October 23, 2015
LUKS Drive EncryptionRemoving Linux User
How to remove user from a linux (system) safetly:
Keep in mind the following process is to make sure a user is SAFELY removed from the system, if you want to remove the user, jump to “To delete user account called [user], enter:”
The following is the recommended
passwd -l username
Backup files from /home/user to /backup:
tar -zcvf /backup/account/deleted/[user].$uid.$now.tar.gz /home/[user]/
Please replace $uid, $now with actual UID and date/time. userdel command will not allow you to remove an account if the user is currently logged in. You must kill any running processes which belong to an account that you are deleting, enter:
pgrep -u [user] ps -fp $(pgrep -u [user]) killall -KILL -u [user]
To delete user account called [user], enter:
userdel -r [user]
Delete at jobs, enter
find /var/spool/at/ -name "[^.]*" -type f -user [user] -delete
To remove cron jobs, enter:
crontab -r -u [user]
To remove print jobs, enter:
lprm [user]
To find all files owned by user [user], enter:
find / -user [user] -print
You can find file owned by a user called [user] and change its ownership as follows:
find / -user [user] -exec chown newUserName:newGroupName {} \;