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
Table of contents Introduction to frm files and i...
Table of contents 1. Component Registration 1.1 G...
If this is the first time you install MySQL on yo...
This article uses the gearman+mysql method to imp...
#docker ps check, all ports are mapped CONTAINER ...
Table of contents 1. Command 2. docker-compose.ym...
<br />Generally speaking, the file organizat...
This article shares the installation tutorial of ...
<br />The page uses UTF8 encoding, and the h...
Storage Engine What is a database storage engine?...
1. The as keyword indicates an assertion In Types...
Preface When sharing a page, you hope to click th...
I just bought an Alibaba Cloud host and couldn’t ...
This article example shares the specific code of ...
This article example shares the specific code for...