This article introduces the operations related to user manegement of linux system . Including adding users, deleting users, setting user passwords, home directories, default shell, etc.
Add a user
Add a user named as user_name.
sudo useradd user_name
Set user’s password
Set password for the user named as user_name.
sudo passwd user_name
Then, input new password for the user.
Delete a user
Delete the user named as user_name.
sudo userdel user_name
Force to delete the user named as user_name with the user data.
sudo userdel -f -d user_name
Modify a user
Change user‘s home directory.
sudo usermod -d new_home_path
Change user’s shell program.
sudo usermod -s path_to_the_shell
Deactivate a account.
sudo usermod -l user_name
Activate a account.
sudo usermod -u user_name
View user information
View user account information, such as belonging group, home directory, shell, etc.
sudo cat /etc/passwd