Linux account and Rights management commands

Source: Internet
Author: User

Linux user accounts are divided into:

Super User root (uid 0)

Normal User (UID 500 and above)

Program User (UID 1-499)

Group account:

Basic Group (Private group)

Additional groups (public groups)


/etc/passwd

Save the user name, host directory, login shell and other basic information, each line corresponding to one user's account records, seven fields

Example: Teacher:x:500:500:teacher:/home/teacher:/bin/bash

Field meaning: User name: Password placeholder: uid:gid: User description: Host directory: Login Shell


/etc/shadow

Save the user's password, account validity and other information, each line corresponding to a user's password record, nine fields

Field meaning: User name: encrypted password: Last modified password time: Minimum validity: Maximum validity: Early expiration warning: Days after password expires: Account expiration: Reserved field


Useradd Add user account

-u: Specify UID tag number

-D: Specify the host directory, default to/home/user name

-e: Specify the account expiration time

-G: Specify the user's base group name (or UID number)

-G: Specify the user's additional group name (or GID number)

-M: Do not establish and initialize the host directory for the user

-S: Specify the user's login shell


Initial profile of user account (template/etc/skel)

~/.bash_profile: Executed every time the user logs on

~/.BASHRC: Execute every time you enter a new bash environment

~/.bash_logout: The user executes each time they log out


passwd Change your account password

-D: Clear the user's password so that it can log in and delete the user account without a password Userdel

-L: Lock user account

-S: Check the status of the user account (whether locked)

-U: Unlock user account


Usermod modifying the properties of a user account

-L: Change the login name of the user account

-L: Lock user account

-U: Unlocking user accounts

The following options have the same meaning as in the Useradd command

-U,-D,-e,-G,-G,-S


Userdel Delete user account

-R: Indicates that the user's host directory is deleted


Group account Files

/etc/group: Save group account basic information

/etc/gshadow: Save password information for group account


Groupadd Add a group account


GPASSWD Set group account password (rarely used), add/Remove Group members

-A: Adding a user to a group

-D: Delete a user member from within a group

-M: Defines a list of group members, separated by commas


Enquiry Account Information

ID Command Query user identity

The groups command queries the group to which the user belongs

Users, W, who commands query for user information that is logged on to the host


Permissions and attribution of files/directories

Access rights

Read R:4 allows viewing of file contents, displaying directory listings

Write W:2 allows you to modify the contents of a file, allowing new, moved, deleted files or subdirectories in the directory

Execute x:1 allows you to run programs, switch directories


Attribution (ownership)

Owner: The user account that owns the file or directory

Group: An account number that owns the file or directory


chmod setting permissions for files and directories

Format: chmod [Ugoa] [+-=] [rwx] file or directory ...

or chmod nnn file or directory ...


Chown setting the attribution of files and directories

Format: chown: Genus group File or directory








This article is from the "Yang Shufan" blog, make sure to keep this source http://yangshufan.blog.51cto.com/13004230/1947306

Linux account and Rights management commands

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.