As there is a windows version of this question, I decided to open a community wiki for the same question under unix, linux, and the like.

I'll be updating this list with the answers:

  • bash: exec 3<> /dev/tcp/localhost/80 # Redirect to port 80 of localhost
  • find: search for files in a directory hierarchy
  • htop: interactive process viewer, similar to top
  • xargs: build and execute command lines from standard input
  • tmux: detachable, re-attachable command line sessions
  • apropos: find relevant man pages
  • vmstat: See the state of your system



Keyboard shortcuts: - Ctrl T (BSD specific): send SIGINFO to a running program - Magic SesRq key (Linux specific):

Terminal - All commands - 9,983 results
sudo !!
2009-01-26 10:26:48
User: root

Useful when you forget to use sudo for a command. "!!" grabs the last run command.

python -m SimpleHTTPServer
:w !sudo tee %
2009-02-25 16:27:24
User: skinp
Functions: tee
Tags: vim sudo tee

I often forget to sudo before editing a file I don't have write permissions on. When you come to save that file and get the infamous "E212: Can't open file for writing", just issue that vim command in order to save the file without the need to save it to a temp file and then copy it back again.

cd -
2009-01-26 13:25:37
User: root

Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run:

echo "no typozs"

you can correct it with

2009-02-21 07:53:32
User: fryfrog

mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.

As mtr starts, it investigates the network connection between the host mtr runs on and HOSTNAME. by sending packets with purposly low TTLs. It continues to send packets with low TTL, noting the response time of the intervening routers. This allows mtr to print the response percentage and response times of the internet route to HOSTNAME. A sudden increase in packetloss or response time is often an indication of a bad (or simply over?loaded) link.

ctrl-x e
2009-03-11 09:26:05
User: fool

Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever.

2009-03-17 16:25:29
User: eaZy

Prepending one or more spaces to your command won't be saved in history.

Useful for pr0n or passwords on the commandline.

Tested on BASH.

> file.txt
2009-01-26 10:22:31
User: root

For when you want to flush all content from a file without removing it (hat-tip to Marc Kilgus).

$ssh-copy-id user@host
2009-01-28 22:22:01
User: root
Functions: reset

If you bork your terminal by sending binary data to STDOUT or similar, you can get your terminal back using this command rather than killing and restarting the session. Note that you often won't be able to see the characters as you type them.

ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg
'ALT+.' or '<ESC> .'
2009-03-20 11:36:04
User: atoponce

When typing out long arguments, such as:

cp file.txt /var/www/wp-content/uploads/2009/03/

You can put that argument on your command line by holding down the ALT key and pressing the period '.' or by pressing <ESC> then the period '.'. For example:

cd 'ALT+.'

would put '/var/www/wp-content/uploads/2009/03/ as my argument. Keeping pressing 'ALT+.' to cycle through arguments of your commands starting from most recent to oldest. This can save a ton of typing.

mount | column -t
2009-03-20 14:18:56
User: thechile
Functions: column mount

Particularly useful if you're mounting different drives, using the following command will allow you to see all the filesystems currently mounted on your computer and their respective specs with the added benefit of nice formatting.

ssh -N -L2001:localhost:80 somemachine
echo "ls -l" | at midnight
2009-01-25 21:07:42
User: root
Functions: at echo

This is an alternative to cron which allows a one-off task to be scheduled for a certain time.

dig +short txt <keyword>
2009-07-31 16:08:59
User: drizzt
Functions: dig

Query Wikipedia by issuing a DNS query for a TXT record. The TXT record will also include a short URL to the complete corresponding Wikipedia entry.You can also write a little shell script like:

$ cat


dig +short txt ${1}

and run it like

./ unix

were your first option ($1) will be used as search term.

netstat -tlnp
2009-02-15 14:20:25
User: fulat2k
Functions: netstat

The PID will only be printed if you're holding a root equivalent ID.

dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp
2009-02-08 10:10:00
User: morpheus
Functions: dd ssh

This will output the sound from your microphone port to the ssh target computer's speaker port. The sound quality is very bad, so you will hear a lot of hissing.

curl -u user:pass -d status="Tweeting from the shell"
2009-02-11 10:20:15
User: Tronks

Very useful for rerunning a long command changing some arguments globally.

As opposed to ^foo^bar, which only replaces the first occurrence of foo, this one changes every occurrence.

mount -t tmpfs tmpfs /mnt -o size=1024m
2009-02-06 00:33:08
User: ajrobinson
Functions: mount

Makes a partition in ram which is useful if you need a temporary working space as read/write access is fast.

Be aware that anything saved in this partition will be gone after your computer is turned off.

man ascii
sshfs name@server:/path/to/folder /path/to/mount/point
2009-02-05 20:17:41
User: ihasn

Install SSHFS from

Will allow you to mount a folder security over a network.

2010-04-21 13:10:33
User: aajjk

curl -> IP Adress

curl -> Remote Host

curl ->User Agent

