Switch user commands the difference between su and -su
First, the root user can easily switch to any user without a practical password
When a normal user switches to the root user, it needs to provide the root user's password, not the password of the normal user.
When using the SU command to switch to the root user, although the user account is switched to root, but the shell with the ordinary user's own shell is not the root user's shell, environment variables are normal user environment variables
When using the-SU command to switch users, the shell and environment variables are switched to the shell and environment variables of the user being switched, which is the essential difference between Su and-SU
The user file is present under the /etc/passwd file, this file has seven columns, separated by:
| First column |
Second column |
Third column |
Fourth column |
Fifth Column |
Sixth column |
Seventh column |
| User name |
password, corresponding file/etc/shadow |
UID, the UID can be specified with the parameter-u=xxx, the default normal user is starting from 500, the special user is 0-499
|
GID can specify gid with parameter-g=xxx |
Explanatory notes |
The location of the home directory can be specified with-d=directory directory location |
Specifies that the Shell,root user and the normal user are used by default /bin/bash, you can use the parameter if you do not allow the user to log in-s= /sbin/nologin or/bin/fals |
Add user's command useradd parameter username-n Cancel group created with username-M does not automatically establish a user's login directory-f Specifies the number of days after the password expires the expiration date of the specified account-E
The user group's profile has five columns under the /etc/gropup file, separated by:
| The second column |
Third column |
group name |
Group Password |
Group ID GID Normal group default starting from 500, System group is 0-499, specifying system group can use parameter-R, note, must be less than 499 |
The password file for the user group is under the /etc/gshadow file
Add a user group command groupadd parameter group name-G can specify the group ID, if you skip the median number, it will start with the last number set, such as setting the GID to 510, the next time if the default create group will start from 511, the middle will be empty, You can use-G to specify, delete the group if there are users inside, is not to delete the group, you must first delete the user, and then delete the group. Except for expansion groups.
2016-6-21 Knowledge Points Summary