Linux basic commands-user management

Source: Internet
Author: User

Add User: useradd

-U uid specifies the UID of the new user. By default, the current maximum uid is used to add 1

-G group: Specifies the group of the new user.

-G: Specify the additional group for the new user

-D specify the Home Directory of the new user

-S specifies the shell used by new users. The default value is Bash.

-C Additional information

-E: Specifies the user expiration time.

-M: create a home directory for the new user

View the user's basic information: IDUser1: view the basic information of user1.

If you only enter the id command, the basic information of the current user will be returned. whoami can also be. Who can also.

 

Add User Group: groupadd

Groupadd-G 888 group2 creates a user group group2 whose GID is 888

 

Delete user: userdel

Userdel-r username Delete account and its home directory

 

Disable User Account

Disabling an account means that users are not allowed to log on to the system for the moment, and their data must be retained. you can edit the etc/passwd file and mark the row of the account to be stopped. add a ticket number to stop the user Jane.

# JANE: X: 1000: 1000: Jane,:/home/JANE:/bin/bash

You can also use another method to change the user's shell to false or null or nologin.

Jane: X: 1000: 1000: Jane,:/home/JANE:/bin/false

Jane: X: 1000: 1000: Jane,:/home/JANE:/bin/null

Jane: X: 1000: 1000: Jane,:/home/JANE:/usr/sbin/nologin

 

Delete user group: groupdel

 

Change User: usermOd

Usermod-l username disable account

Passwd-l Username Password Disabled

Usermod-u username resume Disabled Account

Passwd-u username resume disabled Password

 

Change User Group: groupmod

 

Change Password: passwd

 

Switch User: su

If the root account does not have a password set, it cannot run with Su to the root account.

Directly run the su command without any user name parameters. By default, the system switches back to the root user.

Note: We recommend that you use Su-user when using the su command to load environment variables of that user.

 

Switch user execution: sudo

Sudo passwd this command sets the password for the root user.

Sudo is equivalent to Sudo-u root command by default.

If you want to use another user, you can use Sudo-u user2 command.

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.