How do I create a new user using the Linux command line?
I'm doing it under Ubuntu, for example by adding a new user named Test:
The simplest of commands:
sudo adduser test
The user is automatically added to the group with the same name, the/home/test/is created, the file is copied from the etc/skel/, and the password and associated initial identity information is set.
command of the original point:
sudo useradd-mk/home/test-s/bin/bash test
sudo passwd test
(This is useradd and not adduser)
Give the user root access
Modify the/etc/sudoers file, locate the following line, and add a line below root as follows:
# allow ROOT to run any commands anywhere
Root all= (All) all
Test all= (All) all
Finally, if you want to delete a user:
To delete a user:
sudo userdel test
Rm-rf/home/test
To switch users at the command line:
You can use the SU command to switch users, and SU is the abbreviation for switch User Switching users. It can be switched from a normal user to a root user, or from a root user to a normal user. Switch from normal user to root user needs to enter a password, switch from root user to normal user does not need to enter password.
Command format: su [parameter] [-] [user name]
The default value for the user name is root.
Usage examples:
Su Test #切换到test用户
Su #切换到root用户
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Create user commands under Linux