Managing Users and Groups Flashcards
Content of /etc/passwd
user_name:password:uid:gid:comment:full_path_to_home_dir:/shell
root:x:0:0:root:/root:/bin/bash
Content of /etc/shadow
user_name:encr_passd:days password_changed_since_01.01.1970:min_days_between_passwd_changes:max_days_passwd_valid:warning_days_expiration_of_passwd:days_to_lock_account_when_passwd_is_expired:date_days_since_01.01.01_account_will_expire root:$1$***$...:17618:0:99999:7:: dbus:!!:17618:::::: $1$=MD5 $2$,$2y$=Blowfish $5$=sha-256 $6$=sha-512 $***-salt $...-hashed passed !-account is locked *-account is locked and passed was never set
Add user
useradd -m [home dir] -c[comment] “Adam Vance” -u [uid] 1002 -g[gid] 25 -G wheel -s [shell] /bin/tcsh
Set password to a user
Set a password for yourself
passwd avance
passwd without any params
Force expiration of password and make a user to set up a new password after the login
passwd -e avance
chage -d 0 avance
Remove user’s account keeping home folder
The same and remove user’s home folder
userdel avance
userdel -r avance
Create system account
useradd -r my_service -s /sbin/nologin
Check groups current user belongs to
Check groups a user belongs to
groups
groups avance
Create new group
Delete a group
groupadd [-g[gid] 501] my_group
groupdel my_group
Conf file with default settings set by useradd command
/etc/default/useradd common settings: GROUP=100 HOME=/home SHELL=/bin/bash SKEL= EXPIRE=date the account will expire INACTIVE=-1 (account will not be disabled when password is expired) if =0- disable account when passwd expired
Query db content of specified group id
getent group 100
Conf file that changes the behaviour of /etc/default/useradd file
and should be used by admins to set up vars
/etc/login.defs GID_MIN=1000 this will override min value of GROUP var UID_MIN=1000-this will setup starting uid
Modify a user account
usermod
usermod -a -G finance avance -append avance to suppl group finance
usermod -d /opt/projectx my_project -change home dir from /home/my_project
usermod -e 1 - accoutn will expire in 1 day
usermod -l -change user_login name from to new
usermod -p -passwd
usermod -u -uid
usermod -L- lock user’s password
usermod -U - unlock account
Modify a group
groupmod
groupmod -g 1002 engineering
groupmod -n Engineers engineering
File to create for displaying a message, when a user has /sbin/nologin as shell
/etc/nologin