Linux Getting Started Basics (vi) Linux User basics

Source: Internet
Author: User

Users, Groups

When we use Linux, we need to run as a user, limiting which resources the user or process can use, or not.

Groups to facilitate organization and management of users

Each user has a userid, the operating system is actually using the user ID, not the user name

Each user belongs to a primary group, belonging to one or more subordinate groups

Each group has a groupid

Each process runs as a user and is limited by the resources that the user can access

Each logged-on user has a specified shell

User

The user ID is 32 bits, starting at 0, but for compatibility with older systems, the user ID is limited to less than 60000.

The user is divided into the following three kinds:

Root user (user with id 0 is root)

System User (1~499)

Ordinary users (more than 500)

The files in the system have a user and a owning group

Use the ID command to display information for the current user

Using the passwd command you can modify the current user password

Related documents

/ETC/PASSWD-Saving user information

/etc/shadow-Save the user password (encrypted)

/etc/group-Save Group information

To view logged-in users

Command WhoAmI Display current user

Command who shows who has logged on to the system

Command W shows which users are logged in and what they are doing

pts/0: Graphical interface

Linux many times, the longer the command, the less the display, the fewer commands, the more the display

Create a user

Command Useradd create a new user

$ useradd ZSD Create a new user named ZSD

This command performs the following actions

1. Add user information to/etc/passwd

2. If you use the passwd command to create a password for the specified user, the password encryption is saved in the/etc/shadow file

3. Create a new home directory for users/HOME/ZSD

4. Copy the files in/etc/skel to the user's home directory (this file is a new user's initial file, a new file in this file, such as user documentation, and so on, as long as the creation of new users, will automatically have these files)

5. Create a group that is the same as the user name, and the new user defaults to this group with the same name

Command Useradd supports the following parameters

-D Home Directory

-S Login Shell

-U userid

-G Primary Group

-G Sub-group

can also be implemented by directly modifying the/etc/passwd, but not recommended

Modify user Information

Usermod parameter username

Command Usermod supports the following parameters

-L New user name. $ usermod-l new_name Test_user renamed Test_user New_name

(after modifying the new username, the user name in the/home directory will not change, you need to manually modify, otherwise the user login can not find home directory)

-U new userid. $ usermod-u 1002 Test_user to change Test_user ID to 1002

-D User Home directory location

-G user owned primary group

-G user-owned subordinate group

-L lock user so that it cannot log on

-U unlock Lock

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

Delete User

Command Userdel to remove the specified user

$ userdel test_user (delete user, but keep user's home directory)

$ userdel-r test_user (delete user and delete the user home directory)

Group

Almost all operating systems have a group concept, and through groups we can easily categorize and manage users. In general, we use the classification of departments, functions, or geographical areas to create usage groups.

Each group has a group ID

The group information is stored in the/etc/group

Each user has a primary group and can also have up to 31 subordinate groups

Create, modify, delete a group

Command Groupadd used to create a group

$ Groupadd lab104

Command Groupmod used to modify group information

$ groupmod-n newname oldname Modify Group name

$ groupmod-g newgid oldgid Modify Group ID

Command Groupdel used to delete a group

$ Groupdel lab104

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.