사용자 추가
$ sudo adduser john
Adding user `john' ...
Adding new group `john' (1001) ...
Adding new user `john' (1001) with group `john' ...
Creating home directory `/home/john' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for john
Enter the new value, or press ENTER for the default
Full Name []: john kim
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
$ cat /etc/passwd
...
john:x:1001:1001:john kim,,,:/home/john:/bin/bash
사용자 변경
$ su john
Password:
john@ip-172-31-12-100:/home/ubuntu$
사용자 삭제
$ sudo deluser john --remove-home
Looking for files to backup/remove ...
Removing files ...
Removing user `john' ...
Warning: group `john' has no more members.
Done.
$ cat /etc/passwd
실습
- Group : animals, fruits
- animals : dog, pig
- fruits : apple, banana
~$ sudo addgroup animals
Adding group `animals' (GID 1001) ...
Done.
$ sudo addgroup fruits
Adding group `fruits' (GID 1002) ...
Done.
$ sudo adduser pig --ingroup animals
Adding user `pig' ...
Adding new user `pig' (1001) with group `animals' ...
Creating home directory `/home/pig' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for pig
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
$ sudo adduser dog --ingroup animals
Adding user `dog' ...
Adding new user `dog' (1002) with group `animals' ...
Creating home directory `/home/dog' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for dog
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
$ sudo adduser apple --ingroup fruits
Adding user `apple' ...
Adding new user `apple' (1003) with group `fruits' ...
Creating home directory `/home/apple' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for apple
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
$ sudo adduser banana --ingroup fruits
Adding user `banana' ...
Adding new user `banana' (1004) with group `fruits' ...
Creating home directory `/home/banana' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for banana
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
$ cat /etc/passwd
pig:x:1001:1001:,,,:/home/pig:/bin/bash
dog:x:1002:1001:,,,:/home/dog:/bin/bash
apple:x:1003:1002:,,,:/home/apple:/bin/bash
banana:x:1004:1002:,,,:/home/banana:/bin/bash