midterm Flashcards
Which directory is passwd in?
What kinds of information does the passwd file store?
/etc/passwd
Store stuff like:
username, password (x if it’s encrypted), UID, GID, location of home directory, location of login shell
Where is encrypted password stored?
/etc/shadow
Is it possible to read /etc/passwd file as a regular user?
Yes
What type of info does /etc/shadow have?
- username
- encrypted password
- last password change
- min/max password age
- warning period
- inactivity period
- expiration date
How to add a new user?
useradd
useradd [options] username
Where is default configuration for useradd?
/etc/default/useradd
how to delete a user?
userdel
userdel -r username (if you want to remove their home directory too)
userdel [options] username
Why might you not be able to delete a user?
User still have running processes. Kill processes under a user by:
pkill -u username
or you can forcefully delete user with:
userdel -fr username
How to ser password for a new user?
passwd username
Will prompt you to enter password twice. Nothing will be showed on the screen though
How to lock and unlock a user account?
sudo passwd -l username (for lock)
sudo passwd -u username (for unlock)
how to view groups a member is in?
groups username
how to create a new group?
groupadd
groupadd [options] group-name
which folder has info about groups on your system?
/etc/group
what does the sudo command do?
allows a user to temporarily perform tasks with elevated privileges
where are the configurations for sudo?
/etc/sudo.conf
where are the configurations for who can use sudo?
/etc/sudoers
a sudoers file will generally include a line that grants members of their the “sudo” group or “wheel” group sudo privileges. eg. %wheel ALL+(ALL) ALL
what directory contains individual configuration files?
/etc/sudoers.d/
Why do we have sudo command? why not use root for everything/
Always want to give least privileges as possible so they can’t do what they shouldn’t do.
Accountability
Security. There’s add security for what hackers have to guess.
who to add user to a group?
sudo usermod -aG group user
the “a” is for append. Will not overwrite other groups the user is in.
What are the permissions?
r = read
w = write
x = execute
- = placeholder for permissions user does not have
format of what permissions looks like?
d rwx rw- r–
d = directory (file type)
then user permission
then group
then other
What are the octal/numeric permissions?
4 = read
2 = write
1 = execute
eg.
chmod 644 filename
(still in user, group, other order)
how to change file ownership?
chown
chown [options] user:group file
how to set password expiry?
sudo usermod -e YYY-MM-DD user