User account and group account of LINUX entry (3)

1. Overview of managing user accounts and group accounts

1.1 User account

It is divided into super users, ordinary users, and program users

1.2 Group accounts

It is divided into basic group and additional group, also known as private group and public group

UID and GID
UID
User IDentity, user identification number
For root users, his UID is 0.
For program user accounts, his UID defaults to 1~499.
For ordinary users, his UID defaults to 500~60000.

GID
Group IDentify, group identification number

For root users, his UID is 0.
For program user accounts, his UID defaults to 1~499.
For ordinary users, his UID defaults to 500~60,000.

1.3 User account file

File location:
Each line in /etc/passwd corresponds to a user's account record

Insert picture description here

root: x: 0:0:root:/root:/bin/bash
Field 1: The name of the user account
Field 2: The user's password will be occupied by "x"
Field 3: The UID number of the user account
Field 4: The account of the basic group to which it belongs the GID number
field 5: full name
field 6: host directory
field 7: information login shell
(/ bin / bash to be landing system, / sbin / nologin and / bin / false to disable user login system)

2 Manage the attributes of directories and files

2.1 Concept:

Access authority: read (r), write (w), execute (x)
Ownership: Owner: the user who owns the file
Belonging to the group: the group account that owns the file

2.2 View the attributes of a file or directory:

ls -ld directory or file location
Format: file type, permission, number of inodes, owner, group, size, date, file name
Permission list:
first character: file type, d directory, b block device file, c character Device files, l link files,-ordinary files; the
first 2-4 characters: the owner's authority to the file;
the 5-7th characters: the authority of the group to the file;
the 8th-10th characters: any user to the file Permission;
the representation of permissions :
r: read, view content, can also be represented by 4;
w: write, write (delete, change, move, etc.) content, can also be represented by 2;
x: execute, execute this file Or cd to this directory, it can also be represented by 1;

2.3 Set permissions of files or directories;

Syntax: chmod [ugoa] [±=] [rwx] file or directory
Example: chmod gx, or file or directory
Option: -R means recursive permissions, sub-directories and sub-files in the directory inherit the permissions of the parent directory;
syntax: chmod 775 file or directory

.4. Set the ownership of a directory or file;
syntax: chown the owner of the file or directory##set its owner
chown: a group file or directory##set its own group
chown owner: a group file or directory##set its owner Owner and group
Note: Option -R recursively can inherit the ownership of its sub-directory and sub-file from the parent directory;

3 Expansion

3.1 umask file anti-permission:

umask ##Check the default permission inverse mask value of the system, the maximum file permission is 666, and the directory maximum permission is 777
umask ### ##Manually change the inverse mask value of file permissions, and create a file or directory verification inverse mask after the change value

3.2 chattr lock file:

chattr +i file path##Lock the file, do not move or delete, etc.
chattr -i file path##Unlock the file

Guess you like

Origin blog.csdn.net/weixin_44324367/article/details/110228180