Workshop sixth day

Users and user group management

  1. Command groupadd: New User Group

The format for the new user group: groupadd [-g GID] groupname

Example:

When no -g gid in accordance with the system default create groups

 

 

 

 

Gid create custom groups of acceleration when -g

 

 

 

 

  1. Command groupdel: Delete User Group

Delete a user group in the format: groupdel User Group Name

Example:

 

 

 

 

There is one group can not be deleted: you must delete the account in order to delete a group when the group contains accounts

 

 

 

 

  1. Command useradd: add new users

Add new users format is: useradd -u UID] [[- g GID] [- d HOME] [- M] [- s]

In which the specific meaning of each option are as follows:

-U: represents the custom UID.

-g: represents the new user belongs to a group that already exists, the back can id with the group, you can also name with the group.

-d: indicates that the custom user's home directory.

-M: said they did not establish a home directory.

-s: represents the custom shell.

 

Example: If useradd without any options, directly with the user name, a group with the same name as the user is created

 

 

 

Have to define uid, gid, or belongs to the group, examples of the command is as follows:

 

 

 

 

If the latter -g option with gid does not exist, an error is reported, suggesting that the group does not exist

  1. Command: userdel Delete account

Format delete the account is: userdel [-r] account name

-R role option is that when deleting users, also delete that user's home directory.

Example: do not add -r:

 

 

 

 

       Plus -r

 

 

 

 

First, the user password management

  1. Command passwd: password

Example:

 

 

 

  1. Switching user identity

To create a new user and set a password for him, with which the user can log in again

 

  1. Su command to switch users

Format: su (-) User Name

Example:

 

 

 

  1. Command mkpasswd
  2. Mkpasswd command is used to generate the password. Linux is not the default order, you need to install a software package expect, the installation command as follows:

# yum install -y expect

 

 

 

# mkpasswd -1 12 -s 0 -d 3

 

 

 

 

In the embodiment, -s specified number of special characters, the number of digits specified -d.

Guess you like

Origin www.cnblogs.com/315z/p/12040474.html