当前位置:网站首页>Getting started with Lunix commands - user and file permissions (Chmod details)
Getting started with Lunix commands - user and file permissions (Chmod details)
2022-07-24 06:14:00 【A small EZ】
summary
This article mainly introduces Lunix The user operation in the command is related Such as useradd userdel etc. . And file permission modification chmod command
Introduce
First of all, we need to clarify a core theme Lunix It is a multi-user system composed of files
Composed of documents , Naturally, there are operations on files ,Lunix There are three main operations for files read (Read) , Write (Write), perform (Excute)
Multiuser system ,Lunix Multiple users in can use the system at the same time , Then a series of permission problems will naturally arise . It can be roughly divided into user And user groups . Users are divided into administrators and ordinary users .
The user action
Click the link above to see all the guides
Add users
Common commands are as follows , That is, a new one named zizy Users of
useradd zizy
Set the user's password
by zizy The password specified by the user is 123456
passwd zizy
New password:123456
Re-enter new password:123456
Change user groups
We want to create a project named mysql Group , Group No 5000( The group number is used to uniquely identify a group ), The users of this group manage the database
groupadd -g 5000 mysql
At the same time, we put zizy Users adding to mysql In the group As one of the database administrators
usermod -g mysql zizy
Delete user
Delete user zizy
userdel zizy
Delete the group
groupdel mysql
File permissions
The document has attribution , Users with different identities have different permissions for different files
lunix The main documents are file type and File permissions attribute
The types of documents are Catalog d , file - , link l , Interface b , port c
The authority of documents is divided into read r , Write w , perform x
A common file attribute is expressed as
-rwxrwxrwx
first - Indicates that this is a file
The first after rwx Express The user of the file has Read write execution rights
the second rwx Indicates that the user group to which the file belongs has Read write execution rights
Third rwx Indicates other users ( Non affiliated users Non affiliated user group ) There are Read write execution rights
The type of file and the permissions of different users are calibrated through ten digits ,
Without this permission, the corresponding bit will become -
as follows
drwxr-xr--
This is a directory
The users are Read write execution rights
The user group belongs to read Executive authority
Other users can only read jurisdiction
Change file permissions
Use chmod Command to modify file permissions
Numerical assignment
This is also the most common method Using a digital 4 2 1 Represent the r w x
And add them Such as rwx by 7 rw- by 6 r-x by 5 r-- by 4
For a file a01 Use the following command
chmod 761 a01
The permission attribute of this file is
-rwxrw---x
Direct assignment method
about user (u) User group (g) Other users (o) Give permission directly
For a file a01 Use the following command
chmod u=rwx,g=rx,o=x a01
The permission attribute of this file is
-rwxr-x--x
Use + - Symbol Add delete permission
For the following permissions a01 file
-rwxr-x--x
Use the following command
chmod u-w ,o+rw a01
Permissions will change to
-r-xr-xrwx
Advanced
Okay Now friends should understand the basis of file permissions , Now let's talk about some advanced and fancy
Use umask To get file permissions
umask Set the default permission for users to create files , You can use commands umask Check it out. umask value .
simply It's through umask To get to know When we create a new file What is its default permission .
umask There are four Such as 0043 generally speaking Let's just look at the last three of it namely 043
about file , Use 666 subtract umask value Then odd digits +1( All odd digits have to be added by one )
666 - 043 = 623 Then add one to the odd number The permission of the file is 624
-rw--w-r--
about Folder Use 777 subtract umask value that will do
777 - 043 = 734 The permissions of the folder are 734
drwx-wxr--
Special file permissions
setuid about user (u) Give super permissions , use s Express
- Suppose the original permission is rwx , + s obtain rws . namely rwx + s -> rws
- Suppose the original permission is rw- , + s obtain rwS. namely rw- + s -> rwS
setgid about User group (g) Give super permissions
- Suppose the original permission is rwx , + s obtain rws . namely rwx + s -> rws
- Suppose the original permission is rw- , + s obtain rwS. namely rw- + s -> rwS
sticky Only the owner or root Can be deleted , about Other users (o) operation
- Suppose the original permission is rwx , + t obtain rwt . namely rwx + t -> rwt
- Suppose the original permission is rw- , + t obtain rwT. namely rw- + T -> rwT
notes : Case and rwx The first two of are irrelevant Only with the third x Yes no of
For the following permissions a01 file
-rw-rwxrw-
Use this operation
chmod u+s,g+s,o+t a01
The result is zero
-rwSrwsrwT
Special permission to use digital identification
setuid setgid sticky Use them separately 4 2 1 Express
The logo is in front of three As the first At this time, the permission of the file It becomes four
For example, the file permission bit is 741
Use chmod Join in setuid and sticky After the authority
chmod u+s,o+t a01
It becomes 5741 , 5 Marked setuid and sticky
边栏推荐
- Accessing a one-dimensional array with a pointer
- Machine learning & deep learning introduction information sharing summary
- JVM系统学习
- Foundation of JUC concurrent programming (8) -- read write lock
- Calculation steps of principal component analysis
- 什么是单调栈
- Thymeleaf快速入门学习
- Unity基础知识及一些基本API的使用
- 【数据库系统原理】第四章 高级数据库模型:统一建模语言UML、对象定义语言ODL
- Day2 websocket+ sort
猜你喜欢

Openpose2d transform 3D pose recognition

Openpose Unity 插件部署教程

How does the latest version of text (TMP) UI text of unity display in Chinese

ue4 换装系统 2.换装系统的场景捕捉

ue4 换装系统3.最终成果

Unity Shader :实现漫反射与高光反射

day-7 jvm完结
![[principles of database system] Chapter 5 algebra and logic query language: package, extension operator, relational logic, relational algebra and datalog](/img/6a/c30b139823208a2e021135a4bf8d58.png)
[principles of database system] Chapter 5 algebra and logic query language: package, extension operator, relational logic, relational algebra and datalog

【无需公网IP】为远程桌面树莓派配置固定的公网TCP端口地址

UE4 replacement system 3. Final results
随机推荐
EXCEL 生成mysql语句批量操作
What is monotone stack
unity2D游戏之让人物动起来-上
Using keras to realize LSTM time series prediction based on attention mechanism
Conversion of world coordinate system, camera coordinate system and image coordinate system
MySQL foundation - constraints
Lunix命令入门 - 用户及文件权限(chmod 详解)
UE4 reload system 2. Scene capture of reload system
Jupyter notebook select CONDA environment
ue4换装系统 1.换装系统的基本原理
Using keras to realize multidimensional (multivariable) time series prediction of cnn+bilstm+attention
餐饮数据统计分析---泰迪云课程大作业
day1-jvm+leetcode
Unity(三)三维数学和坐标系统
Introduction to QT new project
Dameng database_ Supported table types, usage, characteristics
QT char to qstring hexadecimal and char to hexadecimal integer
C language linked list (create, traverse, release, find, delete, insert a node, sort, reverse order)
QT drawing exception using pure code
碰壁记录(持续更新)