System administration - jasper-zanjani/dotfiles GitHub Wiki
- adduser
- chage
- chgrp
- chmod
- edquota
- gpasswd
- groupadd
- groupdel
- groupmod
- groups
- last
- lastb
- passwd
- quota
- quotacheck
- quotaoff
- quotaon
- repquota
- su
- sudo
- sudoedit
- timedatectl
- tzconfig
- tzselect
- ulimit
- useradd
- userdel
- usermod
- visudo
- w
- wall
- who
- whoami
adduser
chage
chgrp
chmod
edquota
gpasswd
groupadd
groupdel
groupmod
groups
last
lastb
passwd
quota
quotacheck
quotaoff
quotaon
repquota
shutdown
su
sudo
sudoedit
timedatectl
tzconfig
tzselect
ulimit
useradd
userdel
usermod
visudo
w
wall
who
whoami
Filesystem access control lists (FACL) allow you to grant permissions to more than one group, i.e. in cases where more than one department of a corporation needs access to the same files. They are made up of access control entries (ACE). FACL permissions will be indicated in a ls -l command by the presence of a "+" after the symbolic notation for the traditional UGO permissions. Acl is a dependency of systemd.
To enable it, add ",acl" to options in fstab file, then mount/unmount disk. If enabling FACL on root partition, system has to be rebooted.
Execute a command at a given time
echo "cmd" | at timeExecute cmd at time
at time
> cmdChange ownership of $FILE to $USER and $GROUP
chgrp $USER:$GROUP $FILESet sticky bit on $FILE
chmod +t $FILEClear sticky bit on $FILE
chmod -t fileClear SGID bit on $FILE
chmod g-s fileSet SGID bit on $FILE
chmod g+s fileClear SUID bit on $FILE
chmod u-s fileSet SUID bit on $FILE
chmod u+s fileSet setuid permission on $FILE
chmod +s fileChange a file or directory's ownership. To change the user and group owner of a file to {user} and {group}, chown's syntax is of the format user:group [32].
chown susan:delta file # Assign {file} to user `susan` and group `delta`
chown alan file # Assign {file} to user `alan`
chown alan: file # Assign {file} to user and group `alan`
chown :gamma file # Assign {file} to the group `gamma`Recursively grant {user} ownership to {path}
chown -R user pathAssign {path} to susan and group delta, recursively and with verbose output
chown --verbose --recursive susan:delta path
chown -vR susan:delta pathchown -vR --reference=. path # Use a `reference` file to match the configuration of a particular file
chown -cfR --preserve-root alan # `preserve-root` prevents changes to files in the root directory, but has no effect when not used with `recursive`Change default shell to Fish
chpass -s /usr/local/bin/fishSynchronize system time using NTP (cf. timedatectl
Stop the systemd-timesyncd service
sudo systemctl stop systemd-timesyncd.serviceInstall chrony if it is not already present and enable and start the service
sudo systemctl enable chronyd && sudo systemctl start chronydChange the user's default shell to Bash
chsh-s /bin/bashChange the user's default shell to Fish
chsh-s /usr/local/bin/fishList memory statistics in kilobytes. Without any options, free returns a table listing general statistics in kilobytes:
freeCommand-line memory dashboard
watch free -hGet entries from the passwd file [50]
getent passwd sonny timmysonny:x:1001:1002:Sonny:/home/sonny:/bin/bash
timmy:x:1002:1003::/home/timmy:/bin/bash
getent group sonny timmysonny:x:1002:
timmy:x:1003:
Add $USER to $GROUP
gpasswd -a $USER $GROUPAdd $USER as admin of $GROUP
gpasswd -A $USER $GROUPRemove $USER from $GROUP
gpasswd -d $USER $GROUPCreate a new group
Delete a group
Display processes in a tree-like display illustrating parent-child relationships
ps -f
ps --forestShow system processes
ps ax
ps -eDisplay full listing of processes
ps u
ps -fDisplay user processes
ps xG
ps -aDisplay SELinux contexts for processes
ps auxZGrant user {lisa} right to read {file}
setfacl -m u:lisa:r fileRemove named group {staff} from {file}'s ACL
setfacl -x g:staff fileModify file access control list for {file} to revoke write access from all groups and all named users
setfacl -m m::rx fileGrant read access to other users
setfacl -m o::rwx file4.txtAdd user {zach} to list of users of file4.txt
setfacl -m u:zach:rw file4.txtShut down at 8 pm
shutdown 20:00sudo is installed by default on most distros, but it can be installed. [52]
In order to use sudo, users have to be added to special groups that vary based on distribution. The group wheel grants access to sudo on Red Hat derivatives, while there is a group named sudo on Debian, Ubuntu, and derivatives to do the same thing.
Using sudo with output redirection will cause an error if the effective user doesn't have write permissions.
- Invoke a new shell as root by using
sudo sh -c - Pipe output to
sudo teecommand
Prevent sudo from prompting for credentials or for any other reason
sudo --nopromptObtain the normal login environment
su -Execute a single command with a non-interactive session
su -c cmd| Option | Effect |
|---|---|
-n |
change update interval |
Check kernel version
uname -srmCreate a new user, setting their default shell to /bin/bash
useradd -s /bin/bashCreate a new user account {luke} belonging to default group {wheel}, creating a home directory
useradd -m -g wheel lukeCreate a new user account with {comment}
useradd -c "comment"Create a new user account, adding it to groups {grp1} and {grp2}
useradd -G grp1 grp2Create a new user account, specifying {UUID}
useradd -u UUIDAdd $USER
useradd $USERAdd $USER, noting her full $NAME
useradd $USER -c $NAMEAdd $USER, specifying home directory at $PATH
useradd $USER -d $PATHAdd $USER, specifying expiration $DATE (YYYY-MM-DD)
useradd $USER -e $DATECreate new $USER leaving a $COMMENT field (conventionally noting the full name of the user) and creating a home directory
useradd -c $COMMENT -m $USERCreate a system user rather than a normal user
useradd -rDelete an existing user account
Delete an existing user account as well as the user's home directory
userdel -r user