Linux

From Supernifty
Jump to: navigation, search

Disk Usage

du -S | sort -g -r | less
du -s -k *

Find

find . -name \*.swp -exec rm \{\} \; # delete matches
find . -mtime -30 # modified in last 30 days

Grep

  • -l - filenames only
  • -n - line numbers
  • -R - recursive

DNS

host hostname: IP address, mx
host -a hostname: "all"
host -t txt hostname: txt records

Network Traffic

tcpdump 'tcp port 25' # outgoing smtp
tcpdump 'host supernifty.com.au and port 80'
  • -A: traffic in ascii
  • -s 0: show full packet
  • -i eth0: interface to listen on
  • -l: don't buffer output

SSH Tunnels

  • A tunnel listening on the local machine
ssh -L localport:remotehost:remoteport
  • A tunnel listening on the remote machine
ssh -R remoteport:localhost:localport
  • SOCKS proxy
ssh -D port

e.g.

ssh -D 1080 user@host

I needed FoxyProxy to have this work on Firefox.

Top

  • M - sort by memory usage
  • P - sort by CPU