What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



All commands from sorted by
Terminal - All commands - 12,420 results
awk '{print NR,$0}'
df -kh /dev/vg0*/lv*
rdesktop -u <username> -p <password> -g 1366x724 -a 16 -D -z -P <servername / IP Address>
2010-06-09 11:47:35
User: mariusbutuc
Tags: rdesktop RDP

The above command will:

- open a Remote Desktop connection to [servername / IP Address],

- authenticate using [username] and [password],

- configure resolution to best fit your desktop (I have a 1366x768px resolution so I left space for 2 panels of 22px each),

- sets the color depth for the connection to 16 bpp,

- hides the window manager decorations,

- enables compression of the RDP data stream,

- enables persistent bitmap caching.

netstat -a -o -n | grep 8080
2011-04-28 09:58:59
User: evandrix
Functions: grep netstat

I cannot run Tomcat from Eclipse. It says that there?s other process that is running on port 8080, but I don?t know what is the process, and how to stop it from the Services manger in Windows. So here?s how you can kill and find out what is that process:

To find out what PID 8080 was (hopefully not a trojan)

I typed tasklist /FI ?PID eq 8080″

taskkill /F /PID 2600

vlc mms://twcilivewm.fplive.net/twcilive-live/twci_350
ps aux | grep PID | grep -v 'grep' | awk '{ print $1 }'
2011-11-05 04:53:29
User: nssy
Functions: awk grep ps
Tags: bash awk grep ps

Gets the current system user running a process with the specified pid

iptables -P INPUT ACCEPT; iptables -P FORWARD ACCEPT; iptables -P OUTPUT ACCEPT; for table in `cat /proc/net/ip_tables_names`; do iptables -t $table -F; iptables -t $table -Z; iptables -t $table -X; done
2011-12-15 18:19:34
User: dash
Functions: iptables
Tags: Linux iptables

If you changed the default policy on any chain other than filter table chain's, this won't be enough.

tr -s ' '
2012-06-26 19:34:18
User: ankush108
Functions: tr
Tags: tr

Convert long list of ' ' to a single space. Compress space and other characters.

curl -s http://boards.4chan.org/---/res/nnnnnn | grep -o -i 'File: <a href="//images.4chan.org\/[a-z]*\/src\/[0-9]*\.[a-z]\{3\}' | sed -r 's/File: <a href="\/\///' |xargs wget
history | tail -100 | grep cmd
2013-04-22 03:49:43
User: datamining
Functions: grep tail

this also can find the old command you used before

for i in * ; do mv $i $[j++].mp3 ; done
2013-07-01 08:14:59
User: yangfeng724
Functions: mv

This command will replace spaces in filename with number

info foo |less
2013-09-12 16:49:08
Functions: info
Tags: less info

This command is similar to the above, but is much simpler to remember. Sure, it's isn't as precise as the parent command, but most people aren't going to remember those --flags anyways unless you stick it into your .bashrc on every single system that you manage.

cvlc /path/to/file.avi -V caca
2014-06-13 16:10:36
User: tyzbit
Tags: video vlc

Use this command to watch video files on the terminal using VLC.

prerequisite: VLC and cvlc

sudo apt-get install vlc cvlc

if [[ $(expr $(date +%s) - $(stat -c %X /var/lib/apt/periodic/update-success-stamp)) -gt 86400 ]]; then sudo apt-get update fi
2015-05-12 14:45:11
User: gargolito
Functions: date expr stat sudo

I have this in my .bash_aliases and call it before running apt-get install or apt-get upgrade


alias apt-install='apt-update; apt-get install'

alias apt-upgrade='apt-update; apt-get upgrade'

function apt-update () {

if [[ $(expr $(date +%s) - $(stat -c %X /var/lib/apt/periodic/update-success-stamp)) -gt 86400 ]]; then

sudo apt-get update


echo apt is up to date



cd ~/.minetest/mods && git clone --recursive https://github.com/$1/$2.git
2015-09-30 19:24:59
User: lordtoran
Functions: cd

Where $1 = author and $2 = mod name

You need to be running a daily build of Minetest (for example from the 'minetestdevs/daily-builds' PPA), or some bleeding edge mods will not work or crash the game.

Update a mod by entering its subdirectory under ~/.minetest/mods and doing

git pull && git submodule update --recursive --remote --init
while(1){while((date -f ss)%10-gt0){sleep -m 300} echo "$(date -u %s) $((curl|%{$_ -replace '\D+\n',''})">>modemlog.txt;sleep 1;echo .}
2015-12-24 02:12:10
User: omap7777
Functions: date echo sleep

IMPORTANT: You need Windows PowerShell to run this command - in your Windows Command Prompt, type


Create a log file of your Motorola Surfboard SB6141 downstream signal strengths.

Uses the built-in curl to request signal strength data from your SB6141 cable modem.

HTML page has the signal strength numbers for the 8 downstreams.

Some HTML/DOM processing parses out the 8 values from the above page.

The eight extracted signal strengths are then logged to a file.

A small while-loop watches the clock & repeats the process every 10 seconds.

egrep '183\.([0-9]|(1[0-6]|2[0-3]))' -J /var/log/maillog*
2010-10-17 21:44:57
User: wazigster
Functions: egrep

Useful for grepping an IP range from the maillog. When for instance dealing with a spam-run from a specific IP range, or when errors occur from or to a specific IP-range.

In the example above the IP range ( -

To grep the IP range ( - from the maillog:

egrep '124\.217\.2(2[4-9]|[34][0-9]|5[0-5])' -J /var/log/maillog*

NOTE: the location of the maillog may vary based upon operating system and distribution.

awk '/^'$SEARCH'[ ]*$/{getline;if ($1 ~ /query/) {split($4,a,".");print a[2]}}' /etc/sybase/interfaces
2010-12-17 13:24:27
User: JohnGH
Functions: awk

Awk magic to replace:

cat /etc/sybase/interfaces | grep -A 1 -e "$SEARCH" | grep query | awk '{ print $4 }' | awk -F'.' '{print $2}'

( for((i=0;$i<100;i++))do echo volume $i 1; sleep 0.1s; done; )| mplayer -slave -quiet sample.mp3
2011-01-06 11:22:03
User: Juluan
Functions: echo sleep

Of course, a fifo is required for piloting the fade out of another song, but with a few bash function, we can mix music in bash like :

crossfadeIn > mplayerfifo1 & crossfadeOut > mplayerfifo2

loop 0 10 > mplayer fifo1

etc etc

ping -a IP-ADDRESS
2011-04-28 13:51:12
User: markussesser
Functions: ping

pcspkr have to be enabled!

modprobe pcspkr

xset b on

get_duration () { IFS=.: read -r _ h m s _ < <(ffmpeg -i "$1" 2>&1 | grep Duration);echo $(( h * 3600 + m * 60 + s )); }
inxi -F
stat /etc/my.cnf
# ping -c 1000 -i 0.001 <host>