Creating and removing users
The useradd and adduser commands, passwd, usermod with -aG, -s and -L, userdel with -r, groupadd and groupdel, the /etc/skel template and the home directory.
- 24 cards
- 4 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- Scenarios
A few cards from the deck
useradd: what is it?
Show the answer
The command that creates an account according to its options: -m creates the home directory, -s sets the shell, -G adds secondary groups.
The created account has no password yet: it stays locked until one is set. On Debian, adduser is a more interactive script that does all this and sets the password.
Lea is in the secondary groups sudo and dev. You type
usermod -G docker lea. What becomes of her list of secondary groups?- docker alone: sudo and dev are removed
- docker is added to sudo and dev
- Nothing: without -a, the command is refused
- docker replaces only dev, the last group
Show the answer
docker alone: sudo and dev are removed
-G gives the complete list of secondary groups. Lea loses sudo, hence her administration rights: the fix is usermod -aG sudo,dev,docker lea.
With useradd, the … option creates the home directory, … chooses the shell and … adds secondary groups.
Show the answer
With useradd, the -m option creates the home directory, -s chooses the shell and -G adds secondary groups.
useradd -m -s /bin/bash -G dev lea creates the lea account with its directory, bash as shell and dev as secondary group.
passwd: what is it?
Show the answer
The command that sets or changes an account's password; with no name, the current user's.
It writes the hash into /etc/shadow, never the password in clear. Only root can change another account's.
userdel leaanswers "userdel: user lea is currently used by process 4123". What should you do?- Add -r: that option stops the account's processes
- Terminate lea's processes, for example with pkill -u lea, then run userdel again
- Delete her primary group first with groupdel, which frees the account
- Edit /etc/passwd by hand to remove lea's line
Show the answer
Terminate lea's processes, for example with pkill -u lea, then run userdel again
userdel refuses to delete an account whose processes are still running. -r only concerns the home directory. Removing the line by hand would leave leftovers in shadow and group.