Article title: Introduction to the user management mechanism in Linux. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic classification names: adduser
Permission: System Administrator
Usage: adduser [-c comment] [-d home_dir]
[-E expire_date] [-f inactive_time]
[-G initial_group] [-G group [,...]
[-M [-k skeleton_dir] |-M] [-p passwd]
[-S shell] [-u uid [-o] [-n] [-r] loginid
Or adduser-D [-g default_group] [-B default_home]
[-F default_inactive]
[-E default_expire_date]
[-S default_shell]
Note: The adduser and useradd commands are the same commands (symbolic link is connected by symbols)
Description: adds a user account or updates preset user information.
Parameters:
-C comment: annotation data of the new user in the password file (usually/etc/passwd)
-D home_dir: Set the user's home directory to home_dir, and add the user account loginid after the preset home value.
-E expire_date sets the validity period of this account (in the format of YYYY-MM-DD), default value is permanently valid
-F inactive_time example:
Adduser is used to add users.
In contrast, you can also delete user commands, userdel.
Syntax: userdel [login ID]
Name: su
Permission: all users
Usage: su [-fmp] [-c command] [-s shell] [-- help] [-- version] [-] [USER [ARG]
Note: to change the identity of another user, except for the root user, you must enter the user's password.
Parameters:
-F or -- fast does not need to read the startup file (such as csh. cshrc), and is only used for csh or tcsh
-M-p or -- preserve-environment does not change the environment variable when su is executed
-C command or -- command = command is changed to the USER whose account is USER, and then the USER is returned after executing the command.
-S shell or -- shell = shell specifies the shell (bash csh tcsh, etc.) to be executed. the default value is the USER shell in/etc/passwd.
-- Help: Display the description file
-- Version: displays version information.
--L or -- login is added as if login is the USER again. most environment variables (such as home shell user) are dominated by this USER, the working directory will also change. If no USER is specified, it is set to root.
USER account to be changed
Input a new shell parameter using ARG.
Example:
The su-c ls root account is changed to root, and the account is returned to the original user after the ls command is executed.
Change the su root-f account to root and input the-f parameter to the newly executed shell.
Su-clloud changes the account to clloud and changes the working directory to the home directory (home dir) of clloud ).
Name: sudo
User permissions: Users in/etc/sudoers
Usage: sudo-V
Sudo-h
Sudo-l
Sudo-v
Sudo-k
Sudo-s
Sudo-H
Sudo [-B] [-p prompt] [-u username/# uid]-s
Sudo command
Note: execute commands as system administrators. that is to say, commands executed through sudo are like commands executed by the root user.
Parameters:
-V: Display version number
-H: the version number and instructions are displayed.
-L display the permissions of the user (the user who executes sudo)
-V because sudo is not executed during the first execution or within N minutes (N is set to 5), the password is asked. this parameter is re-confirmed. if it exceeds N minutes, will also ask the password
-K will force the user to ask the password for the next sudo execution (whether or not the password exceeds N minutes)
-B: execute the command in the background.
-P prompt can change the password prompt, where % u is replaced by the user's account name, and % h displays the host name
-U username/# The uid does not contain this parameter, which indicates that the command is to be executed as root, but this parameter is added, commands can be executed as username (# uid is the user number of this username)
The SHELL specified by the shell in the-s execution environment variable, or the shell specified in/etc/passwd
-H: specify the HOME directory in the environment variable as the user's HOME directory for identity change (if the-u parameter is not added, the system administrator root is used)
Command the command to be executed as a system administrator (or changed to another person as a-u)
Example:
Sudo-l lists the current permissions
Sudo-V lists sudo version information