User management in linux can be done by using many commands that already provided. User management in linux includes the management of user and group of users.
User management operation is recommended using root user. To login as root user, use
sudo -icommand then enter the username and password.
To create a new user, use
Then, insert related data to the new user.
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for fox Enter the new value, or press ENTER for the default Full Name : fox mccloud Room Number : 64 Work Phone : 123123 Home Phone : 123123 Other : Is the information correct? [Y/n] Y
useradd command is also available for creating new user. With this command, the additional information about the new user isn't needed.
To change certain user's password, use
To change password for group, use
All available users can be seen with
more /etc/passwd. This is the output example.
This output includes many information such as username for login, password, user ID, group ID, additional informations, home directory and login shell.
To remove an user, use
userdel command followed with user's name.
To remove an user include it's home directory, use
userdel -r command.
userdel -r test
To create a new group, use
groupadd command followed with group name.
To add a new member into a group, use this command. In this command, the user with username
nathan is added into
usermod -a -G ravenwest nathan
To view a list of groups, use
more /etc/group command. This is the output example from the command.
This output includes many information such as group's name, encrypted password, GID number, group's members.
To remove a group, use
delgroup command followed with group name.
To remove an user from certain group, use
deluser command. In this example, the user with username
fox is removed from group called
deluser fox ravenwest
I hope this article is helpful for learning user management in linux, if you have any thoughts or feedbacks. You can write in the discussion section below.