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,446 results
tar -C <source_dir> -cf . | tar -C <dest_dir> -xf -
ifconfig | grep "inet\ " | grep -v "127.0" | sed -e 's/inet\ addr://g' | sed -e 's/Bcast:/\ \ \ \ \ \ \ /g' | cut -c 1-29 | sed -e 's/\ //g'
cd $(ls -1t --color=never | head -1)
ls -la | grep $(date +%Y-%m-%d) | egrep -v -e '\.{1,2}' | sed "s/.*\:[0-9]\{2\} \(.\+\)$/\\1/g"
sudo iptables-save > /etc/iptables.up.rules
2009-08-19 14:55:05
User: kamiller
Functions: iptables-save sudo

Stores the currently active iptables rules to a file that will be applied upon reboot

find . -name "*.EXT" | xargs grep -n "TODO" | wc -l
sed -i '/Centos/d' VirtualBox.xml
2009-05-05 13:03:55
Functions: sed

Simple but useful command, I use this for purge an hard disk entry in Virtualbox registry file (is in ~user/.Virtualbox) that persist if I erase a Virtual Machine, so I need to delete it manually.

no untag
2010-03-26 02:45:32
User: rootgeek
Tags: foundry

'no untag' is applied to _all_ ports under the default VLAN. Otherwise the default VLAN runs untagged over all physical ports. Pretty good idea to 'prune' your VLANs and define which ones pass over and across trunks that carry the default VLAN traffic.

cal -3
2009-04-02 17:40:38
User: haivu
Functions: cal
Tags: PIM

the -3 show the previous, current, and next month.

ls *.wav | while read f; do lame "$f" -o "$(echo $f | cut -d'.' -f1)".mp3; done;
rstp priority 0
2010-03-26 02:51:54
User: rootgeek
Tags: foundry

This is how you make sure that ports in a VLAN remain, root ports. Typically, you would use this command on all your Core-1 switch VLAN ports, and then use 'rstp priority 1' on all your Core-2 switches. This is if you have a dual L3 core that is.

rm !(*.txt)
aaa authentication login default local tacacs+
2010-03-26 02:58:03
User: rootgeek
Functions: login
Tags: foundry

You need all those commands, in the sample output. I had some of this, but had to play, add remove, type random stuff like a monkey to finally get this working (clearly those IP's are fake to protect the guilty, and so is the key).

2011-07-02 17:37:19
User: 0disse0
Tags: windows ntfs

Although not frequently used, it is possible to clone an NTFS partition to an image file and, where necessary, restore the image to another partition. This command is useful, for example, if we want to keep a backup copy of our Windows installation, or in a corporate environment to install or repair a Windows of one or more computers. For the command syntax is refer to the documentation (man ntfsclone)

show optic <slot #>
2010-03-26 03:07:22
User: rootgeek
Tags: foundry

Okay, Jimmy, the command 'optical-monitor' is needed within the global config. for this command to work (and if supported by your licsense: yada yada, blah, blah). But, like its mad PHAT Kid, you dig? Basically, a Foundry/Brocade switch is reading the Laser light levels just like those Fiber test kits from Owl that cost 4k. I know, I also find it hard to contain myeself ;-) No really.....

echo Y29tbWFuZGxpbmUuZnUgcm9ja3MK | base64 -d
yum install fortune-firefly; fortune
mkntfs /dev/hda1
2011-07-02 17:43:16
User: 0disse0
Tags: windows ntfs

With this command you can create an empty NTFS partition. The command is useful if, for example, we want to format a previous installation of Windows and reinstall before you want to restore some files on the partition.

open -a /Applications/Safari.app $1
puppetd -t
sudo mount -t vfat /dev/sdb1 /mnt/sdb1
ls *[^p][^a][^t]* ; # or shopt -s extglob; ls !(*pattern*)
ifconfig | sed '/.*addr.*Bcast.*/ ! d'| sed 's/.*addr:\([0-9\.]*\).*/\1/'
2010-03-26 08:13:13
User: Haegin
Functions: ifconfig sed

This doesn't make any assumptions about your IP address and prints out one IP address per line if you have multiple network interfaces.

echo -e "o\nn\np\n1\n\n\nw\n" | fdisk /dev/sdX
for /F "DELIMS=""" %i in ('dsquery group -name SourceGroupName ^| dsget group -members') do dsquery group -name TargetGroupName | dsmod group -addmbr %i
2009-09-25 16:32:33
User: miketheman

Interacting with Active Directory to add users from one group to another group.

This prevents from having to deal with long DNs and copying, pasting problems. It executes once per returned object.