Ubuntu10.04useradd and adduser

Source: Internet
Author: User
Tags perl script
I have never been confused about the difference between useradd and adduser In Ubuntu. Most posts on the Internet say that the two are actually implementing the same function, but I have a lot of problems when I am doing it myself. Now I will write a memo after the conclusion, so let's take a look. Useradd is a linux Command, but it provides many parameters for users to set according to their own needs. adduser is a perl script, A user interface similar to human-computer interaction is displayed during use. options are provided for users to fill in and select.

I have never been confused about the difference between useradd and adduser In Ubuntu. Most posts on the Internet say that the two are actually implementing the same function, but I have a lot of problems when I am doing it myself. Now I will write a memo after the conclusion, so let's take a look.

Useradd is a linux Command, but it provides many parameters for users to set according to their own needs. adduser is a perl script, the interface similar to man-machine interaction is displayed when you use it. It provides options for users to fill in and select. This command is simpler and dummies than useradd.

I. Detailed description of adduser

When using the adduser command, the system will add this user name and automatically create a user group with the same name as this user name as the initial user group of this user. In addition, a directory with the same name as the user is automatically created under the/home directory, and then the "cp/etc/skel/home/username" operation is executed, initialize the main directory of the new user.

The account created using the adduser command is a system account and can be used to log on to our ubuntu system.

Ii. Usage of useradd

Useradd has a large number of parameters for personalized settings. However, we do not know many default settings. Therefore, you need to be cautious and careful when selecting this parameter. Otherwise, the result may be different from what we expected. The useradd parameters are as follows:

-Add remarks to c remarks. The remarks are added to the 5th field in/etc/passwd.

-D main user folder. Specifies the directory to which the user logs on and gives the user full control over the directory.

-E validity period. The validity period of the specified account. The format is YYYY-MM-DD, which will be stored in/etc/shadow

-F indicates the number of buffer days. Specifies how many days after the password expires to disable the user account

-G main group. Set the main group to which the user belongs

-G Secondary Group. Sets the secondary group to which the user belongs. You can set multiple groups.

-M force not to create the user master folder


-M forcibly creates a main user folder and copies the files in/etc/skel/to the root directory of the user.

-P password. Enter the password of this account

-S shell. Shell used for User Login

-U uid. User id, uid for short

The useradd command creates a common account and cannot be used to log on to the system.

Note: In fact, when I use useradd, there are still many problems. The most impressive thing is that even if I use the "-d" parameter, the user's main folder cannot be correctly created. Later, I directly used the "-m" parameter to force the creation of the user's main folder, instead of the "-d" parameter. As a result, the main folder was created. So I came to the conclusion that when the "-m" parameter is used, the system will automatically create a main user folder with the same name as the new user in the/home Directory; if "-m" is not used, the "-M" parameter is used by default, and the main folder is not created, even if you use the "-d" parameter. Therefore, the "-d" parameter is used with "-m" to allow you to select the path of the main folder.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.