
Linux is a free and open source operating system that is widely used in servers, embedded devices, personal computers and other fields. In Linux systems, adding new users is a common operation. This article will explain in detail how to use commands to add new users, including specific code examples.
1. Commands to add new users
In the Linux system, the command to add new users mainly uses theuseraddcommand. Theuseraddcommand is used to create a new user and can specify the user's home directory and other information. The following is the basic syntax of theuseraddcommand:
useradd [options] username
Among them,optionsrepresents the options that can be added, andusernamerepresents the new user to be created. username.
2. Specific steps for adding new users
Use theuseraddcommand to add a new user. For example, to add a user with the user name "newuser", you can use the following command:
sudo useradd newuser
Set the new user's password. Use thepasswdcommand to set a password for the new user, for example:
sudo passwd newuser
The system will prompt you to enter the password, enter it twice to confirm.
Optional step: Specify home directory and other information for the new user. If you need to specify additional information such as a home directory, you can add options to theuseraddcommand, for example:
sudo useradd -m -s /bin/bash newuser
Among them, the-moption indicates creating a home directory, ## The #-s /bin/bashoption indicates that the specified shell is bash.
In order to demonstrate the process of adding a new user more intuitively, the following is a complete example process:
sudo useradd testuser sudo passwd testuser
sudo useradd -m -s /bin/bash testuser
Adding new users is one of the commonly used operations in Linux systems. After mastering the use of related commands, you can easily add new users to the system to achieve more flexible management. When adding a new user, be sure to set a secure password and specify home directory and other information for the new user as needed to ensure the security and stable operation of the system. I hope this article has helped you add new users in your Linux system.
The above is the detailed content of Complete Guide to Adding Users in Linux. For more information, please follow other related articles on the PHP Chinese website!