Detailed account management

Overview of managing user accounts and group accounts

user account

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

Group account

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 the root user, his UID is 0.
For the program user account, his UID defaults to 1~499.
For ordinary users, his UID defaults to 500~60,000.

User account file

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

Insert picture description hereField explanation

root: x: 0:0:root:/root:/bin/bash
字段1:用户帐号的名称
字段2:用户密码占位待"x"
字段3:用户帐号的UID号
字段4:所属基本组帐号的GID号
字段5:用户全名
字段6:宿主目录
字段7:登录shell信息
(/bin/bash为可登陆系统,/sbin/nologin和/bin/false为禁止用户登陆系统)

Manage the attributes of directories and files

1. Concept:

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

2. View the attributes of the 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 file, l link file,-ordinary file; the
first 2-4 characters: the owner's authority to the file;
the 5-7th character: the authority of the group to the file;
the 8th-10th character: any user to the file Permission;
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;

3. Set permissions for files or directories;

Syntax: chmod [ugoa] [±=] [rwx] file or directory
Example: chmod gx, or file or directory
Option: -R means recursive permission, 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 the directory or file;

Syntax: chown owner file or directory##Set its owner
chown: group file or directory##Set its group
chown owner: group file or directory##Set its owner and group
Note: Option -R Recursively can inherit the ownership of the parent directory from its sub-directory and sub-file;

Expand

1.umask file anti-permission:

umask ##View the system default permission inverse mask value, 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

2. Chattr lock file:

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

Guess you like

Origin blog.csdn.net/weixin_51614581/article/details/110202142