Raspberry Pi_Kor_12.4.3 “adduser” 명령 – 사용자 생성


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" 명령 - 사용자 생성

 

사용자 계정을 생성하는 데는 "adduser" 명령과 "useradd" 명령을 사용할 수 있다. "adduser" 명령은 간편하게 사용자 계정을 생성할 수 있다. "useradd" 명령은 매우 low-level의 명령으로 상대적으로 세부적인 처리를 할 수는 있지만, 사용하는 것이 복잡하여 일반적인 목적으로는 잘 사용되지 않는다.

 

일반적으로 사용자 계정을 생성하고자 하면 "adduser" 명령을 사용한다. 이 명령을 사용하면 사용자 계정을 생성하면서 동시에 사용자 그룹을 함께 지정할 수 있다

 

[명령 형식]

adduser [options] LOGIN

 

[명령 개요]

    새로운 사용자 계정을 생성한다.

    user 권한    -- super user. 

 

[상세 설명]

    "adduser" 명령은 Shell option"/etc/adduser.conf" 파일에서 지정된 설정 내용에 따라 시스템에 새로운 사용자를 추가한다. 지정된 option에 따라서 home directory를 생성하거나 script를 실행할 수도 있다.  

    실행에 필요한 모든 parameter를 직접 지정할 수도 있고, 일부 항목에 대해서는 대화식으로 입력하면서 처리할 수도 있다.

    Home Directory 생성에 대한 특별한 option을 지정하지 않아도 기본 directory가 자동으로 생성된다. 기본 directory"/Home/UserID" 이다

    

[주요 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

 

[사용 Example]

새로운 사용자 계정 "guser001"를 생성하기 위해서 다음과 같은 작업을 실행한다.

 

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

 

시스템의 "/etc/passwd"의 내용을 확인해 보면 새로이 생성되는 각각의 사용자 계정에 대해서 맨 아래에 아래와 같은 내용이 추가되어 있음을 확인할 수 있다.

 

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

 


 

시스템의 "/etc/group"의 내용을 확인해 보면 새로운 group "guser001"이 새로이 생성되어 있는 것을 확인할 수 있다.

 

pi@raspberrypi ~ $ sudo cat /etc/group

root:x:0:

daemon:x:1:

~~~~~

guser001:x:1004:

 

새로운 사용자 계정을 생성한 다음 window logon해서 [파일 관리자] 프로그램을 실행해 보면 아래의 화면처럼 폴더가 생성되어 있는 것을 확인할 수 있다. "/home/guser001" 이라는 폴더가 생성되어 있고 그 폴더가 사용자 "guser001"의 기본 폴더로 지정되어 있음을 알 수 있다.


그림 12‑4 사용자 home directory

 


 

Leave a Reply