1. Linux Users
The operating system does not differentiate users by user name, but by ID to differentiate users
ID ID Student
Admin account Default Uid=0
Normal user is UID assigned starting from 1000
UID Security and user account information for the user: in the/etc/passwd file
CAT/ETC/PASSWD |grep Student
Student:x:1000:1000:student User:/home/student:/bin/bash
Student represents the user name
X indicates whether the authentication
1000 indicates UID (number of users)
1000 = GID (number of the group)
Student User represents the description information of users
/home/student represents the home directory where the user resides
/bin/bash indicates that the shell environment
User's password file: in the/etc/shadow file
Cat/etc/shadow |grep Student
Student represents the user name
16442 indicates the number of days the password was created (from 1970.1.1 onwards)
0 indicates the minimum validity period
99999 indicates the maximum validity period
7 indicates 7 days before expiration reminder
2. Linux Group
Information for a collection group of multiple users is saved in/etc/group
There are two types of groups:
Primary Group
Each user has a primary group
The local user's primary group is represented by GID, and the user's primary group can be seen in the/etc/passwd file
Typically, the group of user-created files is owned by the master Group;
Typically, when a user is created, the UID and GID of the user are the same
When you create a user, the system creates a primary group of the same name
Users cannot be removed from the primary group
Additional groups
The user may be 0 or more additional group members
Users can be removed from additional groups
One user can belong to multiple additional groups, but only one primary group
View information for additional groups, which can be viewed in/etc/group
Additional groups help users access other resources on the system
Root Super Admin
Install software \ Remove software \ Create User ... Must have Administrator privileges
(1) Su-Switch user
- For switching user environments
Su root/home/student Switch user, do not switch directories
Pwd
Su-roor/root switch User, switch directory
Pwd
sudo elevated user rights
A tool that allows an administrator to allow an ordinary user to perform some or all of the root commands;
To use sudo, you must first set up authorization;
Sudo Authorization Method:
Visudo (Administrator can Visudo)
Sudo-l View sudo authorization
2)vim /etc/sudoers
Useradd
Useradd USESR1
Sudo Useradd user1
Sudo Password expiration is 5 minutes by default
Sudo-k the cache empty
3. Manage Local Users and groups
Useradd
-C Specify Note information
-D Specify home directory
-e Specify the expiration date for the account
-g Specifies the primary group ID
-G Specify additional group ID
-M Create home directory (default creation)
-M do not create home directories in general, M and s are used together
-s Specifies the user's shell
-U Specify UID
Useradd-c "This usesr was not root" User3 User description Information "This user is not root"
After you create a user, you must create a password for the user
PASSWD User3
Useradd-d/user4/user4
Without creating a user, copy the contents of the/etc/skel to a template from the home directory in the home directory/etc/skel
Useradd-u User7
ID USER6 ID User7 ID User8
USERADD-E 20161231 User9
cat/etc/passwd
Tail/etc/shadow Expiration date of the password
Useradd-g User10 premise is that the primary group exists
Useradd-g User11 Advance is an additional group presence
Cat/etc/group additional groups to view
Useradd-ms/sbin/nologin User12
Linux file system permissions and access control
Directories and files have permissions
U (user) G (group) O (Other)
rwx r-x r-x
File The role of the directory
R (read): Can read the contents of the file list directory filename
W (write): Can change the contents of the file in the directory can create and delete any file
X (EXEC): The file can be executed as a command directory can be accessed
Modify file or directory Permissions
Touch file1
chmod Change permissions for a file or directory
-r recursively change directory permissions
chmod u/g/o/a +/-/= r/w/x file |directory
chmod u+x file1 chmod g+x File1 chmod o+x file1
chmod u-x file1 chmod g-x file1 chmod o-x file1
chmod u=r file1 chmod g=r file1 chmod o= x file1
chmod a=rw-file1
chmod u=rwx,g=rw,o=r file1
can represent permissions in binary mode
---
4 2 1 764
chmod 7 6 4 file1
Modify permissions for a directory recursively: permissions for files in a directory are changed at once
Chmod-r 750/dir1/
(2) Chown Modify the ownership of a file or directory: Change the owner and group of the file
Chown change the ownership of a file or directory
Chown-r recursively modifies the ownership of the directory and the files therein
Chown Student file1 Change file owner
Chown-r Student Dir1
Chown:student file1 changing the group to which the file belongs
Chown student:student file2 Change owner and all groups at the same time
Chown-r student:student Dir1
(3) CHGRP exclusive change asking price or the group to which the directory belongs
CHGRP Root File2
Special permissions:
SUID indicates that execution of the file is performed by invoking the permissions of the file owner
such as: Root user ls-l/usr/bin/passwd
General User Ls-l/bin/passwd
RWS s indicates that suid indicates that the file has execute permissions before
RwS S indicates that this file did not have permission to execute before
Student use root permissions to modify \etc\shadow when performing password modifications
chmod 4764 file1 4 special permissions for users
chmod u+s File2
SGID
Sticky
Linux 124 Lesson 5, Managing local Linux users and groups