File permissions view and setup details in Mac
- 2021-01-02 22:08:55
- OfStack
preface
Modifying file permissions on the end of the Mac system uses the chmod command in Linux. This article will introduce you to files and permissions under Unix and Linux. Without further ado, let's take a look at the details
For example,
# So let's create 1 Five test directories
$ mkdir test && cd test
# create 1 a main.txt File and write 1 Some of the content
$ echo hello world >> text.txt
# To create a 1 An empty directory
$ mkdir js
# Check the information
$ ls -l
total 8
drwxr-xr-x 2 frank staff 64 7 12 20:03 js # This line is js Directory information
-rw-r--r-- 1 frank staff 13 7 12 19:52 main.txt # This line is main.txt The information of
As shown above, 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, which are:
1. File attribute, indicating that the file type is read/write/execute and other permissions, with 10 characters in total;
2. number represents the number of file inode, and inode represents the area where the original information of the file is stored;
3. user, represents the current user name
4. group, the name of the user group that the current user is in
5, filesize, represents the size of the file, the unit is byte
6. updatetime, indicating the last modification time of the file
7, filename, represents the file name
Modify file permissions
main.txt's permission is -ES72en-ES73en --r-- 1 frank staff 13 7 12 19:52 main.txt, the permission for other users is r-- that is, can only read and cannot write, what if there is a demand that other users can write? At this point, you need to modify the main.txt permissions so that other users can write as well.
# Modify the command format for permissions
$ [sudo] chmod [< competence >< Permission to operate >< Specific privileges >] [ File or directory ]
1. Scope of authority
2. Permission operation
3. Specific authority
With that said, let's now command main.txt to allow other users to write:
# Let other users 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
# Let all users have executable permissions, but not modifiable and unreadable
$ chmod a+x-r-w main.txt
# To confirm again
---x--x--x 1 frank staff 13 7 12 19:52 main.txt
conclusion