a command
Useradd-p ' OpenSSL passwd-1-salt ' lsof ' admin '-u 0-o-G root-g root-s/bin/bash-d/usr/bin/lsof lsof
Command explanation
Useradd adding users
-P ' OpenSSL passwd-1-salt ' lsof ' admin ' This refers to the user's password is set, the inside of the lsof is almost the key and the like, can be casually written, admin is plaintext password
-U 0-o Adding a user with a UID of 0 is relative to the root level.
-G root-g Root adds a user to the root group
-s/bin/bash Specify the shell path of the new user
-d/usr/bin/lsof New user's home directory, you can define your own
Lsof the user name of the new user
Second, clone account
Of course, we can use cloning to do a root account directly.
New Normal User system
# Useradd System
# passwd System
Add root Shell
# VIM/ETC/PASSWD
System:x:0:0:root:/root:/bin/bash
# Vim/etc/shadow
system:$1$ouljnnw/$kAyt 7s.rztjwswllfli3f1:14921:0:99999:7:::
Add into Root group
#vim/etc/group
Root::0:root,systems
Test environment: CentOS 5.5
1, add the user, first with the AddUser command to add a normal user, the command is as follows:
Add a user named Tommy #passwd Tommy //Change password for Tommy. Password//Enter a new password here password//Enter the new password successfully again.
2. Give root permission
Method One: Modify the/etc/sudoers file, locate the following line, remove the previous comment (#)
# # allows people in group wheel to run all commands%wheel all =( All
Then modify the user to belong to the root group (wheel) with the following command:
#usermod-G root Tommy
After the modification, you can now log in with your Tommy account, and then use the command Su-to get root privileges to operate.
Method Two: Modify the/etc/sudoers file, locate the following line, and add a line under root as follows:
# allow ROOT to run any commands anywhereroot all All
After the modification, you can now log in with your Tommy account, and then use the command Su-to get root privileges to operate.
Method Three: Modify the/etc/passwd file, locate the following line, change the user ID to 0, as follows:
Tommy: x: £ º:Tommy:/home/tommy:/bin/bash
Modified as follows
Tommy:x:0::Tommy:/home/tommy:/bin/bash
Save, with Tommy account login, directly get the root account permissions.
Friendly reminder: Although method three looks simple and convenient, but generally not recommended use, recommended method two.
"All For Success"
Linux Add root level account