Linux CLI Tools


Basics

ln -s /path/to/existing/file /path/to/create/link/in

df -h
(human readable disk space free)

ssh-add -K ~/.ssh/keyfile

head -n 1000 hugefile.txt > first1000lines.txt

tail -f logfile.txt
shows last 15 lines and follows updates to the file

screen
screen -r
(reconnects to existing terminal that stays running after ssh session ends)

tar zcvf ~/source.tgz path/to/expand/at

\ls
(runs a bare ls without trying to figure out which are folders/files, useful for large network directories that normal ls takes forever to output)

find . -mtime -1 -ls
(finds files changed in the last 24h)

Bash Snippets

YESTERDAY_DAY_LINUX=`date -d "yesterday 13:00" '+%d'`
YESTERDAY_DAY_MAC=`date -v-1d +%d`
YESTERDAY="${YESTERDAY_DAY_LINUX}${YESTERDAY_DAY_MAC}"

.bashrc

# some more ls aliases
alias ll=’ls -alFh’
alias la=’ls -A’
alias l=’ls -CF’

Netem (simulating poor network conditions)

sudo tc qdisc add dev eth0 root netem delay 100ms (add 100ms delay to eth0)

sudo tc qdisc delete dev eth0 root netem delay 100ms (remove 100ms delay to eth0)

Docker

docker ps -al

docker pull

docker system prune

Additional 3rd Party Tools

ncdu (ncurses disk utlility) – great tool to find where all your disk space is being used on linux (q to exit)

sudo apt install ncdu
sudo yum install ncdu

nmap (network mapping) – port scanning

ntop – like top but for networks

ctop – docker container top

tldr – short man pages about


I'm a 29 year old UIUC Computer Engineer building mobile apps, websites and hardware integrations with an interest in 3D printing, biotechnology and Arduinos.