Linux Command user management commands, linux Command user management

Source: Internet
Author: User

Linux Command user management commands, linux Command user management

Groupadd

[Function description]

Create user group

[Syntax format]

Groupadd [-f] [-r] [-g <GID> <-o>] [group name]

[Option parameters]

Parameters

Description

-F

Create an existing group and force the system to receive existing group names. By default, each group name should be unique in the system. If the group name given by groupadd already exists, an error message is returned.

-R

Create a system account. Because 0-499 is the system's reserved ID, the general group ID starts from 500, and the-r parameter can be used to create a system account with the group less than 500

-O

Force use of an existing group ID

-G <GID>

Set the ID of the newly created group. The value must be a unique and non-repeating positive integer. If this parameter is not specified, the system automatically assigns the new group number starting from 500.

Id

[Function description]

Display the ID of the user and the group

# Query the user and the actual ID of the group (RUID/RGID, EUID/EGID). You can use the id command. If the two IDs are the same, only the actual ID (RUID/RGID) is displayed ). If no user name is specified, the current user ID is displayed.

[Syntax format]

Id [-g] [-G] [-n] [-r] [-u] [-help] [-- varsion] [user name]

[Option parameters]

Parameters

Description

-G

Display the ID of the user group

-G

Display the ID of the additional group to which the user belongs

-N

Displays the name of the user, group, or additional group, which must be used together with-u,-g, or-G.

-R

Displays the actual ID, which must be used together with-u,-g, or-G

-U

Show user ID

 

Passwd

[Function description]

Set Password

# The passwd command is used to set or modify user commands. Common users can only change their own passwords, while the system administrator can set passwords for all users. If no user name is specified, the current user password will be changed directly. The Passwd file is a list of system accounts, including each user's encrypted password. Only superusers are allowed to write

In the/etc/passwd file, each line is a user record, including the following format

Account: password: UID: GID: GECOS: dirrctory: shell (account: password: User ID: Group ID: General information: Directory :)

The character description is as follows:

Account: the name of the user in the system. It cannot contain uppercase letters.

Password: encrypted user password or Asterisk

UID: number of user IDs

GID: number of major group IDs of a user

GECOS: this field is optional and is usually set to store information.

Dirrctory: $ HOME directory of the user

Shell: The program that runs during login (if it is empty, use/bin/sh). If it is set to a non-existent execution, you cannot log on through login.

[Syntax format]

Passwd [-d] [-k] [-l] [-S] [-u <-f>] [user name]

[Option parameters]

Parameters

Description

-D

Delete password, dedicated to System Administrator

-K

The password can only be updated after it expires.

-L

Lock the account. Add "!" to the encrypted password string. The password of the account is invalid and cannot be logged on to the system. Used by system administrators only

-S

Lists password-related information. This parameter can be used only by the system administrator.

-U

Unlock the locked account and delete the added "!", Recover the account password. This parameter can be used only by the system administrator.

-F

A group of passwords are randomly generated to forcibly unlock the locked account. Must be used like parameter-u

Su

[Function description]

User Switching

# If a user is logging on with a normal account, what functions can be implemented only by the root account? Using the su command, you can easily switch the user logon identity to complete the corresponding work.

[Syntax format]

Su [-f] [-l] [-m] [-p] [-- help] [-- version] [-] [-c <command>] [-s <shell >] [User Account]

[Option parameters]

Parameters

Description

-F

Does not read the Startup File, applicable to csh and tcsh

-L

Change the working directory while changing the identity, as well as HOME, SHELL, USER,

-M

The environment variable is not changed when the identity is changed.

-C

After executing the specified command, restore the original identity

-S

Specifies the shell to be executed. By default, the shell of the specified user is executed in/ect/passwd.

[User Account]

User to be changed. The default value is root.

Sudo

[Function description]

Change identity Execute Command

# The sudo command allows users in Linux to execute commands as other identities to reduce the logon times and management practices of root users and improve system security.

Sudo can restrict specified users to run certain commands on the specified host and provide the system administrator with configuration files to centrally manage user permissions. The default storage address is/etc/sudoers. Note: Only users specified in the/etc/sudoers file can execute the sudo command.

[Syntax format]

Sudo [-VhlLvksHSb] [-p <prompt>] [-c <Class Name>] [-u <Class Name>] [command]

[Option parameters]

Parameters

Description

-L

Show all commands allowed by the user

-L

Show all allowed commands

-V

The password extension time. The default time is five minutes.

-K

The password validity period is invalid. Therefore, you need to enter the password again next time you execute sudo.

-S

Read Password from standard input device

-C <Class Name>

Restrict the running of commands by the specified class

-U <User Name>

Run the command as the specified user identity. By default, the command is run as the root identity. If the user ID is used to specify the user, use # <user ID> instead of the user name

 

Userdel

[Function description]

Delete User Account

# Userdel is used to delete the specified user account in linux. Directly execute The userdel command to delete the user account. After adding the r parameter, you can delete the user logon directory and all the files and subdirectories in the logon directory.

[Syntax format]

Userdel [-r] [User Account]

[Option parameters]

Parameters

Description

-R

Deletes the logon directory of a specified user.

Usermod

[Function description]

The usermod command is used to modify user account settings and related information.

[Syntax format]

Usermod [-L] [-U] [-c <remarks>] [-d <logon directory>] [-e <validity period>] [-f <buffer days>] [-g <group>] [-G <group>] [-1 <account>] [-p <password>] [-s <shell>] [-u <uid >] [User Account]

 

[Option parameters]

Parameters

Description

-L

Change the user password. Usermod adds "!" to the encryption of the user account. Symbol to invalidate the user password. This parameter cannot be used together with-p or-U.

-U

Unlock Password

-F

Life cycle between password expiration and account Shutdown

-G

Modify the group to which the user belongs

-G

Modify the additional group to which the user belongs

-P

Change User Account Password

-S

Modify the shell used after login.

-U

Modify user ID

The final conclusion may not be so much time.

Thanks

The document is from Zhang Dong, the complete Linux Command technology guide.

Related Article

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.