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

What are the special file permissions for linux

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the relevant knowledge of "what are the special file permissions of linux?". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In addition to the common read (r), write (w) and execute (x) permissions in linux, there are three special permissions, namely suid, sgid and sticky bit

1 、 suid 、 sgid

Take a look at an example to check the permissions of your / usr/bin/passwd and / etc/passwd files.

[root@MyLinux] # ls-l / usr/bin/passwd / etc/passwd-rw-r--r-- 1 root root 1549 08-19 13:54 / etc/passwd-rwsr-xr-x 1 root root 22984 2007-01-07 / usr/bin/passwd

As we all know, the account and password information of each user is stored in the / etc/passwd file. / usr/bin/passwd is the program to modify and view this file, but in terms of permissions, / etc/passwd only has the right to write (w) the root permission, but in fact, every user can modify the file through the / usr/bin/passwd command, so the special permission setuid in linux is involved here, such as s in-rwsr-xr-x.

Suid is to give ordinary users special rights to execute "only root can be executed". Sgid synonyms means "group".

As an ordinary user, he does not have the right to modify the / etc/passwd file, but after giving / usr/bin/passwd suid permission, the ordinary user can temporarily have the root permission to modify the / etc/passwd file by executing the passwd command.

2. Sticky bit (adhesive bit)

Look at another example to see the permissions of your / tmp directory

[root@MyLinux] # ls-dl / tmpdrwxrwxrwt 6 root root 4096 08-22 11:37 / tmp

The tmp directory is a temporary folder shared by all users, and all users have read and write permissions, so there is bound to be a problem. User A created a file a.file in / tmp, and user B was upset and deleted it in / tmp (because of read and write access). That must not work. In fact, this will not happen because there are special permissions sticky bit (paste bit) permissions, like the last t in drwxrwxrwt

Sticky bit (paste bit) means that unless the owner of the directory and the root user have permission to delete it, other users cannot delete or modify the directory.

That is, in the / tmp directory, only the owner and root of the file can modify and delete it, but not other users, avoiding the problems mentioned above. The general purpose is to open the permissions of a folder and then share files, like the / tmp directory.

3. How to set the above special permissions

Suid:chmod Utility xxx

Sgid: chmod gears xxx

Sticky bit: chmod ostent xxx

Or use octal to add a number to the original number, and the three permissions represent a number similar to the general permission, as follows:

Suid guid stick bit

1 1 1

So: the binary string of suid is 100, and the converted decimal is 4

The binary string of guid is: 010, conversion: 2

Sticky bit binary string: 001, conversion: 1

So it can also be set up as follows: suid:chmod 4755 xxx

Sgid:chmod 2755 xxx

Sticky bit:chmod 1755 xxx

This is the end of the content of "what are the special file permissions for linux". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report