Information below is not for the current semester.
The current semester can be found here.
This is an advanced course. We have put together a list of commands we expect you to know and be able to use.
Read through the manpages to learn about each command and, where listed, its
options. Don’t read man pages top-to-bottom, that’s impossible. The goal is to
know what commands there are, not to know every single option they have. Learn
to search the man page (/
if the pager used is less
).
Most of these commands (with obvious exceptions, such as rm
or reboot
) are
safe to just try—take advantage of that.
- You probably use most of these already, or at least you know they exist:
man
,man -k
- read
man man
to learn about different sections of the manual and the$PAGER
variable PAGER=cat man ls
- To reference a man page and section, you often use ls(1) in writing to
refer to the man page of ls in section 1 of the manual (
man 1 ls
). - Multiple sections may contain the same page, cf
man 1p mkdir
andman 3p mkdir
. - The double-dash (
--
) option terminator as implemented by many built-ins and commands - If you’re interested in a bit of history, check out Unix command line conventions over time (8 min reading)
- The
$POSIXLY_CORRECT
environment variable set
,set -eux
env
,export
command -v
(POSIX) vs.which
,which -a
- What is the difference between a command, a built-in (command) and an alias?
$?
exit
whoami
,id
,/etc/passwd
,/etc/group
,/etc/shadow
- Man pages exist for files and file formats too, see e.g. passwd(5)
cd
,cd -
pwd
,$PWD
passwd
chsh
sudo
,sudo -E
,sudo -u
,sudo -i
,sudo -s
hostname
uname -a
vs./etc/os-release
printf
(POSIX) vs.echo [-n]
(many different implementations)read -r
,$IFS
- test
-eq
,-gt
,-ge
, …=
,!=
-e
,-f
,-d
-s
-r
,-w
,-x
- Understand
test
vs[ ... ]
vs[[ ... ]]
ls
,ls -la
,ls -latr
touch
mkdir
rm
,rm -r
,rm -f
,-rf
,rmdir
cat
,cat -n
less
tee
ln -s
,ln -sf
readlink -f
realpath
find
with the following predicates:-!
\( ... \)
-type
-name
-path
-size
-executable
-exec ... \;
wc
,wc -l
,wc -c
head
,tail
diff
,diff -u
comm
,comm -123
cut -f
,cut -d
paste
,paste -d
,paste -s
bc
grep
,grep -E
,grep -F
,grep -r
,egrep
andfgrep
(deprecated)sed
,sed -e CMD -e CMD ...
awk
reboot
,poweroff
xargs
,xargs -I
,xargs -n
sort
,sort -n
,sort -r
uniq
,uniq -c
seq
base64
,base64 -d
hexdump
,hexdump -C
truncate
sha256sum
,sha512sum
- These may be new to you, but are nonetheless very useful:
ps
,ps auxf
pgrep
,pgrep -f
,pgrep -a
kill
,kill -SIGNAL
pkill
,pkill -SIGNAL
,pkill -f
htop
,top
, iotopwatch
,watch -n
sleep
pause
time
date
,date -d @TIMESTAMP
,date -u
df
lsblk
,blkid
du
,du -h
,du -s
free
,free -h
/proc/meminfo
reset
- Debugging:
strace
,strace -f
,strace -p
gdb
,gdb --args
dmesg
lsmod
,modprobe
objdump
- Networking:
ip link
(ip l
),ip addr
(ip a
),ip route
(ip r
) etc.- Many of the following commands support
-4
(force IPv4) and-6
(force IPv6), that will be useful. ping
traceroute
,mtr
ssh
,ssh -p
nc
,nc -l
,socat
ss
,netstat
iw
telnet
curl
drill
,dig
,nslookup
- UNIX permissions will be of utter importance:
- What is the meaning of
rwx
bits for files and directories respectively? chmod
with both symbolic and octal mode,chmod -R u+X .
chown
,chown -R
- What is the meaning of
- Make sure you understand basic concepts of the Unix shell. You don’t need to
understand the underlying mechanisms (although that cannot hurt), but you
must be able to use them:
- Writing shell scripts:
- What is the shebang/hashbang?
- What is the
#!/usr/bin/env ...
idiom used for? - Which permissions are required for a script to be successfully executed?
- I/O redirection:
- What is stdin, stdout and stderr?
- What is a file descriptor and how is it related to stdin, stdout and stderr?
CMD <f
CMD >f
,CMD 2>f
,CMD 2>&1
,>f CMD
CMD >>f
- Order matters:
CMD >/dev/null 2>&1
vsCMD 2>&1 >/dev/null
- Pipes:
grep /sbin/nologin /etc/passwd | cut -d: -f1
- What is the exit code of a pipeline?
set -o pipefail
(Bash, Zsh)
- Writing shell scripts: