User Management Manual in Linux

Source: Internet
Author: User
Keywords linux linux user management linux user management commands
The biggest feature of the linux system is to support multi-user and multi-tasking. If you want to use linux system resources, you must apply for an account from the administrator and open the corresponding permissions at the same time, so that you can use the account to log in to the system and use system resources. .


The linux system account management greatly facilitates the unified management and unified control of system users by the manager. Every Linux user has a unique user name and password. After logging in, he can enter the system and his corresponding home directory. In the actual management of Linux users, we must master three aspects of knowledge:

Add, delete and modify user accounts.
Management of user passwords.
Management of user groups.

First. Linux system user account creation, deletion and modification management

The management of user accounts mainly involves the addition, modification and deletion of user accounts. Adding a user account is to create a new account in the system, and then assign resources such as user number, user group, home directory, and login Shell to the new account.


1. Add Linux users

Syntax format: useradd option username


# useradd –d /home/ftp -m ftp

This command creates an ftp user, where the -d and -m options are used to generate a home directory /home/sft for the login name ftp (/home is the parent directory where the default user home directory is located).

2. Delete the linux account

If a Linux account is not in use, we need to delete the user directly from the system. When deleting a user, we also need to delete the user's home directory.


Syntax format: userdel [parameter] [user name]


You only need to remember this one command:

# userdel -rf ftp

This command is to forcibly delete the user ftp user and the ftp user's home directory /home/ftp.

3. Modify linux user

After creating a Linux user, we can adjust the attributes of the Linux user's permissions, user number, home directory, user group, and login shell again according to actual work needs.

Syntax format: usermod [parameter]


# usermod -s /bin/ksh -d /home/ftp1 -g sftp ftp

This command changes the login Shell of user ftp to ksh, the home directory to /home/sftp1, and the user group to sftp.

4. User password management

In Linux, the newly created user has no password, so it will be locked by the system and cannot be used directly. To use it, we must create a password for it. It should be noted that even if you want to specify a blank password for the user, you must specify it first. To put it bluntly, you must use the passwd command to execute it again.


Common format: passwd [parameter]


For super users, they can specify passwords for themselves and other users, and ordinary users can only use it to modify their own passwords.

#passwd

Old password:******

New password:*******

Re-enter new password:*******

If you are a super user, you can specify any user's password in the following form:

# passwd ftp

New password:*******

Re-enter new password:*******

When an ordinary user changes his password, the passwd command will first ask for the original password, and then ask the user to enter the new password twice after verification. If the two passwords are the same, the password will be assigned to the user; and the super user will assign the password to the user. When, you don’t need to know the original password.

Second, Linux system user group management

Each user has a user group, so that the system can centrally manage all users in a user group. Different Linux systems have different rules on user groups. For example, a user under Linux belongs to a user group with the same name as it, and this user group is created at the same time as the user is created.


1. Add a new user group

Syntax format: groupadd [parameter]


Use the groupadd command. The format is as follows:

# groupadd group

This command adds a new group group to the system. The group identification number of the new group is added to the largest group identification number currently available.

2. Delete an existing user group

Syntax format: groupdel [parameter] [group name]


# groupdel group

This command deletes the group group from the system.

3. Modify the attributes of the user group

Syntax format: groupmod [parameter]


# groupmod -g 102 group

This command changes the group identification number of group2 to 102.


As we said before, everything in the Linux system is a file. Adding a user account means adding a record for the new user in the /etc/passwd file, and at the same time updating other system files such as /etc/shadow, /etc/group, etc. The management of user groups involves the addition, deletion and modification of user groups. The addition, deletion and modification of groups are actually updates to the /etc/group file. We can also modify the relevant documents directly to achieve the same effect.
Related Article

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.