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 understand the rights management under Linux

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

How to understand the rights management under Linux, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

Once the next Linux file is created, it can be accessed in three ways

1. Read to display the contents of the file

two。 Write, you can edit it or delete it

3. Execute, if the file is a shell script or program

According to the user, the permissions of the file can be divided into three categories.

1. File owner, the user who created the file

two。 Users in the same group, any user of the user group to which the file owner belongs

3. Other users, users in other user groups that do not include file owners

[root@VM_0_14_centos] # lltotal 32drwxr-xr-x 4 root root 4096 Nov 28 00:09 group-chatdrwxr-xr-x 5 root root 4096 Oct 16 11:41 new-blog-rwxr--r-- 1 root root 2303 Sep 17 11:31 start_sb_app.sh...

Analyze the results of the command

Output interpretation total 32 the space occupied by all files in this directory drwxr-xr-xd represents the type of file, rwxr-xr-x9 characters represent the file's access rights 4 the number of hard links to this file the owner of the file, the master root file, the default group (also known as root) 28 the length of the file, Nov 28, the update time of the file at 00:09, the name of the group-chat file.

The types of files are as follows

Symbol introduction d directory l symbolic link (to another file) s socket file b block device file c character device file p named pipe file-ordinary file, or, more accurately, files that do not belong to the above types

Rwxr-xr-x9 characters represent the access rights of a file. These 9 characters can be divided into three groups of rwx: file belonging to primary permissions, rmurx: same group user permissions, rmerx: other user rights.

On the rwx location-indicates that the corresponding access is prohibited

Give me a few examples to demonstrate. I'm sure you'll understand it soon.

The meaning represented by permissions is r-the file is readable, but cannot write or execute rwx r-r-the file belongs to the master to read, write, execute, the same group and other users can only read rwx rwx rwx everyone can read, write, execute change permission symbol mode

The general format of the chmod command is

Chmod [who] operator [permission] filename

The meaning of who

Character interpretation u file belongs to primary permissions g same group user rights o other user rights an all users (file owners, same group users and other users)

The meaning of operator

Character interpretation + add permissions-cancel permissions = set permissions

The meaning of permission

Character interpretation r read permission w write permission x execute permission

To give a few examples, assume that the initial permission of the myfile file is rwx rwx rwx

The command result implies that chmod a murx myfilerw- rw- rw- withdraws the execution rights of all users chmod go-w myfilerw- r-r-withdraws the write permissions of the same group of users and other users chmod Usenx myfilerwx r-r-gives the file owner absolute execution permissions

It is a powerful idea to use the 0 and 1 of the two-tier numbers to represent the permissions of the user, as shown in the following figure! When the user has read and write execution permission at the same time, the binary is 111 and the conversion to 10 is 7, so 777 indicates the file owner, and both users in the same group and other users have read and write execution permissions.

Examples are as follows

Command result meaning chmod 777 myfilerwx rwx rwx gives all users read, write and execute permissions chmod 644 myfilerw- r-r-gives file group read and write permissions, all other users read permissions chmod 444 myfiler- r-r-gives all users read permission

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Development

Wechat

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

12
Report