The Linux user and group management (fundamental)

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Users and groups is an important part of Linux, so learning Linux must also learn the knowledge that one, at least must learn how to use the most basic commands, below I to share my this piece of learning outcomes

1 create user group

Create a group of users is relatively simple, Only need to use the command sudo groupadd sudo groupadd -g ID name or group name, The first command is very simple and not much to say, For the second command we need to know the user group in Linux exists mainly in a configuration file, This configuration file location is /etc/group, use the VI view to see the user group system which created


User group configuration file contents as follows


This figure we should also know that only ID as 117, 118, 119, 700, 1006 these figures represent user group, so for the second command is not difficult to understand if the parameter is not -g and later, Linux will give us to assign a user group ID

The 2 group of users modify operation

In some cases we may have to modify the user group, the main is to modify the ID users group and modified group name 2 operations, modify user group name sudo groupmod -n command is the new name of old name, as shown below

If the change of user group ID can use the sudo groupmod -g group ID group name

The modified profile is shown as follows


Create and modify 3 users

A user creation is the basis of comparison, create user has 2 command, the first is the sudo useradd user name; second is to assign the sudo useradd -g username. I recommend the use of the latter, the first command he not only created a new user created a user name and the same group

This command creates a Xiaofei user and added to the administrator group., Here we must also know that Linux also put the user in a configuration file., The file position is /etc/passwd. only create user and not to the user password, Linux is a user not allowed to log on this system., Below then to set the password to the user, The command is the sudo passwd user name

The next is to delete user group, delete the group command is sudo groupdel group name; delete user command is sudo userdel username, delete user default does not delete the user directory, if you want to delete the user's home directory. You should use the sudo userdel -r user name

Set delete I will not screenshots


There are several operations, are said to modify user operation, modify the user name to use the command sudo usermod -l new old user name user name, as shown below

There is a not very much to modify the user command sudo usermod -c note or notes user name, this command means for the user to add a comment or description

There is a final operation is also very important, it is for the user to specify a operational command is the sudo usermod directory, -d path name

The operation of the user base so much


3.linux restrict certain user login system

Sometimes in order to troubleshooting may need to temporarily restrict certain user login system, Linux also can achieve such restrictions, The premise is that we understand the Linux user password in the configuration file., This is a simple user password configuration file where the path is /etc/shadow, then we just need to find the user password in the password to open the VI editor in front with a can!, Modify this file requires administrator privileges, because we modify the file is read-only, So it should be forced to write, Behind WQ and the last exclamation mark can


The MD5 password is encrypted, the user name: position is behind, as shown above in the third line from the bottom, to have a look xiaofeifei the user can login

4 no other but the root user login

The operation is simple, create a nologin in the etc directory folder can, the command is the sudo MKDIR /etc/nologin

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Vivian at December 24, 2013 - 9:31 AM