Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set file viewing permissions in Mac

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to set file view permissions in Mac? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Give an example

# Let's first create a test directory $mkdir test & & cd test# create a main.txt file and write something $echo hello world > > text.txt# then create an empty directory $mkdir js# view information $ls-ltotal 8drwxr-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:

# Common format of permission information:-rwxr-xr-x number user group filesize updatetime filename

The common format is divided into seven parts, which are:

1. File attribute, indicating that the type of the file is read / write / executable, etc., with a total of 10 characters

The first character represents the type, and the next nine characters are divided into three groups, indicating the read / write / executable permissions of the file relative to the current user (user), the group in which the current user belongs (group), and other users (other).

Rwx: for permission,-for no permission, r for read with read permission, w for write with writeable permission, x for execute with executable permission

Take the main.txt above as an example. The first character is -, which indicates the file type, while the first character of the js directory is d, which represents the directory directory.

The next three characters are rw-, to indicate that the file is readable and writable to the current user, but cannot be executed

The next three characters are rmurf, indicating that the file has read-only access and no write and executable permissions for members of the group in which the current user belongs.

The last three characters are also rMurray, indicating that the file can only be read, not written and executed for other users.

2. Number, indicating the number of inode of the file, and inode indicating the area where the original information of the file is stored.

3. User, which indicates the current user name

4. Group, which indicates the name of the user group to which the current user belongs

5. Filesize, which indicates the size of the file, in byte

6. Updatetime, indicating the last modification time of the file

7. Filename, which represents the file name

Modify file permissions

The permission of main.txt is-rw-r--r-- 1 frank staff 13 7 12 19:52 main.txt, and the permission for other users is r Merry, that is, you can only read but not write. What if you have a requirement that you want other users to write? At this point, you need to modify the permissions of main.txt so that other users can also write.

# Command format for modifying permissions $[sudo] chmod [] [file or directory]

1. Scope of authority

U: user, indicating the owner of the file or directory

G: group, indicating the group to which the file or directory belongs

O: other, except for the owner or group to which the file or directory belongs, all other users fall within this scope

A: all, that is, all users, including the owners of files or directories, the groups to which they belong, and other users

2. Permission operation

+ means to increase permissions

-denotes cancellation of permission

= indicates unique set permissions

3. Specific permissions

R means readable

W means writable

X means executable

After explaining so much, now let's give other users write permission to main.txt through command operation:

# Let other users have write permission $chmod otakw main.txt# confirm $ls-l main.txt-rw-r--rw- 1 frank staff 13 7 12 19:52 main.txt# gives all users executable permissions, but cannot be modified and not readable $chmod a+x-r-w main.txt# reconfirms-x--x--x 1 frank staff 13 7 12 19:52 main.txt finish reading the above Do you know how to set file viewing permissions in Mac? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report