Ubuntu에서 사용자 계정을 추가하거나 삭제하는 것은 시스템 관리의 기본이 되는 중요한 부분이다. 새로운 사용자를 추가하면 다른 사용자와 리소스를 공유하고, 보안 및 권한 관리를 용이하게 할 수 있다. 이 글에서는 Ubuntu에서 사용자 계정을 추가하고 삭제하는 방법에 대해 알아본다.
사용자 계정 추가
새로운 사용자 계정을 추가하는 명령어는 adduser 와 useradd가 있다.
adduser
adduser를 사용하면, group추가와 user추가, 홈 디렉토리 생성, 비밀번호 설정 등 모든 과정이 한번에 진행된다.
사용방법은 다음과 같다.
sudo adduser <userid>
아래는 “john” 사용자 계정을 추가하는 과정이다. “/home/john” 홈 디렉토리가 생성되고, 계정 비밀번호를 설정하고, john 계정에 대한 group을 생성하고 users 그룹에도 추가된다.

/home 디렉토리를 리스팅 해보면 john 디렉토리가 추가된 것을 확인할 수 있다.

useradd
useradd 명령어는 계정만 생성이 되고, 비밀번호 설정이나 홈 디렉토리 등 기타 부가적인 부분들은 따로 만들어 줘야 한다.
계정 생성
먼저 아래와 같이 useradd 명령어를 사용하여 계정을 생성한다.
sudo useradd <userid>
비밀번호 설정
계정을 생성했으면 아래와 같이 passwd 명령어로 비밀번호를 설정한다.
sudo passwd <userid>

홈 디렉토리 생성
mkdir 명령어로 홈 디렉토리를 생성해 준다.
sudo mkdir -p /home/<userid>

홈 디렉토리 권한 부여
sudo 로 디렉토리를 생성했기 때문에 권한이 root로 되어 있다. chown 명령을 사용하여 사용자 계정으로 권한을 바꿔준다.
sudo chown -R <userid>:<userid> /home/<userid>

그룹 지정
usermod명령을 사용하여 계정을 users 그룹에 추가해 준다.
sudo usermod -G users <userid>

기본 쉘 지정
계정이 사용할 기본 쉘을 bash로 설정한다.
sudo usermod -s /bin/bash <userid>

계정 로그인
su 명령어로 새로 생성한 계정으로 로그인을 해본다.
su - <userid>

사용자 계정 삭제
계정 삭제 역시 deluser와 userdel 두 가지 명령어가 있다.
deluser
deluser는 --remove-all-files 옵션을 주면 사용자 계정의 모든 파일을 삭제해 준다.
sudo deluser --remove-all-files <userid>
사용법은 다음과 같다.
userdel
userdel 명령어는 -r 옵션을 붙이면 홈 디렉토리와 메일을 삭제해 준다.
sudo userdel -r <userid>
사용 방법은 다음과 같다.

What’s up colleagues, how is the whole thing, and what you wish for to say concerning this
piece of writing, in my view its actually remarkable for me.
Wow! Finally I got a webpage from where I know how to really take helpful facts concerning
my study and knowledge.
I blog often and I genuinely thank you for your information. This
article has really peaked my interest. I’m going to
take a note of your site and keep checking for new information about once per week.
I opted in for your RSS feed as well.
You’ve made your point.
You actually stated it fantastically.
You reported that terrifically!
Really quite a lot of excellent info.
Awesome data, Thank you.
Superb information, Thank you!
With thanks! I value this!