1, add ordinary users
[[email protected] ~]# Useradd CHENJIAFA//Add a user named Chenjiafa
[[email protected] ~]# passwd CHENJIAFA//Change Password
Changing password for user Chenjiafa.
New UNIX Password://Enter your password here
Retype new UNIX Password://Enter password again
Passwd:all Authentication Tokens updated successfully
2. Give root permission
Method 1): Modify the/etc/sudoers file, locate the following line, and remove the previous comment (#)
Then modify the user to belong to the root group (wheel) with the following command:
[Email protected] ~]# usermod-g root Chenjiafa
Modified, with Chenjiafa account login, and then with the command su– switch, you can get root permissions to operate.
Method 2): Modify the/etc/sudoers file, locate the following line, and add a line below root as follows:
After the modification, with Chenjiafa account login, and then use the command su–, you can get root permissions to operate.
Method 3): Modify the/etc/passwd file, locate the following line, and change the user ID to 0 as follows:
After the change to save, with Chenjiafa account login, directly get the root account permissions.
==========================================================================
[Detailed su command]
This command is important to enable a general user to have Superuser or other users ' privileges, or to enable a superuser to do something as a normal user. However, the general user must have a password for the superuser or other user when using the command. If you want to exit the current user's login, you can enter exit.
2. Use
The role of SU is to change to another user's identity, and you need to type the user's password (except for the superuser).
2. Format
su [Options] ... [-] [USER [ARG] ...]
3. Main parameters
-F, –fast: Do not need to read the boot file (such as CSH.CSHRC, etc.), only for CSH or tcsh two kinds of Shell.
-L, –login: After adding this parameter, it appears that the user is re-logged as the user, most of the environment variables (such as home, shell, user, etc.) are based on the user, and the working directory will change. If user is not specified, the default is root.
-M,-p, –preserve-environment: does not change the environment variables when performing su.
-C command: Change the user's username and execute the instruction (command) before changing back to the original user.
User: To change the user account, Arg passes in the new shell parameter.
4. Application examples
Change the account to be superuser and restore the user after the DF command is executed. Su-c DF Root
[sudo command detailed]
Function Description : Executes the instruction as a different identity.
syntax : sudo [-bhhpv][-s][-u < user >][instructions] or sudo [-klv]
Additional Instructions : sudo allows the user to execute the specified instruction in a different identity, with the default identity as root. The user who can execute the sudo instruction is set in/etc/sudoers. If an unauthorized user attempts to use sudo, a warning message is sent to the administrator. When using sudo, the user must first enter the password, then have a 5-minute expiration date, and the password must be re-entered after the deadline.
Parameters
-B executes the instruction in the background.
-h displays Help.
-H Sets the home environment variable to the new identity of the home environment variable.
-K The expiration of the password, which is required to enter the password the next time the sudo is executed.
-l lists instructions that are currently available to users and cannot be executed.
-p Change the hint symbol to ask for the password.
-S executes the specified shell.
-u< user > with the specified user as the new identity. If this parameter is not added, the default is the new identity as root.
-V Extend the password for a period of 5 minutes.
-V Displays version information.
User management of Linux