Managing Users and Groups Flashcards
Add user
useradd -m [home dir] -c[comment] “Adam Vance” -u [uid] 1002 -g[gid] 25 -G wheel -s [shell] /bin/tcsh avance
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
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
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
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- append user to suppl group
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
Change aging params of a user’s account
k=date -d+'15 days' +%Y-%d-%d
chage -E $k avance
chage -E 2020-01-01 avance -set expiration date of account
chage -l user -list account aging info
chage -E -1 avance -set no expiration to account
chage -W 15 avance- change warning period
chage -M 15 avance -change password expiration date from now
chage -d 0 avance - force password to be changed for avance
chage -I 5 avance -account will be inactive after 5 days when the password is expired
Modify a group
groupmod
groupmod -g 1002 engineering
groupmod -n Engineers engineering