Raspberry Pi_Eng_12.4.3 “adduser” Command – Create User


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


12.4.3  "adduser" Command Create User

 

You can use "adduser" and "useradd" commands to create user accounts. The "adduser" command makes it easy to create user accounts. The "useradd" command can handle relatively detailed processing with very low-level commands, but it is complex to use and generally not used for general purposes.

 

Generally, if you want to create a user account, use the "adduser" command. Using this command, you can create user account and specify user groups of the user at the same time.

 

[Command Format]

adduser [options] LOGIN

 

[Command Overview]

   This creates a new user account.

   User privilege          -- Super user.

 

[Detail Description]

   The "adduser" command adds new user to the system according to the settings specified in the Shell option and "/etc/adduser.conf" file. You can also create a home directory or run a script according to the specified options.

   You can specify all the parameters required for execution, and some items can be processed interactively.

   If you do not specify a special option for home directory creation, the default directory is automatically created. The default directory is "/Home/UserID".

 

[Main Option]

--disabled-login

Do not run passwd to set the password. The user won't be able to use her account until the password is set.

--disabled-password

 

Like --disabled-login, but logins are still possible (for example using SSH RSA keys) but not using password authentication.

--group

When combined with --system, a group with the same name and ID as the system user is created. If not combined with --system, a group with the given name is created. This is the default action if the program is invoked as addgroup.

--home DIR

Use DIR as the user's home directory, rather than the default specified by the configuration file.  If the directory does not exist, it is created and skeleton files are copied.

--shell SHELL

Use SHELL as the user's login shell, rather than the default specified by the configuration file.

--system

Create a system user or group

 

[Used Example]

To create a new user account "guser001", do the following work.

 

pi@raspberrypi ~ $ sudo adduser guser001

Adding user `guser001' ...

Adding new group `guser001' (1004) ...

Adding new user `guser001' (1001) with group `guser001' ...

Creating home directory `/home/guser001' ...

Copying files from `/etc/skel' ...

Enter new UNIX password:

Retype new UNIX password:

passwd: password updated successfully

Changing the user information for guser001

Enter the new value, or press ENTER for the default

        Full Name []: general user 001

        Room Number []:

        Work Phone []:

        Home Phone []:

        Other []:

Is the information correct? [Y/n] Y

 

If you check the contents of "/etc/passwd" on your system, you will see that the following content for each newly created user account has been added at the bottom.

 

pi@raspberrypi ~ $ sudo cat /etc/passwd

root:x:0:0:root:/root:/bin/bash

daemon:x:1:1:daemon:/usr/sbin:/bin/sh

~

guser001:x:1001:1004:general user 001,,,:/home/guser001:/bin/bash

 

If you check the contents of "/etc/group" on the system, you can see that a new group "guser001" is newly created.

 

pi@raspberrypi ~ $ sudo cat /etc/group

root:x:0:

daemon:x:1:

~~~~~

guser001:x:1004:

 

After creating a new user account, if you logon to the window and run the [File Manager] program, you can see that the folder is created as below. It can be seen that a folder named "/home/guser001" is created and the folder is designated as the default folder of the user "guser001".

 


Figure 12‑4 User home directory