Home  >  Article  >  System Tutorial  >  Understanding Linux file permissions, plain and simple

Understanding Linux file permissions, plain and simple

王林
王林forward
2024-02-13 19:39:03590browse

Linux is a multi-user and multi-tasking operating system. It has strict permission control on access and operations of files and directories. If you want to manage your files efficiently on Linux, you need to understand the concept and usage of Linux file permissions.

了解 Linux 文件权限,简单明了
user group other
read=4 X X X
Write = 2 X
execution=1 X X X
total (4 2 1) = 7 (4 1) = 5 (4 1) = 5

For example, 4 2 1 = 7, grant read, write, and execute permissions; 4 1 = 5, grant only read and execute permissions. Therefore, 755 grants 7 (read, write, execute) to the file owner, 5 (read and execute) to the group the file belongs to, and 5 (read and execute) to the world. Each number corresponds to a set of permissions (read, write, or execute), and the position of the number corresponds to the user category (left = owner, middle = group, right = other). The single digits for all three user categories are defined as follows:

0 – – – Inaccessible
1 – – X Execute only
2 -w- Write access only
3 -wx Write and execute
4 r – – Read only
5 r-x Read and execute
6 Read and write- Read and write
7 Read and write Read, Write and Execute (Full Access)

Some file permission examples:

777 – Read/Write/Execute by everyone (full access).
755 – Owner can read/write/execute, group/others can read/execute.
644 – Owner can read/write, group/others can only read.

Some directory permission examples:

777 – Read/write/search available to everyone.
755 – Owner can read/write/search, others and groups can only search.

Common permission settings:

777 - Use this directory with the appropriate permissions on the files in the directory, please use this directory with great care
755 – Web Storage Folder, CGI Script
751 – Log Folder
701 – webalizer and modlogan folder
666 – Data File
644 – Configuration files (files not updated by scripts, html, gif, etc…)

You can change file permissions using Web Shell File Manager

You can change file permissions using some FTP transfer programs (such as WS_FTP).

WARNING: You may be tempted to simply use chmod 777 on all files and directories, as this ensures that the web server can perform any operations on the files. However, it is strongly recommended that you do not leave the file in this state. Making your scripts open to changes by the web server rather than being read-only is considered a major security risk. We recommend that you consult your programmer to set file permissions correctly.

Through this article, you should have a clear understanding of Linux file permissions and master some common commands and techniques. Linux file permissions are an important feature of Linux systems. They can protect the security of your files and improve your work efficiency. I hope this article is helpful to you. If you want to know more about Linux file permissions, you can refer to the following URL

The above is the detailed content of Understanding Linux file permissions, plain and simple. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete