Preface To modify file permissions in the terminal of a Mac system, use the chmod command in Linux. This article will introduce you to files and permissions under Unix and Linux. Let’s take a look at the detailed introduction. Example # Let's create a test directory first $ mkdir test && cd test # Create a main.txt file and write some content $ echo hello world >> text.txt # Create another empty directory $ mkdir js # View information$ ls -l total 8 drwxr-xr-x 2 frank staff 64 7 12 20:03 js # This line is the information of the js directory -rw-r--r-- 1 frank staff 13 7 12 19:52 main.txt # This line is the information of main.txt As shown above, both files and directories have the following information: # General format of permission information: -rwxr-xr-x number user group filesize updatetime filename The general format is divided into 7 parts, namely: 1. File attributes, indicating the file type, read/write/executable permissions, etc., a total of 10 characters;
2. number, which indicates the number of file inodes. Inode indicates the area where the original information of the file is stored. 3. user, indicating the current user name 4. group, indicating the name of the user group to which the current user belongs 5. filesize, indicating the size of the file in bytes 6. updatetime, indicating the last modification time of the file 7. filename, indicating the file name Modify file permissions The permissions of main.txt are -rw-r--r-- 1 frank staff 13 7 12 19:52 main.txt, and the permissions for other users are r--, which means they can only read but not write. What if there is a requirement to allow other users to write? At this time, you need to modify the permissions of main.txt so that other users can also perform write operations. # Command format for modifying permissions $ [sudo] chmod [<permission range><permission operation><specific permissions>] [file or directory] 1. Scope of authority
2. Permission Operation
3. Specific permissions
Having explained so much, let's now use the command to allow other users to also have write permissions to main.txt: # Allow other users to have write permissions $ chmod o+w main.txt # Confirm$ ls -l main.txt -rw-r--rw- 1 frank staff 13 7 12 19:52 main.txt # Allow all users to have executable permissions, but not to modify or read $ chmod a+xrw main.txt # Confirm again---x--x--x 1 frank staff 13 7 12 19:52 main.txt Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: How to make a List in CocosCreator
>>: MySQL variable declaration and stored procedure analysis
This article is mainly to take you to quickly und...
Table of contents What are Refs 1. String type Re...
1. Install MySQL database on mac 1. Download MySQ...
When we display long text, we often need to interc...
Table of contents 1. Use help information 2. Crea...
<br />It has been no more than two years sin...
When threads execute concurrently, we need to ens...
1. What is HTML HTML (HyperText Markup Language):...
1. Problems encountered In the process of distrib...
Knowledge point 1: Set the base URL of the web pa...
Overview: The filesystem module is a simple wrapp...
The overall architecture of NGINX is characterize...
Table of contents Solution 1 Solution 2 When crea...
Table of contents Overview Performance.now Consol...
Please open the test page in a mainstream browser...