Linux: creating and deleting users under Linux

Time:2021-1-20

1、 Create user

To create users under Linux, the following commands are generally used:

sudo useradd -m username

amongsudoIt means to use the administrator’s authority to create a user, because only the administrator can have the authority to add users in his own system. Useradd means to add a user, the – M parameter means to create a new user in the home directory, and the user name means the name we want to create a new usergeeksongsInsteadusernameRepresents the user name we created. After creating a user, we also need to create a password to log in to the new user, so that we can log in to our new user. Otherwise, it will be created in vain. We use the following command to create a password for the new user:

You also need to use administrator permissions:

sudo passwd geeksongs

Then enter our password. The first two steps are as follows:

 

 

In this way, we can check the home directory again, that is, the home directory. We can see that there are two users, one is the Mike user I currently use, and the other is the geeksongs user I just created. We can also log in to another user. If it’s an Ubuntu system, we can directly click theswitch userSwitch users as follows:

 

 

Click to create a new user interface. You can operate it to see what is in the directory of the new user geeksongs;

 

It’s amazing that the new user geeksongs has fewer folders than the original Mike user. At the same time, the geeksongs user has permission to enter another user Mike’s folder!

2、 Delete user

To delete a user, we also use the administrator authority to directly use the command:

sudo userdel geeksongs

That’s right. After using this command, you can check the home directory. Except for the original mile, there are no other users!

Recommended Today

How to Build a Cybersecurity Career

Original text:How to Build a Cybersecurity Career How to build the cause of network security Normative guidelines for building a successful career in the field of information security fromDaniel miesslerstayinformation safetyCreated / updated: December 17, 2019 I’ve been doing itinformation safety(now many people call it network security) it’s been about 20 years, and I’ve spent […]