SUID 及 SGID

 

Special permissions and file access control lists

Introduce:

# ls –l `which passwd`

There are three special permissions

SOUTH:

Explanation: When running a program, the owner of the corresponding process is the owner of the program file itself, not the initiator (the initiator can temporarily have root privileges)

chmod u+s FILE

chmod u-s FILE

Note: If the FILE itself has execute permission, the SUID is displayed as s (lowercase), otherwise it is displayed as S (uppercase)

Case:

Remarks: When we find that the owner of a file is root, and giving him SUID will bring danger to the file at this time, it will be more troublesome if there are other people who have editing rights.

 

Additional :

Because ordinary users can change their own passwords

Example: I wrote a script. If you need to get system properties, you must have the s permission at this time. In the past, scripts written in perl language in the background of the website needed to have s permission to obtain information, and such websites were easy to be invaded.

 

SGID:

Explanation: When running a program, the group of the corresponding process is the group of the program file itself, not the basic group to which the initiator belongs

Format: chmod g+s FILE

    chmodg-s FILE

Note: If the FILE itself has execute permission, the SUID is displayed as s (lowercase), otherwise it is displayed as S (uppercase)

 

Example:

There are three people hadoop, hbase and hive. They have a common directory /tmp/project. All three users are required to create files in this directory. Since the files created by the three users belong to the same project, all three users can view them. and edit each other's files.

How to achieve this?

Question: Three users can view and edit each other's files, but they can also delete each other's files. How to solve this problem?

This uses the following sticky

Sticky:

Explanation: In a public directory, everyone can create files and delete their own files, but cannot delete other people's files

Format: chmod o+t DIR (for directories)

            chmodo -t DIR (for directories)

Case: continue the above

Note: You cannot delete other people's files, but you can delete your own files.

The above problem is solved

How to write a paragraph of text in a blank document and save it

Press i to enter edit mode

: wq, save and exit

Cat View

 

:s /old/new Replace the first string of characters found on the current line with "old" with "new"

         :s/old/new/g Replace all found strings "old" on the current line with "new"

         :#,#s/old/new/g Replace all strings "old" with "new" in the range of line numbers "#,#"

         :%s/old/new/g replaces all strings "old" with "new" in the whole file

         :.,$-1s/old/new/g Replace all strings "old" with "new" from the current line to the penultimate line

         Note: The delimiter can be /, @, #

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324843703&siteId=291194637