Commands

I love the command line and want to help others love it too.  Sometimes remembering the proper syntax just needs a quick glance at an example to jog the memory.  The man pages are best if you need the details.  Here are common commands with a very short description:

dumpcap Capture packets remotely to view with Wireshark:
dumpcap -q -g -i eth0 -b filesize:100000 -b files:20 -w /media/ram/cc -f "ether host a4:77:33:52:10:ae or ether host a4:77:33:52:12:e0 or port 53" &

lsb_release Show the Linux/Ubuntu Version that you are using:
lsb_release -a
cat /etc/*release*
cat /proc/version
uname -a

shred Fill a HDD with random data one time, then fill it with zeros:
shred -n1 -v -z /dev/sdX

SSH to a host using a specific user and TCP port:
ssh -p 22 [email protected]

RSync is a wonderfully flexible way to backup your files:
rsync -vaHxe 'ssh -p 22' --progress --compress-level=9 --numeric-ids --log-file=/your-log-2010-10-22 --delete --delete-excluded [email protected]:/source-path/ /your/destination path/

fdisk will show you about your hard drives and let you change the partitioning:
fdisk -l
fdisk /dev/sdX

Run Command on many *.raw Bind files to Make *.txt files:
named-compilezone -f raw -o GavinHollinger.com.txt GavinHollinger.com GavinHollinger.com.raw
for i in *.raw; do named-compilezone -f raw -o "${i/.raw}".txt "${i/.raw}" "$i"; done

sed -i 's/v=spf1 ip4:208\.77\.103\.174 include:_spf\.google\.com ~all/v=spf1 ip4:23\.227\.163\.202 include:_spf\.google\.com ~all/g' *.txt

iperf is good for quick speed testing.
Server: iperf -s
Client: iperf -i 1 -c 10.0.0.1 -d

Enable saving to Ubuntu live USB flash disk:
sudo mount -o remount,rw /cdrom


Windows 10 show open ports and processes:
netstat -aofb


sudo lsof -i -P -n | grep LISTEN
sudo netstat -tulpn | grep LISTEN
sudo ss -tulpn | grep LISTEN
sudo lsof -i:22 ## see a specific port such as 22 ##
sudo nmap -sTU -O IP-address-Here

No comments: