07.linux file Permissions

Source: Internet
Author: User

◊ Basic framework:

A) Linux user category: Root owner Group Other

b) Group Management:

c) User Management

d) Rights Management Chown chmod

1. linux user category

Root: Super Administrator with all permissions, with forced Write permission

2. Group Management commands:

Groups also have their own configuration files: Group files (/etc/group) and known files (/etc/gshadow)

/etc/group file Format: groupname:password:gid:user_list

Groupadd: Adding groups

gpasswd:1) Add Delete Group member: Gpasswd–a

Gpasswd–d

2) Set the group password

Groupmod: Change the name of the group:

Groupmod–n

Groupdel: Deleting a user group

Groups: Displays the group where the user is located

3. User Management commands :

Useradd: Add a user (note that the system creates a default group at the same time as the user is added)

Useradd–g + Default Group –g + other groups

Useradd–d to create a user and specify a home directory at the same time

PASSWD: Set a password for the user

PASSWD + user Name

passwd-d + Username: delete Password

Usermod: Modify user information, use similar to Useradd

Usermod–g + Default Group change default group to which the user belongs

Usermod–l changing user names

Userdel: Deleting users

Userdel–r Delete the user and the corresponding home directory

Id: View the user's UID, default group, and list of groups in which they are located

Su: Switching users

Su-user name: Switch the path to the user's home directory while switching users

This kind of switch is more thorough, the switch executes simultaneously to switch the user's configuration file, carries on some environment initialization.

su equivalent to Su root

4. Rights Management

♦chown: Used to change file owners and groups

Chown + other users: other groups + files

Chown-r + other users: Other groups + folders: Recursive changes

♦CHGRP: Only enough to repair the reorganization, use similar to Chown

♦chmod: Change of permissions

1) Digital Way

Chmod 777 (mode) filename

2) Text mode: [UGOA][+-=][RWX]

U means owner

Chmod–r + folders: Recursive changes

5 , other important details:

1) The meaning of the various permissions of the directory:

W Permissions: Represents the ability to create and delete files in the directory

Permissions for x: Delegate can enter folder

R permissions: You can list the contents of the folder, read the folder

2) Umask:

Folder: Mode = 777 & ~umask

Files: mode = 666 & ~umask

6 , a few special permissions: (Understand)

♦set uid s permission

/USR/BIN/PASSWD-RWsr-xr-x passwd command changes/etc/shadow file

/etc/shadow-r----------

A program's access to a file is not determined by the user who initiated the program, but by the owner of the file.

Characteristics:

1) Valid only for executables, i.e. with x permission

2) This permission is for running processes

3) The running process has the permissions of the program owner

Set GID: Similar to set UID

♦ Sticky bit (sticky bit) t permission (key to understand)

1)/tmp DRWXRWXRWt

2) valid only for catalog

3) Prevent files or directories from being deleted by owner or root user

Practical significance: When a few programmers jointly develop a software, I write the program can only be deleted by myself.

07.linux file Permissions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.