Linux Commands Part II (user and Group operations)

Source: Internet
Author: User

1.useradd

"Command Action" creates a new user in the system

Command syntax Useradd (options) (parameters)

"Common Options"

-g Specifies the group to which the user belongs
-G additional groups for the specified user
-U Specify the user's ID

"Parameter description" the user name of the user to be created

"Command Example"

Create a new user Ruan, and specify that his ID is 123

# Useradd Ruan-u 123


2.groupadd

"Command Action" creates a new workgroup

Command syntax Groupadd (options) (parameters)

"Common Options"

-R to create a system workgroup, but the group ID is less than 500

-g Specifies the ID of the group

Parameter description The group name of the workgroup you want to create

"Command Example"

Create a workgroup named Ruan

# Groupadd-r Ruan


3.passwd

The "command function" setting changes the password (but only the administrator can change all the passwords, the user can only change their own password)

Command syntax passwd (options) (parameters)

"Common Options"

-D: Remove password (only for administrators)

-L: Lock the Code.

-u: Unlock locked Account

Account name of the "parameter description" setting password

"Command Example"

Locked Ruant Account, unable to login with password

# passwd-l Ruan

Unlock Ruan user's password lock

# passwd-u Ruan


4.gpasswd

"Command function" Linux under Workgroup files /etc/group and/etc/gshadow的管理工具

Command syntax gpasswd (options) (parameters)

"Common Options"

-A Add user to group
-D Remove the user from the group
-a specifies the group administrator
-R Remove Password
-R Restrict User login group

Parameter description Specifies the group name of the managed workgroup

"Command Example"

Add user Jie to the Ruan Group
# Gpasswd-a Jie Ruan
Restrict Ruan user group users to log in to group
# Gpasswd-r Ruan


5.usermod

"Command function" modifies user information

Command syntax Usermod (options) (parameters)

"Common Options"

-D Modify the user's log in directory
-L Modify the user's account name
-L Lock account password
-U modify UID of user
-U unlock password lock
-G Modify the owning group of the user
-G Modify the user's additional group
-e Modify the effective time of the user account

"Parameter description" requires the user's user name to be modified

"Command Example"

Modify the Jie user name to Ruan

# usearmob-l Ruan Jie

Modify Ruan User Login directory to/010

# usermod-d ruan/010


6.groupmod

"Command Action" modifies the name and ID of a group

Command syntax Roupmod (options) (parameters)

"Common Options"

-G Modify Workgroup ID
-N Modify Workgroup name

Parameter description to modify group name for group

"Command Example"

Rename the Ruan group to Jie
# Groupmod-n Jie Ruan
Modify the group ID of the RUANL group to 520
# GROUPMOD-G 520 Ruan


7.userdel

"Command function" Delete a user's account and related files

Command syntax Userdel (options) (parameters)

"Common Options"

-F: Force the user to be deleted, even if the user is currently logged

-R: Delete the user while deleting all files related to the user

"Parameter description" to delete the user name (but not the option, only delete the user, do not delete the relevant files)

"Command Example"

Delete User ruant and all of his related files

# Userdel-r Ruan


8.groupdel

"Command function" deletes the specified workgroup

"Command Syntax" Groupdel (Parameters)

"Common options" none

Parameter description Delete the name of the workgroup

"Command Example"

Delete Workgroup Ruanjie

# Groupdel Ruanjie


9.id

"Command action" shows the ID of a real-life user-fit and group

"Command syntax" id [options] [parameters]

"Common options" none

Parameter description needs to specify the user name and group name that you want to display for users and groups

"Command Example"

Promise Ruanjie User ID and group ID

# ID Ruanjie


10.newgrp

"Command action" log in to a new group

"Command Syntax" NEWGRP [options]

"Common options" none

Parameter description toggles the name of the group (must be a user of that set)

"Command Example"

To switch the current user to the Jie group

# Newgrp Jie


11.su

"Command function" toggles the currently logged-on user (exit can return to the original user)

"Command Syntax" SU (option) (parameter)

"Common Options"

-C Switch back to the original user after executing the command

-< Parameters > change the working directory (home directory), as well as environment variables when switching users

Parameter description specifies the identity target user name to switch to (not required by the administrator)

"Command Example"

Switch to the Ruan user and change the working directory
# Su-ruan

Change the account to root and exit to the original user after the LS command is executed

# Su-c ls Root

12.chfn

"Command function" changes the information displayed by the finger command

Command syntax CHFN (options) (parameters)

"Common options" none

"Parameter description" needs to specify the user name to change the finger information

"Command Example" none

13.finger (Gdm-plugin-fingerprint)

"Command function" finds and displays user information

"Command Syntax" finger[options [parameters]

"Common Options"-l lists the user's account name, real name, user-specific directory, login used shell, login time, forwarding address, email status, plan file, program file content

"Parameter description" specifies the user name that needs to be queried for information

"Command Example"

Display user information for Ruanjie

# inger-l Ruanjie


14.chsh

The command function is used to replace the shell used to log on to the system. If you do not specify any parameters and user names, the CHSH will be set as an answer.

Command syntax Chsh (options) (parameters)

"Common Options"

-S change the system preset shell environment

-L Show available shells

Parameter description Specifies the user to change the default shell

"Command Example"

View current system available shells

# chsh-l

15.chage

"Command function" is used to modify the expiration date of the account and password

"Command Syntax"

Chage (option) (parameter)

"Common Options"

The minimum number of days that the-m password can be changed (a password can be changed at any time for zero)

The maximum number of days that the-m password remains valid

The date that the-e account expires. This account will not be available after this day.

-D: Date of last change

"Parameter description" user name of the user who needs to be modified

"Command Example"

Modify the validity period of the Ruan user password

# chage Ruan

Linux Commands Part II (user and Group operations)

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.