Useful Unix commands

For a long time I’ve maintained a memory aid in the form of a list of useful commands which can be used on the command line for Linux, OS X, BSD, Solaris, etc., so I thought I’d list them in a blog post in case they come in useful for others. Most of these will run on any Unix-type operating system, though I’ve usually indicated where a command is OS-specific.

  • For Debian/Ubuntu distributions, many of these commands are available via the APT package manager.
  • For Red Hat/CentOS/Fedora, many of these commands are available via the yum package manager, though particularly in the case of CentOS I’d recommend adding the EPEL repository to increase the availablility of useful tools which are otherwise missing.
  • For OS X, install the excellent Homebrew package manager, then many of these commands will be available for install.

This is a fairly arbitrary list which I add to when I forget to use something old, or when I come across something new which is useful. Some of these commands will probably be familiar to you, and some probably won’t. I’ve added links where applicable. Please feel free to throw amendments or additional suggestions my way.

The list of commands

  • ab – website benchmarking; usually comes with Apache HTTP server
  • afconvert – powerful audio file converter; OS X only
  • cpulimit – provides a simple way of limiting CPU usage for specific processes
  • curl – powerful URL transfer tool for testing web pages and other services
  • dc – CLI-based calculator
  • ditaa – converts ASCII art to PNG
  • dmidecode – reports system hardware as described in the BIOS
  • exiftool – for manipulating Exif data on image files
  • fio – IO benchmarking tool
  • goaccess – simple and powerful web log analyser and interactive viewer
  • html2text.py – converts HTML to Markdown; this is not the html2text which comes with e.g. Homebrew
  • htop – like top but nicer and more informative
  • http-server – start a web server in the current directory on port 8001, using Node.js; package needs to have been installed using: npm install http-server -g
  • httping – ping a host using HTTP instead of ICMP
  • iftop – like top but for network traffic
  • ike-scan – find and probe IPSec VPNs
  • iotop – like top but for disk IO
  • jp2a – converts JPEGs to ASCII art
  • lshw – simple and powerful way of getting hardware info; Linux only
  • lsof – for finding which processes are using which files and network ports, amongst other things
  • mitmproxy/mitmdump – nice HTTP sniffer proxy; usually installed via pip
  • mtr – handy graphical combination of ping and traceroute
  • mountpoint – check whether a directory is a mount point
  • multitail – tail multiple log files in separate panes in the same window
  • ncat – like nc/netcat but newer and with extra options; comes with nmap
  • nethogs – quick real-time display of how much bandwidth individual processes are using; Linux only
  • ngrep – for intelligently sniffing HTTP and other protocols
  • nl – add line numbers to input from file or stdin
  • nmap – comprehensive port/vulnerability scanner
  • nping – advanced ping tool for TCP/HTTP pinging; comes with nmap
  • opensnoop – watch file accesses in real time; OS X only
  • parallel – like xargs but better
  • paste – merge multi-line output into single line with optional delimiters
  • pen – simple but effective command line load balancer
  • pgrep/pkill – easy grepping for/killing of processes using various criteria
  • photorec – recover lost documents, videos, photos, etc. from storage media
  • pidstat – flexible tool for obtaining statistics on processes, very useful for understanding resource usage for particular processes
  • psk-crack – for cracking VPN preshared keys obtained with ike-scan; comes with ike-scan
  • printf – for reformatting; very useful for things like zero padding numbers in bash
  • pstree – shows a tree of running processes
  • pv – provides a progress bar for piped processes
  • python -m SimpleHTTPServer – start a web server in the current directory on port 8000, using Python
  • qlmanage -p – Quick Look from the command line; OS X only
  • s3cmd – CLI tool for Amazon S3 administration
  • scutil – for changing system settings including various forms of hostname; OS X only
  • seq – generates a sequence of numbers
  • siege – website benchmarking; more options than ab
  • sslscan – see which ciphers and SSL/TLS versions are supported on secure sites
  • stress – to artificially add load to a system for testing purposes
  • subnetcalc – IPv4/IPv6 subnet calculator
  • tcptraceroute – like traceroute but TCP
  • tee – for directing output to a file whilst watching it at the same time
  • time – gives info on how long a command took to run
  • timeout – run a command with a time limit, i.e. kill it if it’s still running after a certain time
  • tmutil – get more control over Time Machine from the command line; OS X only
  • tree – file listing in tree format
  • trickle – simple but effective bandwidth throttling
  • trimforce – turns on TRIM support for third-party SSDs; OS X only
  • watch – prepend to a command line to see continously updating output
  • wget – nice client for web downloads and archiving websites
  • xmlstarlet – powerful tool for manipulating and reformatting XML