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.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

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.


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:



2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.




All commands from sorted by
Terminal - All commands - 11,490 results
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.

ifconfig | awk '/inet addr/ &&! /{ gsub(/addr:/,""); print $2 }'
if [ $(synclient -l | grep TouchpadOff | awk '{print $3}') = "2" ]; then synclient TouchpadOff=1; elif [ $(synclient -l | grep TouchpadOff | awk '{print $3}') == "1" ]; then synclient TouchpadOff=2; else synclient TouchpadOff=2; fi
2010-01-26 07:52:55
User: GinoMan2440
Functions: awk grep

This command toggles the touchpad on and off, when it's on, the right side scroll strip (annoying) and the tap-clicking are disabled, you can change this by changing occurances of 2 in the command to 0. this whole command can then be given a keyboard shortcut so that the touchpad is disableable without using a special fn key (which linux doesn't recognize on some computers) or a seperate button.

2009-05-06 08:01:06
User: P17
Tags: bash

The colors are defined as variables.




ifconfig eth0 down hw ether (newmacaddresshere) && ifconfig eth0 up && ifconfig eth0 (newipaddresshere) netmask up && /bin/hostname (newhostnamehere)
2009-06-04 20:25:49
User: localGhost
Functions: ifconfig

The command above has been changed due to very good constructive criticism - thanks x 2! This command can be used after acquiring mac's, ip's and hostname's or any of the above from a freshly scanned LAN. User must be root, and remember to change your settings on your network managing software manually (Fedc10 NetworkManager Applet 0.7.1 is mine) instead of 'auto DHCP'. You can also substitute eth0 for wlan0 etc - be good and ENJOY!

cat aaaaaa 2>&-
sar -g 5 5
find . -name *.php | xargs grep -i -n 'TERM'
yes | tr 'y' 'n'
find . -iname "*.jar" -exec cp '{}' /tmp/ \;
2010-01-26 12:19:15
Functions: cp find

Useful for Maven multimodule projects, where you want to extract all packaged jar files.

find . -type f -print0 | grep -vzZ '.svn' | xargs -0 grep --color -nEHi "SEARCHTERM"
2009-02-05 10:27:15
User: troelskn
Functions: find grep xargs

Variant of find grep that ignores files with .svn in the name. Useful for searching through a local repository of source code.

set -o vi
2009-12-22 20:40:10
User: andykazmaier
Functions: set

Once issuing the command, hit "esc" and then "k" (not together) to enter the search mode at the shell prompt (each time), and invoke the search with "/" as if you would in vi. Type a command and see the most recently used instance of that command. Use "n" and "N" to go forward and backwards through other instances of that command.

sfdisk /dev/sdb <(sfdisk -d /dev/sda| perl -pi -e 's/sda/sdb/g')
2009-12-22 22:45:41
Functions: perl

*as long as the drives are exactly the same* then this command copies the partition table on /dev/sda to /dev/sdb

vboxmanage clonehd --format VMDK <source image|uuid> <destination image>
2010-10-04 16:42:12
User: dreffed

This is based on the Windows Version of VirtualBox.

From the /? ...

VBoxManage clonehd |

[--format VDI|VMDK|VHD|RAW|]

[--variant Standard,Fixed,Split2G,Stream,ESX]

[--type normal|writethrough|immutable|shareable]

[--remember] [--existing]

From the online help..


VBoxManage clonehd

This command duplicates a registered virtual hard disk image to a new image file with a new unique identifier (UUID). The new image can be transferred to another host system or imported into VirtualBox again using the Virtual Media Manager; see the section called ?The Virtual Media Manager? and the section called ?Cloning disk images?. The syntax is as follows:

VBoxManage clonehd |

[--format VDI|VMDK|VHD|RAW|]

[--variant Standard,Fixed,Split2G,Stream,ESX]

[--type normal|writethrough|immutable]


where the parameters mean:


Allow to choose a file format for the output file different from the file format of the input file.


Allow to choose a file format variant for the output file. It is a comma-separated list of variant flags. Not all combinations are supported, and specifying inconsistent flags will result in an error message.


Only honored if --remember is also specified. Defines what kind of hard disk type this image should be.


Keep the destination image registered after it was successfully written.

curl ifconfig.me
2011-03-02 23:04:00
User: Honeypuck

It takes a few seconds until it has figured out your public ip address. You need to have 'curl' installed of course.

vi -R filename
2009-03-04 06:56:40
User: haivu
Functions: vi
Tags: vim

The -R flag prevents you from making changes to a file, useful when you only want to view the file. This command is nicer than the 'more' or 'less' commands because for source codes, vi shows syntax highlight.

for i in `find . | grep jar$`; do echo $i; jar tvf $i | grep 'search-string'; done;