Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux user and Rights Management

Shulou Source: shulou.com Published: 2022-06-02 19:34:43 09月10日 Update

First, users and user groups

The gods are like the root in our Linux.

(1) Linux file permissions

Unlike the Windows system, in the Linux system, each file adds a lot of attributes, especially the concept of user groups, what is the use of this?

1. The function of system protection

2. The function of team developing software or data sharing

3. Harm if permissions are not set properly

Chgrp: change the group to which the file belongs

Chown: change the file owner

Chmod: change the permissions of the file. Characteristics of SUID,SGID,SBIT, etc.

Change the permission to the maximum permission 777 (r read = 4 ~ w write = 2 ~ ~ x execute = 1)

Symbol type changes file permissions

U: owner

G: belonging to group

O: other

A: all

If I don't know the original file properties, and I just want to increase the permissions that everyone in the .bashrc file can write to, then I can use:

And what if you want to remove permissions without changing other existing permissions? For example, to remove the executable permissions of all people, then:

The meaning of the permissions of directories and files

Default and hidden permissions for files and directories:

The default permissions for directories are (777) and the default permissions for files are (666).

For example:

It turns out it's 022.

Well, if it is a directory, then use 777-022 permissions 755. All permissions of this directory are 755.

The file is 666-022. 644, so the file permission is 644.

As shown in the figure:

Default and hidden permissions for files and directories:

+ I means you can't do anything, which is like locking the directory.

-I means to unlock the directory

View locked directories

File special permissions: SUID=4, SGID=2, SBIT=1. Special permissions must have execute (x) permission in advance.

What is the special function of SUID permissions for a file?

SGID has the following functions

This Sticky Bit, SBIT is currently only valid for directories, but has no effect on files. The role of SBIT for directories is:

For example, our / tmp own permission is "drwxrwxrwt", under which anyone can add or modify files in / tmp, but only the file / directory creator and root can delete their own directories or files. This feature is also very important! You can do a simple test like this:

Will find that shan'bu can not be deleted, you can use sudo (temporarily call root permission to operate)

Tags: Permissions files directories that is functions users special system properties properties user groups proper maximum effective important for example role content creator team Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Redmi macOS vpn MariaDB