Adding, Deleting, and Modifying User Groups Flashcards
What is our go-to command for manipulating users?
useradd
What does the useradd
command do?
It adds a new user.
What is the synopsis of the useradd
command when we man
it?
useradd [OPTIONS] LOGIN
What do we need in order to add a user using the useradd
command?
We need to have administrator rights.
What is the most basic real-world example of using the useradd
command, and what do we get asked for when we execute it?
sudo useradd jdoe
2. Our password.
What flag do we use with useradd
to specify a comment?
The -c
flag.
What do most distros store in the comment for a given user?
The full name of the user.
What is the most basic real-world example of creating a user and give them a comment using the useradd
command?
sudo useradd -c "Jane Smith" jsmith
How do you set an expiration date for a user when creating it with the useradd
command?
By using the -e
flag.
eg.
~~~
sudo useradd -e 2019/12/31 jsmith
~~~
What is the format accepted by the -e
flag when using the useradd
command?
YYYY/MM/DD
eg. 2019/12/31
How do you set the default shell for a user when creating it with the useradd
command?
By using the -s
flag and giving it the path to the binary for that particular shell.
eg.
~~~
sudo useradd -s /bin/zsh jsmith
~~~
What is the path to the default home directory for a given user?
/home/[username]
eg.
If the username is “jsmith”, the home directory would be home/jsmith
.
How do we specify a non-default home directory for a given user when creating it using the useradd
command?
By using the -d
flag.
eg.
~~~
sudo useradd -d /home/johnsmith jsmith
~~~
When we’re using the useradd
command to create a new user with a non-default home directory, what is the secondary step that we must undertake and why?
- We must create the folder that we specified as the user’s home directory.
- Because unlike using the default home directory, when we specify a custom home directory for a user when creating one with the
useradd
command, the home directory we specified will not be created.
How do you print the ID of a user on the terminal?
By using the id
command and giving it the username that we want to get the ID for.
eg.
~~~
sudo id sarah
~~~