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.

Universal configuration monitoring and system of record for IT.

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



Psst. Open beta.

Wow, didn't really expect you to read this far down. The latest iteration of the site is in open beta. It's a gentle open beta-- not in prime-time just yet. It's being hosted over at UpGuard (link) and you are more than welcome to give it a shot. Couple things:

  • » The open beta is running a copy of the database that will not carry over to the final version. Don't post anything you don't mind losing.
  • » If you wish to use your user account, you will probably need to reset your password.
Your feedback is appreciated via the form on the beta page. Thanks! -Jon & CLFU Team

Commands using sudo from sorted by
Terminal - Commands using sudo - 443 results
find /var/cache/apt -not -mtime -7 | sudo xargs rm
ls /dev/disk* | xargs -n 1 -t sudo zdb -l | grep GPTE_
2012-10-06 20:19:45
User: grahamperrin
Functions: grep ls sudo xargs

Show the UUID-based alternate device names of ZEVO-related partitions on Darwin/OS X. Adapted from the lines by dbrady at http://zevo.getgreenbytes.com/forum/viewtopic.php?p=700#p700 and following the disk device naming scheme at http://zevo.getgreenbytes.com/wiki/pmwiki.php?n=Site.DiskDeviceNames

sudo nmcli con up/down id vpn-name
find site/ -type d | xargs sudo chmod 755
find ./ -type f | xargs sudo chmod 644
find /var/cache/pacman/pkg -not -mtime -7 | sudo xargs rm
2012-09-20 12:36:44
User: brejktru
Functions: find sudo xargs

Sometimes my /var/cache/pacman/pkg directory gets quite big in size. If that happens I run this command to remove old package files. Packages that we're upgraded in last N days are kept in case you are forced to downgrade a specific package. The command is obviously Arch Linux related.

sudo apt-get install aptitude
sudo -u $USER kill -9 -1
2012-09-14 12:03:25
User: jeffenstein
Functions: kill sudo

Kill all processes belonging to a user, with a minimum of resource usage. Great for the times when a user fork-bombs the system and it's difficult to login or run commands.

sudo -s du -sm /Users/* | sort -nr | head -n 10
2012-09-13 10:15:23
User: mematron
Functions: du head sort sudo

In OSX you would have to make sure that you "sudo -s" your way to happiness since it will give a few "Permission denied" errors before finally spitting out the results. In OSX the directory structure has to start with the "Users" Directory then it will recursively perform the operation.

Your Lord and master,


sudo usermod -s `which zsh` `whoami`
sudo lastb | awk '{if ($3 ~ /([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}/)a[$3] = a[$3]+1} END {for (i in a){print i " : " a[i]}}' | sort -nk 3
2012-09-11 14:51:10
User: sgowie
Functions: awk lastb sort sudo

The lastb command presents you with the history of failed login attempts (stored in /var/log/btmp). The reference file is read/write by root only by default. This can be quite an exhaustive list with lots of bots hammering away at your machine. Sometimes it is more important to see the scale of things, or in this case the volume of failed logins tied to each source IP.

The awk statement determines if the 3rd element is an IP address, and if so increments the running count of failed login attempts associated with it. When done it prints the IP and count.

The sort statement sorts numerically (-n) by column 3 (-k 3), so you can see the most aggressive sources of login attempts. Note that the ':' character is the 2nd column, and that the -n and -k can be combined to -nk.

Please be aware that the btmp file will contain every instance of a failed login unless explicitly rolled over. It should be safe to delete/archive this file after you've processed it.

sudo find . -name "*.csv" | xargs /bin/rm
2012-08-29 11:38:37
User: defc0n1
Functions: find sudo xargs

In case you ever got to many arguments using rm to delete multiple files matching a pattern this will help you

sudo file -bs /dev/sda | sed -e 's/.*partition 1\(.*\) code offset.*/partition 1\1/g' -e 's/\(.\);/\1\n/g'
sudo showkey -k
sudo apt-get remove $(dpkg -l|awk '/^ii linux-image-/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic*//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic*\nlinux-image-%s-generic*\n",$0,$0,$0)}')
2012-08-15 10:02:12
User: mtron
Functions: awk sed sudo

Remove old kernels (*-generic and *-generic-pae) via apt-get on debian/ubuntu based systems. Tested on ubuntu 10.04 - 12.04.

sudo ssh -D 88 -fN [email protected]
sudo shred -vz -n 0 /dev/sdb
sudo /etc/init.d/dns-clean
2012-08-06 18:40:49
User: varghjarta
Functions: sudo
Tags: Network Ubuntu

Flush the DNS cache under Ubuntu (Debian?)

sudo find / \( -nouser -o -nogroup \)
2012-07-13 07:09:08
User: gwd
Functions: find sudo

suspicious/anomalous ownership may indicate system breach; should return no results

sudo find / -perm -2 ! -type l -ls
can(){ shift 2; sudo "$@"; }
sudo lshw -C network
sudo bash -c "sleep 30m; pm-hibernate"
2012-05-21 17:56:11
Functions: bash sudo

Can use minute - m, hour - h

Eg: sudo bash -c "sleep 2h; pm-hibernate"

will hibernate the system after 2hours.

while pgrep wget || sudo shutdown -P now; do sleep 1m; done
cd /System/Library/LaunchDaemons; sudo launchctl load -w com.apple.metadata.mds.plist