Linux study notes (2)

xiaoxiao2021-03-06  68

1.6 SUID / GUID

Suid means that if a user sets this permissions to belong to its own shell script, then other users will have the corresponding permissions of the owner when performing this script. The same principle also applies to the GUID, and the user who performs the corresponding script will have the user's permissions in the user group belonging.

1.6.1 How to set SUID / Guid

Enter / bin or / sbin directory, execute:

$ ls -l | grep '^ ... s'

The above command is used to find Suid files

$ ls -l | grep '^ ... s ... s

The above command is used to find SUID and GUID files

To set the SUID, set the one before the corresponding permission bit is set to 4; if you want to set the GUID, then set the one before the corresponding permission bit is set to 2; two bits are set, 4 2.

Once this bit is set, a S will appear in the X position. To set up Suid / GUID, you must open the execution permission.

You can also use a symbolic manner to set Suid / GUID.

Note: The chmod command does not perform the necessary integrity checks, you can give any privileges for a file that is useless, but nothing to do for the set permissions.

1.7 Chown and ChGRP

Used to change the owner of the file, but only the owner and system administrator of the file can operate, formatted:

Chown -r -h Owner File

-R means that the files in all word directory are also available

-h means that the target file points to the link pointing to the link when changing the symbolic link file owner

1.7.1 Chown Example

$ Chown LP Project

Give the ownership of the file Project from the original file owner to the user LP

1.7.2 chgrp

The format of CHGRP and the format of Chny are similar, and ChGRP changes the group belonging.

1.7.3 find out the user group you belong to

$ GROUP or $ ID

1.7.4 Find the group to which other users belong

$ group username

1.8 umask

Umask determines the default mode when you create a file. The umask command is set in / etc / profile. If you want to modify the value of umask, put it in your .profile or .bash_profile file in your $ home directory.

1.8.1 How to calculate uMask values

Like the umask and chmod commands, use absolute mode settings, but note that the system does not allow you to give it permission when you create a text file, you must add this permission after you create CHMOD. The directory allows you to set the execution permission.

1.8.2 Common UMASK value

Umask value directory file

022 755 644

027 750 640

002 775 664

006 771 660

007 770 660

Query the current umask value

$ umask

Modify the current UMASK value

$ umask value

1.9 symbolic link

There are two different types of links, soft links, and hard links. Only the soft link is discussed, which is a pointer to a file.

1.9.1 Use soft links to save files

LN [-s] source_path target_path where the path can be a directory or a file.

转载请注明原文地址:https://www.9cbs.com/read-88196.html

New Post(0)