003day -- Common commands for linux User Permissions, 003day -- linux

Source: Internet
Author: User

003day -- Common commands for linux User Permissions, 003day -- linux

I. useradd Command Options:

-U: User's UID useradd-u 1024 mu # The UID of the specified mu is 1024

-G: Specify the user group useradd-g jack mu # specify the mu group as jack

-D: Specify the user's home directory useradd-d/home/family mu # specify the mu home directory as/home/family

-C: Specify the user's remarks useradd-c 'mu _ test' mu # mu's remarks are 'mu _ test'

-S: Specifies the shell used by the user.

**************************************** **************************************** *

Ii. usermod Command Options:

-U: Modify the UID useradd-u 1024 mu # change the UID of mu to 1024

-G: Modify the user's GID useradd-g 2048 mu # change the UID of mu to 2048

-G: Add a user to the specified group. usermod-G jack mu # Add mu to the jack group.

-D: Modify the user's home directory useradd-d/home/family mu # modify the mu home directory to/home/family

-C: Modify the user's remarks useradd-c 'mu _ test' mu # modify the remarks of mu to 'mu _ test'

-S: Modify the shell used by the user

-L: Lock the user account usermod-L mu # Lock the mu

-U: Unlock usermod-U mu # unlock mu

**************************************** **************************************** *

Iii. userdel Command Options

Userdel mu # command for deleting a mu user not to delete his/her home directory

Userdel-r mu # command for deleting mu users and their home directories

**************************************** **************************************** **

Iv. group Command Options

4.1 groupadd command

Groupadd group1 # Add a group1 Group

4.2 groupmod command

Groupmod-g 666 mu # change the GID of the mu group to 666

Groupmod-n jack mu # modify the mu group name to jack

4.3 groupdel command

Groupdel mu # delete a mu Group

**************************************** *************************

5. Homework (50 minutes)

1) create a user named natasha. The uid is 1000, the gid is 555, and the remarks are "master"

Useradd-u 1000-g 555-c 'master' natasha

2) modify the Home Directory of the natasha user to/Natasha

Usermod-d/Natasha natasha

3) view the last line of the user information configuration file

Cat/etc/passwd

Shift + G

4) set the password "123" for natasha users"

Echo 123 | passwd natasha

5) view the last line of the User Password Configuration File

Cat/etc/shadow

Shift + G

6) Lock the natasha User Account

Usermod-L natasha

7) unlock the natasha User Account

Usermod-U natasha

8) create a group police with the gid of 999

Groupadd-g 999 police

9) view the last row of the group configuration file

Cat/etc/group

Shift + G

10) add natasha users to the police Group

Groupmod-G police natasha

11) modify the group name of the police group to jingcha.

Groupmod-n jingcha police

12) Delete the natasha user, and delete the home directory and email address together.

Groupdel-r natasha

13) Delete the jingcha Group

Groupdel jingcha

**************************************** *************************

6. Detailed description of user and group permissions

6.1 ls-l command to View File Permissions

D rwx rw-r --

The first parameter d is the directory file, and there are other symbols:-Common File

The second parameter rwx reads and writes,-indicates that the user of the u owner has no permission.

The third parameter is the same as the user in group g.

The fourth parameter is the same as that of other users.

7 (rwx) 6 (rw-) 5 (r-w) 4 (r --) 3 (-wx) 2 (-w-) 1 (-- w) 0 (---)

Homework (60 minutes)

1) Create the directory test in the user's home directory and enter test to create an empty file file1

Cd/

Mkdir/test

Cd/text

Touch file1

2) display the file information in long format. Pay attention to the permissions and users and groups of the file.

Ll-dl/test/file1

3) Set permissions for file file1 so that other users can write the file.

Chmod o = w/test/file1

4) view the setting result,

Ll-dl/test/file1

5) cancel the permission of users in the same group to read file1 and view the setting result.

Chmod g-r/test/file1

Ll-dl/test/file1

6) set the permission for the file in digital notation. The owner can read, write, and execute the file. The owner and other users in the group can only read and execute the file. After the setting is complete, view the setting result.

Chmod 755/test/file1

Ll-dl/test/file1

7) change the file1 permission in number format so that the owner can only read the file. No other user has permission. View the setting result.

Chmod 400/test/file1

Ll-dl/test/file1

8) return to the upper-level directory to view test permissions.

Cd ..

Ll-dl/test

9) add write permission for this directory to other users

Chmod o + w/test

 

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.