Create a new user with useradd under debian

1. Use sudo:

sudo useradd -m user1 -g sudo -s /bin/bash -d /home/user1
sudo passwd user1

2. Directly under the root user:

groupadd user1
useradd -m user1 -g user1 -s /bin/bash -d /home/user1
passwd user1
The meanings of the parameters of the useradd command are as follows, for reference:
-c <remarks>: add remarks. The remark text will be saved in the remark field of passwd;
-d<login directory>: specify the starting directory when the user logs in; -D: change the default value;
-e<valid period>: specify the validity period of the account;
- f<buffer days>: specify how many days after the password expires to close the account;
-g<group>: specify the group to which the user belongs;
-G<group>: specify the additional group to which the user belongs;
-m: Automatically create a user's login directory;
-M: Do not automatically create a user's login directory;
-n: Cancel the creation of a group named after the user's name;
-r: Create a system account;
-s: Specify the shell used by the user after login ;
-u: Specifies the user id.

At this point, the user is added successfully. If you need to allow this user to have root privileges, execute the command:

vim /etc/sudoers
modify the file as follows:

# User privilege specification
root ALL=(ALL) ALL
user1 ALL=(ALL) ALL
save and exit, user1 has root privilege.

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324139521&siteId=291194637