Adding, Deleting, and Modifying User Groups Flashcards

1
Q

What is our go-to command for manipulating users?

A

useradd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the useradd command do?

A

It adds a new user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the synopsis of the useradd command when we man it?

A

useradd [OPTIONS] LOGIN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What do we need in order to add a user using the useradd command?

A

We need to have administrator rights.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the most basic real-world example of using the useradd command, and what do we get asked for when we execute it?

A
  1. sudo useradd jdoe

2. Our password.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What flag do we use with useradd to specify a comment?

A

The -c flag.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do most distros store in the comment for a given user?

A

The full name of the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the most basic real-world example of creating a user and give them a comment using the useradd command?

A

sudo useradd -c "Jane Smith" jsmith

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you set an expiration date for a user when creating it with the useradd command?

A

By using the -e flag.

eg.
~~~
sudo useradd -e 2019/12/31 jsmith
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the format accepted by the -e flag when using the useradd command?

A

YYYY/MM/DD

eg. 2019/12/31

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you set the default shell for a user when creating it with the useradd command?

A

By using the -s flag and giving it the path to the binary for that particular shell.

eg.
~~~
sudo useradd -s /bin/zsh jsmith
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the path to the default home directory for a given user?

A

/home/[username]

eg.
If the username is “jsmith”, the home directory would be home/jsmith.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do we specify a non-default home directory for a given user when creating it using the useradd command?

A

By using the -d flag.

eg.
~~~
sudo useradd -d /home/johnsmith jsmith
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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?

A
  1. We must create the folder that we specified as the user’s home directory.
  2. 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you print the ID of a user on the terminal?

A

By using the id command and giving it the username that we want to get the ID for.

eg.
~~~
sudo id sarah
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you delete a user using the terminal?

A

By using the userdel command and giving it the username of the user we’d like to delete.

eg.
~~~
sudo userdel sarah
~~~

17
Q

How do you specify that the home directory of the given user should be deleted when using the userdel command?

A

By using the -r flag.

eg.
~~~
sudo userdel -r sarah
~~~

18
Q

What does the usermod command do?

A

It modifies a user account.

19
Q

How do you modify a user account?

A

By using the usermod command.

eg.
~~~
sudo usermod -c “Not Sarah” sarah
~~~

20
Q

How do you change the username of an account using the usermod command?

A

By using the -l flag.

eg.

sudo usermod -l sjones sarah
~~~
…will change the username from sarah to sjones.
~~~

21
Q

What is the default password for users that are added using the useradd command, and what does this mean?

A
  1. Nothing. There is no default password for the users created by the useradd command.
  2. User accounts without passwords will NOT function. They simply won’t work until we attach a password to them.
22
Q

How can you attach a password to a user that was created by the useradd command?

A

By using the passwd command.

eg.

sudo passwd sjones
~~~
…will prompt us for a new password for the user sjones
~~~

23
Q

How do you set an expiration date for a user’s password?

eg. so that they have to change it before a certain date after they’ve started to use their account.

A

By using the chage command.

24
Q

What does the chage command do?

A

It changes the number of days between password changes and the date of the last password change. This information is used by the system to determine whether a user must change his/her password.

25
Q

How do you display information about the password changes of a user?

A

By using the chage command and the -l flag.

eg.
~~~
sudo chage -l sjones
~~~

26
Q

How do you browse the default values that are used by the useradd command when adding a new user?

A

By using the -D command.

eg.
~~~
sudo useradd -D
~~~

27
Q

What is a skeleton directory?

A

It is an important directory that is inside /etc. Whenever a new user is created, a new copy of the skeleton folder is created and put into the home directory of that new user.

28
Q

How do you explicitly specify a home directory to be created for the new user when using the useradd command?

A

By using the -m flag.

eg.
~~~
sudo useradd sjones -m
~~~

29
Q

How do you specify the skeleton directory when adding a new user using the useradd command, and what is the requirement to be able to do this?

A
  1. By using the -k flag.

eg.
~~~
sudo useradd sjones -k /etc/skel
~~~

  1. The requirement is that we also need to create a new homefolder for the given user. This can be achieved in Ubuntu by using the -m flag.

eg.
~~~
sudo useradd sjones -k /etc/skel -m
~~~