To list all users you can use:
1 2 3 |
cut -d: -f1 /etc/passwd |
To add a new user you can use:
1 2 3 |
sudo adduser new_username |
This command is more user-friendly than adduser. PERL script which uses useradd in the backend.
or:
1 2 3 |
sudo useradd new_username |
Less user-friendly than adduser, but see What is the difference between adduser and useradd?
To remove/delete a user, first you can use:
1 2 3 |
sudo userdel username |
Then you may want to delete the home directory for the deleted user account:
1 2 3 |
sudo rm -r /home/username |
Use with caution! If you’re unsure, first back up the home directory using the command below:
1 2 3 |
sudo tar -zcvf /home/username.tar.gz /home/username |
To modify the username of a user:
1 2 3 |
usermod -l new_username old_username |
To change the password for a user:
1 2 3 |
sudo passwd username |
To change the shell for a user:
1 2 3 |
sudo chsh username |
To change the details for a user (for example real name):
1 2 3 |
sudo chfn username |
And, of course, see also: man adduser
, man useradd
, man userdel
… and so on.
Note: This is a modified version of this answer on AskBuntu which was so concise.
Speak Your Mind