Notes on System Administration
Users
passwd [options] [user]
: changes passwords for user accounts. A normal user may only change the password for their own account, while the superuser may change the password for any account. It also changes the account or associated password validity period.su [options] [-] [user]
: allows commands to be run with a substitute user and group ID.-
starts the shell as a login shell.-c command
passes a command.
File System
Filesystem Hierarchy Standard
bin
: Essential command binariesboot
: Static files of the boot loaderdev
: Device filesetc
: Host-specific system configurationhome
: Users directorieslib
: Essential shared libraries and kernel modulesmedia
: Mount point for removable mediamnt
: Mount point for mounting a filesystem temporarilyopt
: Add-on application software packagesproc
: Kernel and process file systemroot
: Home directory for the root userrun
: Data relevant to running processessbin
: Essential system binariessrv
: Data for services provided by this systemsys
: Kernel and system informationusr/bin
: Most user commandsusr/include
: Standard header filesusr/lib
: Libraries for programming and packagesusr/libexec
: Binaries run by other programsusr/local
: Local softwareusr/share
: Arch independent datatmp
: Temporary filesvar
: Variable datavar/spool/cron
: Cron jobs' data
Commands
cmp [options] [file1] [file2]
: compare two files byte by byte.find [options] [start directory] -name [pattern]
: searches for files.plocate [pattern]
: searches for files.sudo updatedb
to update its database.tree [options] [directory]
: a recursive directory listing program that produces a depth indented listing of files.-L
sets the max display depth of the directory tree.cp [options] [origin] [destination]
: copy fromorigin
todestination
.-i
asks before copying.-r
recursive copy.-t folder
copy everything from origin into folder.-T
destination is a file.mv [options] [origin] [destination]
: move/rename fromorigin
todestination
.-i
asks before moving.-t folder
move everything from origin into folder.-T
destination is a file.rm [options] [file]
: remove/renamefile
.-i
asks before removing.-r
recursive remove.ln -s [origin] [destination]
: soft link fromorigin
todestination
.
Permissions
d rwx rwx rwx
: if directory and read, write, execute for user, group and othersgroups [user]
: list the groups the user is a member ofchgrp [options] [group] [file]
: change the group of the filechown [options] [user] [file]
: change the user of the filechmod u=rwx,g=rx,o=r [file]
: change the permissions of the file to the exact ones providedchmod u+wx [file]
: add permissions to the filechmod ug-wx [file]
: remove permissions from the file
Shell
Wildcards
Wildcards are placeholders for omitted letters or numbers:
?
: placeholder for one character*
: placeholder for zero or more characters
Commands
chsh [-s shell] [user]
: change users shell.-l
lists installed shells.
Variables
$SHELL
: path to current shell binaryexport VAR=MyVar
: new env variavle for current session
System Information
uname -a
: info on systemdf -h
: see all file systemsdu -h
: disk usage of files on current directorylsblk
: list block deviceslsblk
: list block devicesfile [file]
: query what kind of file is itwho [options]
: print logged usersw
: print logged users and processesid [user]
: get user idset
: print all env variables
Environment
TODO
Internet
TODO
Utilities
apropos [options] [keyword]
: searches forkeyword
on manpageswc [options] [file]
: prints metrics from file.-c
counts bytes,-m
counts chars,-l
counts lines,-w
counts words.head [-n] [file]
: prints the first n lines of filetail [-n] [file]
: prints the last n lines of filegrep [options] [pattern] [file]
: print lines that match pattern on file. If file is-
, stdin is considered.-c
just counts matches.v
consider non matchessed 's/old/new/g' [file]
: replace all the occurrence of the pattern on the fileawk -F, ‘{ print $2 “ “ $1 “ “ $7 }’ [file]
: print fields 2, 1 and 7 of file considering a comma delimited filesdiff -s [file1] [file2]
: prints the comparison of file1 and file2.<
if the line exists only in the first file,>
if the line exists only in the second file,|
if they are differentsort [options] [files...]
: sort lines of text files.-t char
char delimited files,+n
sort by the nth field,-n
sort numericallyuniq [options] [input] [output]
: report or omit repeated lines.-u
print unique lines,-D
print duplicate linestee [file]
: read from standard input and write to standard output and file.-a
append, do not overwrite.split [options] [size] [file] [prefix]
: output pieces of file to PREFIXaa, PREFIXab, ... in chunks of size size.-b
size in bytes,-l
size in lines,-t char
use char as separatorat [options]
: o
Vim
TODO
Regular Expressions
TODO