2.2 Given a scenario, manage users and groups Flashcards
What are the commands used for creating users?
- useradd
- groupadd
Describe how to use the useradd command
The useradd command is used by the root user to create a user account
useradd julia
Describe how to add a user to a group
The groupadd command is used by the root user to create a group account
groupadd -g 2050 test
The -g option is used to specify the GID for the new group
What are the main commands designed to modify user and group accounts?
- usermod
- groupmod
- passwd
- chage
How do you use the usermod command?
The usermod command is used by the root user to modify a user account
[root@OCS ~]$ usermod -s /bin/tcsh julia
What is the groupmod command used for?
The groupmod command is used by the root user to modify a group account
[root@OCS ~]$ groupmod -n proj test
Here are some important options for groupmod command:
- g change the GID
- n Change the group name
What is the command that allows a user to change their password?
The passwd command allows a user to change their password. The root user can also use this command to change any user password or change other password based features for a user account.
-d
Delete the user’s password.
-e
Expire the user account immediately.
-l
Lock the account.
-u
Unlock the account.
-m
Change the Min field of the /etc/shadow file for the user.
-M
Change the Max field of the /etc/shadow file for the user.
-w
Change the Warn field of the /etc/shadow file for the user.
What is the command used to modify password aging features for a user?
The chage command is executed by the root user to modify password-aging features for a user account. Here are some important options for the chage command
What are the commands used to delete users and groups?
The commands used to delete users and groups are
- userdel
- groupdel
How do you delete a user?
The userdel command is used by the root user to delete a user account
[root@OCS ~]$ userdel susan
An important option for the userdel command is the -r option, which deletes the user account as well as the user’s home directory and mail spool
What is the command used to delete a group?
The groupdel command is used by the root user to delete a group account
[root@OCS ~]$ groupdel test
mportant Note
Be sure to remove all files owned by the group before running this command (or reassign the files to another group).
What does the query id do?
The id command will display basic account information. When run with no arguments, it displays the current user’s UID, username, primary GID and name, as well as all secondary group memberships:
[root@OCS ~]$ id
uid=0(root) gid=0(root) groups=0(root)
You can pass a name as a parameter:
id zackbunch
What does the whoami command do?
The whoami command displays the effective user ID
What is the command to see WHO is currently logged in?
The who command shows who is currently logged in
The output of the who command includes the username, the terminal device the user is using, the login date and time, and where the user logged in from (:0 means a local login)
[root@OCS ~]# who
student :0 2017-02-18 01:52 (:0)
student pts/0 2017-02-18 01:52 (:0)
student pts/1 2017-03-05 19:55 (:0)
student pts/2 2017-03-06 18:24 (:0)
root pts/3 2017-03-06 18:24 (localhost)
What is the w command used for?
The w command displays who is logged in as well as other useful information:
[root@OCS ~]# w
18:25:08 up 3 days, 1:24, 5 users, load average: 0.27, 0.08, 0.07
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
student :0 :0 18Feb17 41:48 1.01s gdm-session-wor
student pts/0 :0 18Feb17 4.00s 0.46s 20.33s /usr/libexec/gn
student pts/1 :0 Sun19 1:32 0.04s 0.00s less -s
student pts/2 :0 18:24 12.00s 0.05s 0.01s /usr/bin/sss_ss
root pts/3 localhost 18:24 12.00s 0.03s 0.03s -bash