Linux User Management and linux User Management

Source: Internet
Author: User

Linux User Management and linux User Management

1. view existing users in Linux:

[Root @ CMCC_91 ~] # Cut-d:-f 1/etc/passwd

[Root @ CMCC_91 ~] # Cat/etc/passwd | awk-F \: '{print $1 }'

2. You can view the users you want to view through pipelines:

Filter the query results using pipelines: [root @ CMCC_91 ~] # Cat/etc/passwd | awk-F \: '{print $1}' | grep expression.

3. view the logon records of a specified user:

[Root @ CMCC_91 ~] # Last | grep expression; (LOGIN successful user)

[Root @ CMCC_91 ~] # Lastb | grep expression; (unsuccessful logon user)

4. view the information of a single user:

[Root @ CMCC_91 ~] # Finger username; (view the user's login information and directory)

[Root @ CMCC_91 ~] # Id username; (view the group information that the user belongs)

5. view the current user login:

[Root @ CMCC_91 ~] # W

[Root @ CMCC_91 ~] # Who

[Root @ CMCC_91 ~] # Whoami

6. Create a user:

[Root @ CMCC_91 ~] # Useradd [option] username;

Option:

To view all the options, run [root @ CMCC_91 ~] in shell. # Useradd -- help; (the following are some of the most common ones)

-D specifies the login directory of the current login user (that is, after the user logs on, execute cd ~ Directory)

-M: If the logon directory specified by-d does not exist and this attribute is added, the logon directory is automatically created.

-M: do not automatically create a user's logon directory.

-G: Specifies the user group to which the user belongs.

7. delete a user:

[Root @ CMCC_91 ~] # Userdel [option] username;

Option:

To view all the options, run [root @ CMCC_91 ~] in shell. # Userdel -- help; (The following describes several common ones)

-R: the home directories of the users to be deleted are also deleted.

8. Modify existing users:

[Root @ CMCC_91 ~] # Usermod [option] username;

Option:

To view all the options, run [root @ CMCC_91 ~] in shell. # Usermod -- help; (most of them use the options of useradd. The following describes several frequently used options)

-L modify the username of the user

9. User Password Management:

A newly created user cannot log on without a password (This section describes how to set a password for a new user ):

Super Users can specify passwords for themselves and other users. Common users can only use them to modify their own passwords:

[Root @ CMCC_91 ~] # Passwd [option] username;

Option:

To view all the options, run [root @ CMCC_91 ~] in shell. # Passwd -- help; (The following describes some of the more common ones)

For example, modify the password of the current user:

$ Passwd
Old password :******
New password :*******
Re-enter new password :*******

 

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.