Skip to content

Instantly share code, notes, and snippets.

@ADU-21
Forked from mbbx6spp/README.md
Created August 16, 2016 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ADU-21/170a6d0f8756935cead9361bdea0bc67 to your computer and use it in GitHub Desktop.
Save ADU-21/170a6d0f8756935cead9361bdea0bc67 to your computer and use it in GitHub Desktop.
Best UNIX shell-based tools I can't live without with example usages

Best UNIX Shell tools

These are a list of usages of shell commands I can't live without on UNIX-based systems.

Install

Mac OS X

Using Homebrew (yes, I am opinionated) you can install the following tools with the following packages:

brew install proctools # to install pgrep, pkill, etc.
brew install pstree # to be able to use pstree
brew install vnstat # to be able to use vnstat
brew install ncdu # to use ncdu
brew install ipcalc # to use the almighty ipcalc
brew install htop # to use htop
brew install ack # to use the awesome ack
brew install lsof # to use the amazing lsof

Fedora/Red Hat/CentOS

Using YUM you can install the tools with the following RPM packages:

yum install proctools # same as brew package
yum install psmisc # for pstree
yum install vnstat # for vnstat
yum install ncdu # for ncdu
yum install initscripts # for ipcalc - should already have this, I think?
yum install htop # for htop
yum install ack # for ack
yum install lsof # for lsof

Ubuntu/Debian APT

Using APT you can install the tools with the following RPM packages:

apt-get install procps
apt-get install psmisc
apt-get install vnstat
apt-get install ncdu
apt-get install ipcalc
apt-get install htop
apt-get install ack
apt-get install lsof
#!/usr/bin/env bash
ncdu # launches ncurses version of `du` that makes it nice to navigate around in
pgrep -L beam.smp # lists all Erlang processes
pkill ruby # kills all Ruby processes
fc # opens previous command in your $EDITOR then after editing line, will execute on editor quit
fc pgrep # opens last command starting with pgrep in $EDITOR
lsof -iTCP # show current TCP connections
lsof -i :8080 # show current connections on port 8080
lsof -i@your.remote.host # show all connections to/from your.remote.host
lsof -u `whoami` # show all your user's connections
lsof -c beam.smp # show all connections for Erlang nodes
lsof /path/to/file # show all OS processes using or pointing to that file path
lsof -p 4830 # show all connections for a specific PID (4830)
lsof -a -u USER -c beam.smp # show all connections for Erlang nodes running as USER
/etc/init.d/nginx stop
sudo !! # runs previous command but prefixes sudo before it (can use anything instead of sudo, the key is !!)
^stop^start # reruns previous command but substitutes stop for start
vim /really/long/path/to/file.crap
ghc !$ # use argument from previous command using !$...can prefix with anything, just an example usage with ghc.
vnstat -l 1 -i eth0 # show live transfer counters for interface eth0
ack "text/pattern to search for" # equivalent to a faster fgrep for all files in current directory or under (recursively)
htop # shows colourful version of top with CPU ASCII art display :)
ipcalc 192.168.0.1/32 # displays information about resulting broadcast network, very very useful!
pstree -u USER # show process tree for all procs running as USER
pstree -p PID -l 2 # show process tree for all procs under PID at 2 levels deep
echo "Enjoy and heckle me on Twitter @SusanPotter if you want to tell me what commands you can't live without not in this usage script! :)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment