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
NERDTree is a file system browser for Vim. With t...
Table of contents Current Issues Solution process...
Last time, we came up with two header layouts, on...
Preface: I'm currently learning Linux and .Ne...
Transactions in MySQL are automatically committed...
1. Implement a simple triangle Using the border i...
1. Send effect HTML <div id="send-btn&quo...
As shown in the following figure: When we use vir...
In a word: if you buy a cloud server from any maj...
1. Prerequisites We use the require.context metho...
I searched for three-level linkage on the Interne...
Table of contents 1. Download MySQL 2. Unzip the ...
Preface Most people will probably perform this op...
1. System Configuration 1. Turn off sudo password...
This article example shares the specific code of ...