


Interpretation of file permissions under Linux system - (user, group, read, write and execute)
Often when deploying a website, the code has been uploaded, the database has been imported, and the configuration file has been changed. But when I entered the domain name, I still got an error. The reason was probably due to file permissions. Today let’s take a look at file permissions under Linux
Users, groups
Linux philosophy Everything is a file, and all files will have their own owners , the group it belongs to. Also, any user must definitely belong to a group. Except for the owner of the file and the users in its group, all other users of the system are the others of the file. How to check users under Linux can be done by viewing the /etc/passwd file.
# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt ……
Through the ls -l command, you can view some attributes such as the owner and group of the file.
# ll total 17484 drwxr-xr-x 3 root root 4096 Dec 2 2019 backup drwxr-xr-x 2 root root 4096 May 15 08:32 bin drwxr-xr-x 10 root root 4096 Jan 8 2020 c_language_code drwxr-xr-x 2 root root 4096 Jun 12 10:46 c_practice -rw-r--r-- 1 root mail 8500 Sep 13 03:47 dead.letter
Of course, we can modify the owner and group of the file through commands
# 同时改变用户和组 -R表示递归修改 # chown -R www:www backup # ll -d backup drwxr-xr-x 3 www www 4096 Dec 2 2019 backup # 仅改变用户 # chown -R root backup # ll -d backup drwxr-xr-x 3 root www 4096 Dec 2 2019 backup # 仅改变组 # chown -R :root backup # ll -d backup drwxr-xr-x 3 root root 4096 Dec 2 2019 backup # 还可以通过chgrp改变组 # chgrp -R www backup/
File permissions
Now Let's take a look at the file permissions. The file permissions can also be viewed through ls -l.
drwxr-xr-x
There are 10 characters in total, which can be divided into four groups, d, rwx, r-x, r-x.
d indicates the type of the file. Common ones are - (file), d (directory), b (block device)
th The second group represents the permissions owned by the user of the file, rwx represents readable, writable, and executable respectively. If replaced by -, it means that you do not have that permission.
The third group represents the permissions owned by the group of the file
The fourth group represents the permissions owned by other people in the file Permissions
Readable, writable, and executable are a bit abstract, and they have different meanings for different file types. Below, I will make a table to help you understand:
File | Directory |
r means yes To check the file information, you can use cat/less/more/head/tail and other commands to check the file information | r means you can list the file list in the directory, you can execute the ls command |
w means that the file content can be modified, and the file content can be modified through vim | w means that files can be created or deleted in this directory, and commands such as touch and mv can be executed |
x means that the file can be executed | x means that you can enter the directory and execute the cd command |
Let’s take a look below Command chmod, through which the permissions of files can be modified. First introduce the numerical representation of permissions: r (4), w (2), x (1)
# chown -R root:root study_file/ # chmod 700 study_file/ #数字方法设置权限 # ll -d study_file/ drwx------ 2 root root 4096 5月 5 13:13 study_file/ # chmod u=rwx,g=r,o=r 1.txt # chmod a-x 1.txt # chmod 600 *.txt # ll 总用量 4 -rw------- 1 root root 34 5月 5 12:22 1.txt -rw------- 1 root root 0 5月 5 13:13 2.txt -rw------- 1 root root 0 5月 5 13:13 3.txt
The above is the detailed content of Interpretation of file permissions under Linux system - (user, group, read, write and execute). For more information, please follow other related articles on the PHP Chinese website!

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.

The core components of the Linux system include the kernel, file system, and user space. 1. The kernel manages hardware resources and provides basic services. 2. The file system is responsible for data storage and organization. 3. Run user programs and services in the user space.

Maintenance mode is a special operating level entered in Linux systems through single-user mode or rescue mode, and is used for system maintenance and repair. 1. Enter maintenance mode and use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can check and repair the file system and use the command "fsck/dev/sda1". 3. Advanced usage includes resetting the root user password, mounting the file system in read and write mode and editing the password file.

Maintenance mode is used for system maintenance and repair, allowing administrators to work in a simplified environment. 1. System Repair: Repair corrupt file system and boot loader. 2. Password reset: reset the root user password. 3. Package management: Install, update or delete software packages. By modifying the GRUB configuration or entering maintenance mode with specific keys, you can safely exit after performing maintenance tasks.

Linux network configuration can be completed through the following steps: 1. Configure the network interface, use the ip command to temporarily set or edit the configuration file persistence settings. 2. Set up a static IP, suitable for devices that require a fixed IP. 3. Manage the firewall and use the iptables or firewalld tools to control network traffic.

Maintenance mode plays a key role in Linux system management, helping to repair, upgrade and configuration changes. 1. Enter maintenance mode. You can select it through the GRUB menu or use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can perform file system repair and system update operations. 3. Advanced usage includes tasks such as resetting the root password. 4. Common errors such as not being able to enter maintenance mode or mount the file system, can be fixed by checking the GRUB configuration and using the fsck command.

The timing and reasons for using Linux maintenance mode: 1) When the system starts up, 2) When performing major system updates or upgrades, 3) When performing file system maintenance. Maintenance mode provides a safe and controlled environment, ensuring operational safety and efficiency, reducing impact on users, and enhancing system security.

Indispensable commands in Linux include: 1.ls: list directory contents; 2.cd: change working directory; 3.mkdir: create a new directory; 4.rm: delete file or directory; 5.cp: copy file or directory; 6.mv: move or rename file or directory. These commands help users manage files and systems efficiently by interacting with the kernel.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
