


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!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.
