These notes were written with some prior knowledge of Linux and therefore may just represent some horrendous knowledge gaps of mine. Thanks to Dave from the tutoriaLinux yt-channel; check out his videos. See Github for nicer formatting.

Basics terminal

pwd - print working directory

rmdir - remove dir (empty)

man program - manual

ls -s - symbolic link

head - first 10 lines of file (default)

tail - last 10 lines of file (default)

tail -f /var/log/dmesg - follow the ende of the file (useful for logs)

poweroffinit 0 / init 6 - shutdown / restart

cp - copy

cd ../../.. - go up 3 directories

ls -lh - long list human readable

sudo -i - interactive root session

wc -l - count stuff

df -h - list mounted devices (human readable)

cut -d: -f2 - take some (piped) input, look for delimiter “:”, take stuff from second field; so Key1: Value1 will return Value1
sort -bf - sort by first letter

uniq - print only unique

wc - word count

grep - searching, finding, filtering (powerful, learn more)
which - shows the full path of (shell) commands
whereis - where is a command (binary, source, manual)
locate - find files by name

cat /etc/network/interfaces - list network devices/interfaces

Pipes and Redirection

| - pipe character

echo "hello world" > hello.txt - write things to file; truncates before writing

echo "hello world" >> hello.txt - appends output

there are three channels: 0 - Standard Input (STDIN), 1 - Standard Output (STDOUT) and 2 - Standard Error (STDERR)

to catch STDERR –> 2> (channel two), e.g. ls -lh someNoneExistingFile.txt 2> action.log

input redirection: mail -s "this is a test" thomas < message.txt

ps | less - show all processes and pipe it into the program less which shows big texts in way which is easy to navigate

&& - check if left command is successful, then execute the right command

ls file.txt && echo "Success." > Success

ls wrongfile.tct && echo “Success.” > Error

vi basics

:wq! - write, quit, don’t prompt me

Package management

apt-cache search ... - search for package (Ubuntu/Debian)

apt-get remove ... - remove package

apt-get autoremove - clean up unneeded packages


ps aux | grep "process name" - get info about process

kill PID - kill process (SIGTERM = 15) with specified PID

pkill -u USERNAME - kill process of user

nice -n 15 program - start a program with low priority (19 = lowest; -20 highest)

renice -5 PID - change niceness (aka priority) of process

/proc - directory of all processes which is managed by the kernel and holds all the information about processes (in sort of files)


man hier - man page on filesystem hierarchy (overview on filesystem)

udevd - device daemon


  • /bin - binaries for applications
  • /boot - boot images
  • /dev - devices
  • /etc - configuration data for applications
  • /home
  • /lib / /lib64 - shared libraries* /mnt - mount
  • /proc - process directory (informations about running processes)
  • /opt - optional software, no clear convention using this
  • /sbin - system binaries
  • /tmp - temporary files, cleaned on restart
  • /usr - non-essential binaries
  • /var/log - system logs

absolute and relative paths: /home/user/downloads and downloads/

Filetypes (with flag/first bit on ls -l)

Regular file (-)
Directory (d)

Character Device (c)

Block Device (b)

Local Domain Socket (s)

Named Pipe (p)

Symbolic Link (l)

File permissions

rwx rw- r-- - owner read/write/execute group read/write anyone read

chmod 777 - rwx for owner, group, anyone

chmod 666 - rw- for owner, group, anyone

chmod 444 - r-- for owner, group, anyone

chmod 000 - --- for owner, group, anyone

LXC (LinuX Containers)

when operating with LXC one should be root; even basic stuff like lxc-ls will need root privileges

/var/cache/lxc/distro - contains the cached images needed for creation of a LXC

/var/lib/lxc/ - contains files for every created container (including rootfs)

/var/lib/lxc/myfirstcontainer/config - config file (see man 5 lxc.container.conf

lxc-create -t ubuntu -n myfirstcontainer - type = ubuntu, name = myfirstcontainer; note: type takes host system defaults if not otherwise specified regarding architecture and what not; note further: will do a net install which is stored

lxc-ls --fancy - list running machines

lxc-start -n myfirstcontainer -d - start LXC in daemon mode; doesn’t hog up the current shell session, starts in background; connect via SSH to IPV4

lxc-stop -n myfirstcontainer -k - stop plus kill

lxc-freeze -n myfirstcontainer - freezes the proccess

lxc-attach -n myfirstcontainer - attaches current shell to container (avoiding to SSH in)