Linux Tips and Tricks

Introduction
A collection of commands that I can struggle to remember ...

Disk Usage ==Find who occupies the most disk space, in the current filesystem: du -h --max-depth=1 --one-file-system. 2>/dev/null | sort -h

Find who occupies the most disk space: du -sh * 2>/dev/null | sort -h

Search for files and directories
Find all directories under /opt, excluding the path /opt/Citrix: find /opt -not -path "/opt/Citrix" -not -path "/opt/Citrix/*" -type d 2>/dev/null

Regular Expressions
Match an IP address: ([0-9]{1,3}[\.]){3}[0-9]{1,3}

Dump network traffic
Good for capturing web pages: tcpdump -i any -n -A -s 0 -w /tmp/capture.cap 'tcp port 80'

Good for capturing generic traffic: tcpdump -i any -n -X -s 0 -w /tmp/capture.cap 'tcp and host 192.168.1.2'