Management of Linux Permissions

Source: Internet
Author: User

(1) Creation and deletion of users under Linux


command to create a user: Useradd jfedu

After this command is executed, it is created for the user:

<1> Create a home directory for users/home/jfedu

<2> Create a group with the same name as the user


To delete a user's command:

Userdel jfedu (keep user's home directory)

Userdel-r jfedu (delete user and home directory)

(2) Switching of Linux users

Switch the root user to the jfedu user

[[Email protected] ~ #] SU jfedu [email protected]]$

Note: Switch User's command: SU user name

<1> ordinary users can only see their own files

<2> View administrator files, will prompt insufficient permissions

<3> View other user files, you need to enter the user's password to access

<4> Normal User failback administrator needs to provide administrator password


Experience Sharing:

When we delete a user and group, it is not recommended to adopt Userdel jfedu, this way delete does not delete the user home directory, this deletion method, although deleted the user. But in the user's same name to create the user, Linux will report that this home directory already exists, the solution is USERDEL-RF jfedu


(3) New user created under Linux, create password

passwd User Name

Comments:

<1> Normal user cannot create password, only root user, have permission to create password


(4) Permissions operation under Linux

<1> in Linux, each file has three permissions, read (R), write (W), execute (x)

Comments:

The directory must have execute (x) permissions, or the content cannot be viewed


<2> view three permissions for a file and view it with Ls-l


<3> How user rights are composed

Drwx-rw-rx-rwx-rw-rx

① the first bit is the D means the directory, the first bit is-represents the ordinary file

② file permissions are composed of User (U), Group (g), others (O), they all have read, write, and execute three kinds of permissions. -Delegate does not have permission


<4> Modify Permissions

chmod u=rw jfedu/chmod=u-x jfedu/chmod=u+x jfedu/

Comments:

<1> jfedu This directory, with read and write permissions, no Execute permissions

<2> u-x means less execution rights u+x means increased execution


Permissions can also be represented by numbers

r=4 w=2 x=1 chmod=700 jfedu

Comments:

<1> indicates that the user has read, write, and Execute permissions

<2> Group and others do not have permission


<5> change the user to which the file belongs

Chown Root jfedu

Comments:

<1> Chown changed user's original user

<2> jfedu now belongs to the user changed to root user


<6> change the group to which the file belongs

CHGRP Root jfedu

Comments:

<1> Chgrp changed user's original user

<2> jfedu now belongs to the group changed to the root group


<7> T permissions

Note: Only the user who owns the file can delete it, others cannot delete it.

Example: chmod o=rwt jfedu/-R

Create a jfedu directory under the TMP directory to add RWT permissions to the other people in this directory. We created 2 users in the TMP directory, respectively, A1,B1. To switch to A1,B1 user, under A1 user Create 123.txt, create 456.txt file under B1 user. A1 users, B1 users can only delete files that they have created and cannot delete other people's files


<8> I permissions

Description: File cannot be written to prevent others from mistakenly deleting

Method of adding I permissions chattr +i test.txt

Ways to view I permissions lsattr test.txt


<9> s permissions

Description: Anyone who sees can perform root permissions

Cases:

In/bin/su this directory, the user has a s permission, can ensure that ordinary users can switch back and forth, if the S permission is removed, the normal user even if the password input is right, also cannot switch

chmod u-s/bin/su

Management of Linux 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.