Add root users in linux

Source: Internet
Author: User
Step 1: Add a common user to create a user, set the password, modify the user, and delete the user: useraddtestuser create user testuserpasswdtestuser to set the password description for the created user testuser: the new user will create a user directory testuseruser under/home...

 

Step 1: Add a common user

 

 

Create users, set passwords, modify users, and delete users:

Useradd testuser create user testuser

Passwd testuser: Set the password for the created user testuser

Note: the newly created user creates a user directory testuser under/home.

Usermod -- help modify the parameters of the user command

Userdel testuser delete user testuser

Rm-rf testuser: delete the directory of user testuser

 

The above commands can only be used by the root account. if you do not know where the commands on your system are located, you can use the following command to find the path:

 

Locate useradd

Step 2: Add permissions

Edit the/etc/passwd file,

Change the uid and gid of the newly added user to 0:

Originally:

Testuser: x: 5: 5:/home/testuser:/bin/bash

After modification:

Testuser: x: 0: 0:/home/testuser:/bin/bash

 

Other methods:

 

 

Useradd-u 0-o-g root-G root-d/home/user1 user1

 

 

Note:

 

-U 0 indicates that the uid is specified as 0 (0) and the root is the same. the prompt after logon is # rather than $.

 

-O indicates that this parameter must be specified because the uid already exists (which is the same as the uid of the root account.

 

-G root: group name of the initialization group. when a user belongs to multiple groups (specified in the-G parameter), the group in which the user logs on. By default, the system creates a group with the same name as the user name and sets the group name at initialization, regardless of the group specified by-G.

 

-G root specifies the group list to which the user name belongs. a user can belong to multiple groups. the group names are separated by commas (,). The group names must already exist.

 

-D/home/user1 specifies the user's home directory

 

User1.

 

 

 

Test: you can use the id user1 command to test the attributes of user1:

 

Uid = 0 (root), gid = 0 (root), group = 0 (root)

 

Note: gid indicates the initialized GID number.

 

Author 0XCC

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.