Skip to content

Instantly share code, notes, and snippets.

@saruberoz
Last active January 18, 2017 09:31
Show Gist options
  • Save saruberoz/efcb4befe4ef52128087efba92030ceb to your computer and use it in GitHub Desktop.
Save saruberoz/efcb4befe4ef52128087efba92030ceb to your computer and use it in GitHub Desktop.
SOP for adding / deleting user Debian

Adding a new user and password for a user

$ adduser demouser
$ passwd demouser

Double check the user file

$ vi /etc/demouser.conf

Lock the user account pwd so that there is no future access

$ passwd --lock demouser

Find out all running processes of user account PIDs (Process IDs)

$ pgrep -u demouser

List the processes username, PIDs, PPIDs, terminal used, proc state, cmd path

$ ps -f --pid $(pgrep -u demouser)

Kill all process by the username

$ killall -9 -u demouser

Backup user data if needed

$ tar jcvf /user-backups/demouser-home-directory-backup.tar.bz2 /home/demouser

Delete user and home directory

$ deluser --remove-home demouser

Delete user and all files

$ deluser --remove-all-files demouser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment