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

Detailed explanation of user group and file permissions under Linux

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

Share

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

User group

Each user in linux must belong to a group and cannot be independent of the group. In linux, each file has the concept of owner, group, and other groups.

Owner

Group

Other groups

Change the group in which the user belongs

Owner

Generally speaking, the creator of the file, who created the file, will naturally become the owner of the file.

You can see the owner of the file with the ls-ahl command

You can also use the chown username file name to modify the owner of the file

Group in which the file belongs

When a user creates a file, the group of the file is the group of the user

You can see all groups of files with the ls-ahl command

You can also use the chgrp group name file name to modify the group in which the file belongs

Other groups

Except for the owner of the file and the users of the group, the other users of the system are all other groups of the file.

File permissions

Ls

-l is shown as follows:

10 characters to determine what different users can do with the file

The first character represents file (-), directory (d), link (l)

The rest of the characters are in groups of 3 (rwx), read (r), write (w), execute (x)

The first set of rwx: the file owner's permissions are read, write, and execute

The second group of rw-: users in the same group as the file owner have read and write permissions but cannot execute

The third group, rmuri: other users who are not in the same group as the file owner have read, write and execute permissions.

It can also be expressed as: ringing 4, welling 2, and therefore rwx=4+2+1=7.

1 indicates the number of files connected

Root represents the user

Root indicates the group in which the user belongs

1213 represents file size (bytes)

Feb 2 09:39 indicates the last modified date

Abc represents the file name

Command to change permissions

Chmod changes permissions for a file or directory

Chmod 755 abc: give demo01.sh permission rwxr-xr-x

Chmod uprirwx dir gendrx Magneo demo01.sh: ditto u = user rights, g = group permissions, o = different groups other user rights

Chmod Uripx Magazine Grouw demo01.sh: remove the user's permission to execute and increase the group write permission for abc

Chmod Avocr demo01.sh: add read permissions to all users

Change owner (chown) and user group (chgrp) command

Chown xiaoming abc: change the owner of abc to xiaoming

Chgrp root abc: change the group abc belongs to to root

Chown root. / abc: change the owner of the abc directory to root

Chown-R root. / abc: change abc this directory and all the files and directories below it are owned by root

Change the user's group

When you add a user, you can specify which group to add the user to, and also use the administrative privileges of root to change the group in which a user belongs

Usermod-g group name user name

You can use it.

Usermod-d directory name, user name, change the initial directory where the user is logged in

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