This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11547|Reply: 0

[linux] Linux adds root users

[Copy link]
Posted on 1/3/2015 4:03:19 PM | | |

The first step is to add a regular user



Create a user, set a password, modify a user, delete a user:

useradd testuser to create a user testuser

passwd testuser to set a password for the created user testuser

Note: The newly created user creates a user directory under /home, testuser

usermod --help modifies the parameters of the user command

userdel testuser deletes user testuser

rm -rf testuser deletes the directory where the user testuser is located


The above commands are only available to root accounts, if you don't know your ownsystemThe above command can find its path using the following command:


locate useradd

The second step is to add permissions

Edit the /etc/passwd file,

Change the newly added user uid and gid 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 means that specifying uid as 0 (zero) is the same as root, and the prompt after logging in is # instead of $.


-o means that this parameter must be specified because the uid is duplicated (duplicate with the uid of the root account).


-g root initializes the group name of the group, when the user belongs to multiple groups (specified in the -g parameter), the group to which the user is logged in. When this item is defaulted, the system creates a new group with the same name as the user name, and sets it to the group name when initialized. Regardless of which group -G is specified.


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


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


user1 The new user name is user1.




Test: You can use the id user1 command to test the attribute of the username user1, which is displayed as:


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


Note: The gid indicates the initialization GID number.






Previous:Tor Browser – A browser that allows you to surf the web anonymously
Next:Linux command to modify files and save how to use them
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com