003day–linux common commands for user rights

Source: Internet
Author: User

One, useradd command options:

–u: Specifies the user's UID useradd–u 1024x768 #指定mu的UID为1024

–g: Specifies the group to which the user belongs useradd–g Jack Mu #指定mu的所属群组为jack

–d: Specifies the user's home directory useradd–d/home/family mu #指定mu家目录为/home/family

–c: Specify user's note information useradd–c ' mu_test ' mu #mu的备注信息为 ' mu_test '

–s: Specifies the shell used by the user

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

Second, usermod command options:

–u: Modify UID of user Useradd–u 1024x768 #修改mu的UID为1024

–g: Modify the user's GID useradd–u 2048 mu #修改mu的UID为2048

–G: Adds a user to the specified group usermod–g Jack Mu #把mu加入jack群组中

–d: Modify the user's home directory useradd–d/home/family mu #修改mu家目录为/home/family

–c: Modify user's comment information useradd–c ' mu_test ' mu #修改mu的备注信息为 ' mu_test '

–s: Modifying the shell used by the user

–L: Lock the user's account usermod–l mu #锁定mu

–U: Unlock the user's account usermod–u mu #解锁mu

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

Three, Userdel command options

Userdel mu #删除mu用户不删除其家目录的命令

Userdel–r mu #删除mu用户和其家目录的命令

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

Iv. Group Command Options

4.1 groupadd command

Groupadd group1 #新增一个group1群组

4.2 groupmod command

Groupmod–g 666 mu #修改mu群组的GID为为666

Groupmod–n Jack Mu #修改mu群组名为jack

4.3 groupdel command

Groupdel mu #删除mu群组

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

Five, after-school homework (spents 50 minutes)

1) New user natasha,uid is 1000,gid to 555, note information is "master"

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

2) Modify Natasha user's home directory for/natasha

usermod-d/natasha Natasha

3) View the last line of the user information profile

cat/etc/passwd

SHIFT + G

4) Set the password "123" for the Natasha user

Echo 123 | PASSWD Natasha

5) View the last line of the user's password profile

Cat/etc/shadow

SHIFT + G

6) Lock the Natasha user account

USERMOD–L Natasha

7) Unlock the Natasha user account

Usermod–u Natasha

8) New group Police,gid to 999

GROUPADD-G 999 Police

9) View the last line of the group configuration file

Cat/etc/group

SHIFT + G

10) Add Natasha user to police group

Groupmod-g Police Natasha

11) Modify the group name of the police group to Jingcha

Groupmod-n Jingcha Police

12) Delete Natasha user, even home directory and mailbox deleted together

GROUPDEL-R Natasha

13) Delete Jingcha Group

Groupdel Jingcha

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

Six, user, group permissions detailed

6.1 ls–l command to view file permissions

D rwx rw-r–

The first parameter, D, is a catalog file, plus other symbols: – Normal file

The second parameter rwx read-write execution, which means that no permission is meant for u owner user

The third parameter is the same as Group G users

Fourth parameter ibid o other users

7 (RWX) 6 (rw-) 5 (R-W) 4 (r –) 3 (-WX) 2 (-w-) 1 (–w) 0 (-)

After-school assignments (spents 60 minutes)

1) Create a directory test in the user's home directory, enter test to create an empty file File1

CD/

Mkdir/test

Cd/text

Touch File1

2) display file information in long format, note the permissions of the file and the user and group to which it belongs

Ll–dl/test/file1

3) Set permissions for file File1 so that other users can write to this file.

chmod o=w/test/file1

4) View the setting results,

Ll–dl/test/file1

5) Remove the Read permission from the same group of users to the file File1 and view the setting results.

chmod g-r/test/file1

Ll–dl/test/file1

6) Use digital notation to set permissions for file files, all readable, writable, and executable, and the owning group user and other users have only read and execute permissions. Review the setup results when the settings are complete.

chmod 755/test/file1

Ll–dl/test/file1

7) Change the permissions of the file File1 in digital form so that the owner can only read the file. No other user has permission. View the settings results.

chmod 400/test/file1

Ll–dl/test/file1

8) go back to the upper directory to see the test permissions

Cd..

Ll–dl/test

9) Add write permissions to this directory for other users

chmod o+w/test

The above is the 003day–linux user Rights Common command of all the content, more information, please pay attention to: CPP Learning Network _cpp University
This article fixed link: CPP Learning Network _cpp University -003day–linux User Rights common commands

003day–linux common commands for user rights

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.