Create a new user
Add a new user
1 | sudo adduser robin |
Create user and home directory
1 | sudo useradd -m -s /bin/bash robin |
Here, the -m
flag creates the home directory for the user.
Interesting fact: If there is no home directory created for the user, the user can’t login using the GUI.
Add user to sudo group
1 | sudo usermod -aG sudo robin |
Note: If the user is not added to the sudo-er list, user cannot run the sudo
commands.
Change user password
1 | sudo passwd robin |
Delete a user
1 | sudo deluser robin |
Delete a user with home directory
1 | sudo deluser --remove-home robin |
Change user name
1 | sudo usermod -l newname oldname |
Change user home directory
1 | sudo usermod -d /new/home/dir -m username |
Change user shell
1 | sudo usermod -s /bin/bash robin |