


What is the concept of linux permissions
chmod command detailed explanation
Usage permissions: All users
Usage method: chmod [-cfvR] [--help] [ --version] mode file...
Linux/Unix file access permissions are divided into three levels: file owner, group, other . Use chmod to control how files are accessed by others.
Mode: Permission setting string, the format is as follows: [ugoa...][[ -=][rwxX]...][,...], where u represents the owner of the file , g represents those who belong to the same group as the owner of the file, o represents other people, and a represents all three.
means adding permissions, - means canceling permissions, = means setting only permissions.
r means readable, w means writable, x means executable, and X means only when the file is a subdirectory or the file has been set to be executable.
-c: If the file permissions have indeed been changed, the change action will be displayed.
-f: If the file permissions cannot be changed, do not display the error message
-v: Display detailed information about permission changes
-R: Make the same permission changes to all files and subdirectories in the current directory (that is, change them one by one in a recursive manner)
--help: Display auxiliary instructions
--version: Display version
Example:
Change file file1. txt is set to be readable by everyone
chmod ugo r file1.txt
Set file file1.txt is readable by everyone
chmod a r file1.txt
Set the files file1.txt and file2.txt to the owner of the file. People who belong to the same group can write to it, but other people can write to it. Then it cannot be written
chmod ug w,o-w file1.txt file2.txt
Set ex1.py so that only the owner of the file can execute
chmod u x ex1.py
Set all files and subdirectories in the current directory to be readable by anyone
chmod -R a r *
In addition, chmod can also use numbers to represent permissions, such as chmod 777 file
The syntax is: chmod abc file
Where a ,b,c are each a number, representing the permissions of User, Group, and Other respectively.
r=4, w=2, x=1
If you want rwx attribute, then 4 2 1=7;
If you want rw- attribute, then 4 2=6 ;
If you want r-x attribute, then 4 1=7.
Example:
chmod a=rwx file has the same effect as chmod 777 file
chmod ug=rwx,o=x file and chmod 771 file The effect is the same
rootPermissions
Detailed explanation of chown command
Usage permissions:root
Usage: chown [-cfhvR] [--help] [--version] user[:group] file...
Description:
Linux/Unix is a multi-person, multi-tasking operating system, and all files have owners. Use chown The file owner can be changed. Generally speaking, this command can only be used by the system administrator (root). Generally, users do not have the permission to change other people's file owners, nor do they have the permission to change the file owner themselves. Change the owner of your file to someone else. Only the system administrator (root) has such permissions.
user: The user of the new file owner
IDgroup: The user group (group) of the new file owner
-c: If the Only display the change action if the file owner has indeed been changed
-f: Do not display an error message if the file owner cannot be changed
-h: Only change the link, not the file that the link actually points to
-v: Display the details of the owner change
-R: For the current All files and subdirectories in the directory undergo the same owner change (i.e., one by one in a recursive manner)
--help: Display auxiliary instructions
--version: Display version
Example:
Set the owner of the file file1.txt to the user jessie of the users group
chown jessie: users file1.txt
Set the owners of all files and subdirectories in the current directory to users of the users group lamport
chown -R lamport:users *
-rw------- (600) -- Only the owner has read and write permissions.
-rw-r--r-- (644) -- Only the owner has read and write permissions; group users and other users only have read permissions.
-rwx------ (700) -- Only the owner has read, write, and execute permissions.
-rwxr-xr-x (755) -- The owner has read, write, and execute permissions; while group users and other users only have read and execute permissions.
-rwx--x--x (711) -- The owner has read, write, and execute permissions; while group users and other users only have execution permissions.
-rw-rw-rw- (666) -- All users have file read and write permissions. This approach is not advisable.
-rwxrwxrwx (777) -- All users have read, write, and execute permissions. An even more undesirable approach.
The following are two common settings for the directory:
drwx------ (700) - Only the owner can read and write in the directory .
drwxr-xr-x (755) - All users can read the directory, but only the owner can change the contents of the directory
The representative number of suid is 4, such as 4755 The result of sgid is -rwsr-xr-x
The representative number of sgid is 2, for example, the result of 6755 is -rwsr-sr-x
The representative number of sticky bit is 1, for example, the result of 7755 is - rwsr-sr-t
The above is the detailed content of What is the concept of linux permissions. 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)

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.

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.

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.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

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.

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

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.