curl -> Port

thonks to

asparagui 13 minutes ago | link

alias emacs="nano"


gav 2 minutes ago | link

Using `find` is nice to get just directories:

$ find . -type d -maxdepth 1


carlesfe 10 minutes ago | link

Here's my list, a very compact plaintext file:


SkippyZA 2 minutes ago | link

Ctrl+l is my most used command. I need a clean terminal


Process Basics

All processes, with params + hierarchy
Show all ruby-related PIDs and processes
What is a process doing?
What files does a process have open?
(also nice to detect ruby version of a process)
Flavors of kill
Keep an eye on a process


How much mem is free?
Learn how to read output
Are we swapping?
First line is avg since boot
List the top 10 memory hogs
Detect OOM and other bad things
Disable OOM killer for a process


Check reads/writes per disk
Files (often logs) marked for deletion but not yet deleted
Overview of all disks
Usage of this dir and all subdirs
Find files over 100MB
Low hanging fruit for free space.
Check /var/log too!
Find files created within the last 7 days
Find files older than 14 days
Delete files older than 14 days
Monitor a log file for an IP or anything else
Generate a large file (count * bs = total bytes)


TCP sockets in use
Get IP/Ethernet info
host <=> IP resolution
Curl, display headers (I), follow redirects (L)
Traceroute with stats over time (top for traceroute) Requires install
Traceroute using TCP to avoid ICMP blockage
List any IP blocks/rules
Drop any network requests from IP
Show traffic by port
Show all ports listening with process PID
D/L speed test (don't run in prod! :)

Terminal & Screen

Start a screen session as the current user
Join/re-attach to a screen session
Record a terminal session
Playback a recorded terminal session

Tips n Tricks

Run Previous command as root
Change to last working dir
Run something forever


"Tail" all queries hitting mysql. Learn more
Connect to production mysql locally on port 3307 via ssh Learn More
sudo dpkg-reconfigure -plow unattended-upgrades
  1. # These aliases can be added to your ~/.bashrc file.
  2. alias f="sudo find / -mount -name"
  3. alias a="sudo service apache2 restart"
  4. alias sl="sudo tail -f /var/log/syslog"
  5. alias n="sudo service nginx restart"
  6. alias s="sudo service smbd restart; sudo service nmbd restart;"
  7. alias u="sudo killall uwsgi"
  8. alias v="source venv/bin/activate"
  9. alias monitor="tcptrack -i eth0"
  10. alias myip="wget -O - -q ; echo"
  11. alias webserver="python -m SimpleHTTPServer"
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
wget --output-document=/dev/null

Old question, though this solution is missing from the answers. You could use iperf to test the speed between two machines, since 'iperf' was designed to measure bandwidth.

on machine1 (host, this one will receive)

iperf -s -p 65000

on machine2 (client, this one will upload)

iperf -c [ip of server] -p 65000

Reverse the machines to test the other way (upload->download or vice versa).

I have marked with a * those which I think are absolutely essential
Items for each section are sorted by oldest to newest. Come back soon for more!

* In bash, 'ctrl-r' searches your command history as you type
- Add "set -o vi" in your ~/.bashrc to make use the vi keybindings instead
  of the Emacs ones. Takes some time to get used to, but it's fantastic!
- Input from the commandline as if it were a file by replacing 
  'command <' with 'command <<< "some input text"'
- '^' is a sed-like operator to replace chars from last command 
  'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
* '!!:n' selects the nth argument of the last command, and '!$' the last arg
  'ls file1 file2 file3; cat !!:1-2' shows all files and cats only 1 and 2
- More in-line substitutions:
- 'nohup ./long_script &' to leave stuff in background even if you logout
- 'cd -' change to the previous directory you were working on
- 'ctrl-x ctrl-e' opens an editor to work with long or complex command lines
* Use traps for cleaning up bash scripts on exit
* 'shopt -s cdspell' automatically fixes your 'cd folder' spelling mistakes

- function lt() { ls -ltrsa "$@" | tail; }
- function psgrep() { ps axuf | grep -v grep | grep "$@" -i --color=auto; }
- function fname() { find . -iname "*$@*"; }

- ':set spell' activates vim spellchecker. Use ']s' and '[s' to move between
  mistakes, 'zg' adds to the dictionary, 'z=' suggests correctly spelled words
- check my .vimrc and here for more

* 'htop' instead of 'top'
- 'ranger' is a nice console file manager for vi fans
- Use 'apt-file' to see which package provides that file you're missing
- 'dict' is a commandline dictionary
- Learn to use 'find' and 'locate' to look for files
- Compile your own version of 'screen' from the git sources. Most versions
  have a slow scrolling on a vertical split or even no vertical split at all
* 'trash-cli' sends files to the trash instead of deleting them forever. 
  Be very careful with 'rm' or maybe make a wrapper to avoid deleting '*' by
  accident (e.g. you want to type 'rm tmp*' but type 'rm tmp *')
- 'file' gives information about a file, as image dimensions or text encoding
- 'awk '!x[$0]++'' to check for duplicate lines
- 'echo | at midnight' starts a command at the specified time
- Pipe any command over 'column -t' to nicely align the columns
* Google 'magic sysrq' and learn how to bring you machine back from the dead
- 'diff --side-by-side fileA.txt fileB.txt | pager' to see a nice diff
* '' remembers your most used folders and is an 
  incredible substitute to browse directories by name instead of 'cd' 
- '' is a fantastic solution to 
  upload by commandline via Dropbox's API if you can't use the official client
- learn to use 'pushd' to save time navigating folders ( is better though)
- if you liked the 'psgrep' alias, check 'pgrep' as it is far more powerful
* never run 'chmod o+x * -R', capitalize the X to avoid executable files. If
  you want _only_ executable folders: 'find . -type d -exec chmod g+x {} \;'
- 'xargs' gets its input from a pipe and runs some command for each argument

- Don't know where to start? SMB is usually better than NFS for most cases.
  'sshfs_mount' is not really stable, any network failure will be troublesome
- 'python -m SimpleHTTPServer 8080' shares all the files in the current 
  folder over HTTP, port 8080
- 'ssh -R 12345:localhost:22 "sleep 1000; exit"' forwards's port 12345 to your local ssh port, even if you machine 
  is not externally visible on the net. 
  Now you can 'ssh localhost -p 12345' from and you will 
  log into your machine. 
  'sleep' avoids getting kicked out from for inactivity
* Read on 'ssh-keygen' to avoid typing passwords every time you ssh
- 'socat TCP4-LISTEN:1234,fork TCP4:' forwards your port
  1234 to another machine's port 22. Very useful for quick NAT redirection.
* Configure postfix to use your personal Gmail account as SMTP: Now you can send emails from the command line.
  'echo "Hello, User!" | mail'
- Some tools to monitor network connections and bandwith:
  'lsof -i' monitors network connections in real time
  'iftop' shows bandwith usage per *connection*
  'nethogs' shows the bandwith usage per *process*
* Use this trick on .ssh/config to directly access 'host2' which is on a private 
  network, and must be accessed by ssh-ing into 'host1' first
  Host host2
      ProxyCommand ssh -T host1 'nc %h %p'
  	  HostName host2
* Pipe a compressed file over ssh to avoid creating large temporary .tgz files
  'tar cz folder/ | ssh server "tar xz"' or even better, use 'rsync'


(CC) by-nc, Carles Fenollosa <> 
Retrieved from
Last modified: jue 07 mar 2013 05:31:49  CET

Try the watch command.

Usage: watch [-dhntv] [--differences[=cumulative]] [--help] [--interval=<n>] 
             [--no-title] [--version] <command>`

So that:

watch -n1  command

will run the command every second, forever.

OP has asked for link to OS X version of watch:

  1. CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
  2. GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

Quickly navigate your filesystem from the command-line

Normal mode: see other answers.

The Ex way:

  • :t. will duplicate the line,
  • :t 7 will copy it after line 7,
  • :,+t0 will copy current and next line at the beginning of the file (,+ is a synonym for the range .,.+1),
  • :1,t$ will copy lines from beginning till cursor position to the end (1, is a synonym for the range 1,.).

If you need to move instead of copying, use :m instead of :t.

This can be really powerful if you combine it with :g or :v:

  • :v/foo/m$ will move all lines not matching the pattern “foo” to the end of the file.
  • :+,$g/^\s*class\s\+\i\+/t. will copy all subsequent lines of the form class xxx right after the cursor.

Reference: :help range, :help :t, :help :g, :help :m and :help :v

Terminal - Alternatives
'ALT+.' or '<ESC> .'
2009-03-20 11:36:04
User: atoponce

When typing out long arguments, such as:

cp file.txt /var/www/wp-content/uploads/2009/03/

You can put that argument on your command line by holding down the ALT key and pressing the period '.' or by pressing <ESC> then the period '.'. For example:

cd 'ALT+.'

would put '/var/www/wp-content/uploads/2009/03/ as my argument. Keeping pressing 'ALT+.' to cycle through arguments of your commands starting from most recent to oldest. This can save a ton of typing.

<ALT> .
<ALT> .
2010-01-24 17:59:52
User: ringlerun

for example if you did a:

ls -la /bin/ls


ls !$

is equivalent to doing a

ls /bin/ls
<ALT>+<.> or <ALT>+<NUM>+<.> or <ALT>+<NUM>,<ALT>+<.>
2011-03-01 17:41:08
User: aikikode

After executing a command with multiple arguments like

cp ./temp/ ~/prog/

you can paste any argument of the previous command to the console, like

ls -l ALT+1+.

is equivalent to

ls -l ./temp/

ALT+0+. stands for command itself ('ls' in this case)

Simple ALT+. cycles through last arguments of previous commands.