In Linux systems, adding new users is an important part of managing system permissions and security. This article will reveal the specific methods of adding users in the Linux operating system, including specific code examples and step instructions, to help readers quickly master the skills of adding users.
adduser
command to add a user. Theadduser
command is the preferred tool for adding users in Debian and Ubuntu. This command will calluseradd
command and set some default values, simplifying the user addition process.
To add a new user, you can follow the steps below:
sudo adduser newuser
After executing the command, the system will prompt you to enter the new user’s password, name and other information. Follow the prompts to complete the settings and you will be successful. Add new user.
useradd
command to add a userIn addition to theadduser
command, theuseradd
command is also a commonly used addition User mode. This command provides more option settings that can be customized according to needs.
To add a user using theuseradd
command, you can follow the steps below:
sudo useradd -m -s /bin/bash newuser
In this command, the-m
option indicates the creation of a user. At the same time, create the user's home directory; the-s
option indicates the specified user's shell. Through this command, you can set the user's permissions, home directory and other information as needed.
passwd
command to set the user passwordWhether you use theadduser
oruseradd
command to create a user, you need Set the user's password. This can be achieved through thepasswd
command:
sudo passwd newuser
After executing the command, the system will prompt you to enter a new password and confirm the password. After the setting is completed, the user's password will officially take effect.
usermod
command to modify user attributesIn addition to adding new users, sometimes it is also necessary to modify user attributes, such as changing the user's group, home directory, etc. At this time, you can use theusermod
command:
sudo usermod -aG sudo newuser
In this command, the-aG
option means to add the new user to the sudo group so that it has administrator rights. . User attributes can be flexibly managed through theusermod
command.
deluser
command to delete a userWhen a user is no longer needed, you can use thedeluser
command to delete the user and its related files :
sudo deluser newuser
After executing the command, the system will delete the user and his home directory to ensure system security and cleanliness.
Through the above introduction, readers can understand how to add users in the Linux system, and master how to use different commands to add users, set passwords, modify attributes, and delete users. Mastering these skills will help improve the efficiency and security of system management. I hope this article will be helpful to readers, and you are welcome to try and further learn Linux system management skills.
The above is the detailed content of Linux User Management: Revealing New User Operations. For more information, please follow other related articles on the PHP Chinese website!