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,448 results
<devcon/>, <dnsstat/>, <dsget>, <dsmod>, <enml>dloal>,/<html></>
2011-12-28 11:41:35
User: ajala19
Tags: cdma

the system will display device manager command line utility, dns statistics, v

grep -r <searchterm> .
2012-02-08 11:59:17
Functions: grep
Tags: grep directory

You don't need to use "*", it will fail if the working directory has too many fails due parameter extension, you can simply pass the working directory using ".".

for file in *.flac; do flac -cd "$file" | lame -h -b 320 - "${file%.flac}.mp3"; done
2012-03-23 08:05:17
User: samadhi
Functions: file

Converts flac files to mp3 with the same file names in the same directory.

(sp-sc sop://brokesopcast.com:3912/6002 3908 8908 &>/dev/null &); vlc http://localhost:8908/tv.asf
sudo find / -perm -2 ! -type l -ls
pdf2jpg(){ convert -density 400 -bordercolor white -border 0 -resize 992x1403 -quality 85 $1 ${1/%pdf/jpg} ; }
awk '{ print $9 }' access.log | sort | uniq -c | sort -nr | head -n 10
ls -1F | grep @$ | sed 's/@//' | column
2013-07-19 17:55:11
User: jlbknr
Functions: grep ls sed
Tags: ls symlinks

I use this with alias:

alias lsl="ls -1F | grep @$ | sed 's/@//' | column"

Limitation: This will also list files that happen to have an @ at the end of the filename.

cd ~/wallpapers;arr=( * );num_wallpapers=${#arr[@]};wallpaper=${arr[$(echo $RANDOM%$num_wallpapers|bc)]};feh --bg-fill $wallpaper
2013-12-30 01:56:24
User: Evidlo
Functions: cd echo

Generates a bash array and uses it to select a random image from ~/wallpapers.

awk '/text to grep/{print $1}' "log" | sort -n | uniq -c | sort -rn | head -n 100
2014-07-09 08:48:06
User: kln0thing
Functions: awk head sort uniq

Original command: cat "log" | grep "text to grep" | awk '{print $1}' | sort -n | uniq -c | sort -rn | head -n 100

This is a waste of multiple cats and greps, esp when awk is being used

grep -Eoa "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" Filetosearch.txt
2014-11-02 19:50:54
User: jsbrown
Functions: grep

Command returns valid IP addresses. Append the following regex to additionally filter out NAT and reserved IP addresses

| grep -Ev "^0|\.0[0-9]|^10\.|^127\.|^169\.|^172\.(1[6-9]|2[0-9]|3[01])|^192.168.|^2(2[4-9]|3[0-9])|^2(4[0-9]|5[0-5])"

du -sk * | awk '{print $1} END {print "[+z1<y]sy\nlyx\np"}' | dc
grep "FOUND" /var/log/squidclamav.log | awk '{print $5"-"$2"-"$3","$4","$11}' | sed -e 's/\,http.*url=/\,/g' | sed -e 's/&/\,/g' | sed -e 's/source=//g' |sed -e 's/user=//g' | sed -e 's/virus=//g' | sed -e 's/stream\:+//g' | sed -e 's/\+FOUND//g'
2009-02-27 13:28:18
User: nablas
Functions: awk grep sed

This command will list a CSV list of infected files detected by clamav through squidclamav redirector.

tail /var/log/emerge.log | awk -F: '{print strftime("%Y%m%d %X %Z", $1),$2}'
sudo hping3 -TV --tr-stop -n -2 -p 53 ns1.server.tld
2011-01-14 10:12:37
User: forcefsck
Functions: sudo

-T = traceroute

-V = verbose

--tr-stop = exit when target is reached

-n = don't do reverse lookups (faster)

-2 = udp

-p 53 = destination port 53 (dns), change to your needs

Useful when trying to debug a network with complex routing rules and/or multiple gateways.

ffmpeg -i input.flv -aq 2 output.mp3
2011-02-16 15:05:41
User: maedox

Gives stereo, 16bit, 44.1kHz (default in Ubuntu/Medibuntu ffmpeg).

-aq 2 = 220-250kbit/s VBR, lower number is better quality. 2 or 3 should be good for most people. If you want the best mp3 q you should remove -aq and use -ab 320k to get 320kbit/s, but that is probably overkill for most .flv videos.

nohup df -k | sort -rn 12
tshark -r data.pcap -zio,phs
xdg-mime default firefox.desktop x-scheme-handler/http
2011-12-28 16:36:27
User: natestar13

A universal way to configure your web browser. Note, you'll also need to set "x-scheme-handler/https" and "text/html" for https links and html files, respectively.

repoquery --whatrequires --installed --recursive packagename
2012-09-06 18:20:05
User: eddieb
Tags: yum

'yum deplist XXX' provides a list of packages that XXX depends on.

This command provides a list of packages that depend upon XXX (package reverse dependencies)

tr -d '\r' < <input> > <output>
lftp -c "pget -n 10 http://example.com/foo.bar"
nmon -f -T -^ -s 15 -c 12
2013-07-22 08:32:48
User: vidya99343

NMON Data collector , DQME

log on to appma569 as root

cd /tmp

nmon -f -T -^ -s 15 -c 12

du -ah | sort -hr | head -n50 | cat -n
svn status | awk -F" " '{ for (i=2; i<=NF; i++) print "ls -ld \""$i"\""}' | sh
2014-07-09 09:41:24
User: kln0thing
Functions: awk
Tags: svn awk ls

The AWK part of the code will "collate" the fields from 2nd to Nth field (this is to handle any svn directories that may have spaces in them - typical when working with code that is interchangeably used with windows environment - for example, documentation teams) - the output is passed to "ls -ld" - the -d option to ls will tell ls to handle directories itself, rather than do ls on the directory. The '-p' option is just for pretty printing directories, links and executables (for added readability).

Finally, the entire "constructed" command will be passed onto sh for shell execution.