Linux users can be added with different ways. but one of the most used way is adding them throughout the shell because Linux admins loves shell usage. In this tutorial we will look how to add user into a Ubuntu, Kali, Mint, Debian box and provide or change required parameters. We will also look user deletion.
可以使用不同的方式添加Linux用户。 但是最常用的方法之一是在整个shell中添加它们,因为Linux管理员喜欢使用shell。 在本教程中,我们将研究如何将用户添加到Ubuntu,Kali,Mint,Debian框中以及提供或更改所需的参数。 我们还将查找用户删除。
根特权 (Root Privileges)
In order to add or remove user from a Linux box we need root privileges. We can get root privileges with different ways. We can login to root account like below.
为了在Linux系统中添加或删除用户,我们需要root权限。 我们可以通过不同的方式获得root特权。 我们可以如下登录到root帐户。
$ su -
OR we can use sudo
command which operates given command with the current user but with root privileges.
或者我们可以使用sudo
命令,该命令以当前用户但具有root特权的方式操作给定命令。
$ sudo ls
使用adduser添加用户 (Add User with adduser)
We can use adduser
command in order to add user. We will add user named poftut
. This command will ask user detailes step by step. At the end of the process we will accept adding given user with Yes\no
question.
我们可以使用adduser
命令来添加用户。 我们将添加名为poftut
用户。 该命令将逐步询问用户详细信息。 在该过程结束时,我们将接受使用“ Yes\no
问题添加给定用户。
$ sudo adduser poftut
使用useradd添加用户(Add User with useradd)
useradd
is the fastest way to add user. useradd
will not look for any user detail. Just add user to the Linux box. But it will not configure any password for the given user so we should set recently added user password with passwd
like below. In this test we will add user named test1
and change its password.
useradd
是添加用户最快的方法。 useradd
将不查找任何用户详细信息。 只需将用户添加到Linux框中即可。 但是它不会为给定的用户配置任何密码,因此我们应该使用passwd
设置最近添加的用户密码,如下所示。 在此测试中,我们将添加名为test1
用户并更改其密码。
$ sudo useradd test2
$ sudo passwd test2
删除用户(Delete User)
We can easily delete existing user with userdel
command. In the following example we will delete user named test1
. We need root privileges again.
我们可以使用userdel
命令轻松删除现有用户。 在下面的示例中,我们将删除名为test1
用户。 我们再次需要root特权。
$ sudo userdel test2