Managing users & Groups Flashcards
What command do we use to create a user account?
useradd
- c Full Name
- e Expiration date
- s Default shell
- d Home directory
useradd jdoe -c “John Doe” -e 2019/12/31 -s /bin/dash -d /home/john_doe
What is userdel command in Linux?
Stands for: User delete
Function: Delete a user account and related files
What command and option is for completely deleting a user?
userdel -r
What command modifies a user account?
usermod
- Rename account: usermod -l jdoe jsmith
- Lock account: usermod -L jdoe
- Unlock account: usermod -U jdoe
- Add user to group: usermod -a -G Marketing
What command changes the login shell of username?
chsh
- Prevent an account from logging in interactively
- e.g. chsh -s /bin/nologin
What is the command to set or change a user password?
passwd
How do you set an expiration for a user account password?
*chage
Define password expiration policy
How do you display current password info for a user?
*Display current info
chage -l jdoe
How do you modify a password policy for a user?
*Modify policy
chage -m -M -E -W jdoe
How do you display defaults of a user account?
useradd -D (displays defaults)
List of defaults
/etc/login.defs
/etc/default/useradd
/etc/skel
How can we verify a user account’s configuration?
*/etc/passwd (account info) Defines accounts User ID UIDs typically start at 500 Users/Groups can share an ID (not ideal) */etc/shadow (password file) */etc/group (group association)
What command do we use to create groups?
*groupadd
groupadd Marketing
*/etc/group list of groups
Are we able to modify the group once it is created?
YES
*groupdel (deletes group)
*groupmod (modifies)
(-n Rename group)
groupmod -n
How do we put user accounts into the groups?
gpasswd
*Add a user
gpasswd -a
*Remove a user
gpasswd -d
*Add a group admin
gpasswd -A
Are secondary group permissions applied automatically?
NO
Users perform all actions under their primary group by default
What does the newgrp command do?
The newgrp command is used to change the current group ID during a login session.
What does the chgrp command do?
The chgrp (change group) command alters the group name that a file or directory belongs to.
What does the groups command do?
The groups command lists the groups that a user belongs to.
groups
Are there any other ways to verify a group’s configuration?
getent passwd (looks into etc/passwd and looks for user info)
getent shadow (looks into etc/passwd and looks for user password)
getent group (looks into etc/passwd and looks for user group) groups (lists all groups that user is part of)