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.

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





All commands from sorted by
Terminal - All commands - 12,273 results
pinky -l <username>
2009-03-01 10:17:08
User: rockon
Functions: pinky

Gives information about user's home directory and real name and shell user is having.

hdparm -i[I] /dev/sda
2009-03-01 10:00:28
User: rockon
Functions: hdparm

Get the hard disk information with out shutting down and opening the system.

It gives information on model no., serial no., cylinders/heads/sectors, and the supported features of the hard disk.

lsb-release -a
2009-03-01 09:42:52
User: rockon

To know the OS distro and version, release.

Is same like /etc/redhat-release

join file1.txt file2.txt > file3.txt
cat file1.txt | uniq > file2.txt
find . |more |grep -v filename |xargs rm
wrestool -x --output . -t14 /path/to/your-file.exe
taskset -c 0 your_command
2009-02-28 22:38:02
User: Alanceil
Functions: taskset

This is useful if you have a program which doesn't work well with multicore CPUs. With taskset you can set its CPU affinity to run on only one core.

mplayer -dumpstream -dumpfile "yourfile" -playlist "URL"
2009-02-28 22:18:17
User: Alanceil

I use this command to save RTSP video streams over night from one of our national TV stations, so I won't have to squeeze the data through my slow internet connection when I want to watch it the next day.

For ease of use, you might want to put this in a file:


FILE="`basename \"$1\"`"

mplayer -dumpstream -dumpfile "$FILE" -playlist "$1"

alias calc 'echo "scale=4;\!*"|bc -l'; alias xcalc 'echo "\!*"|bc -l'
2009-02-28 21:30:59
User: boomer_tn
Functions: alias

allows simple C shell access to the power of bc - never could figure out how to do the same thing with Bash - that's why I use tcsh most of the time.

find -name '*wma' -exec ffmpeg -i {} -acodec vorbis -ab 128k {}.ogg \;
export IFS=$'\n';for dir in $( ls -l | grep ^d | cut -c 52-);do du -sh $dir; done
dpkg --compare-versions 1.0-2ubuntu5 lt 1.1-1~raphink3 && echo y || echo n
2009-02-28 18:01:59
User: raphink
Functions: echo
Tags: Debian Ubuntu

Compares two versions with dpkg. It is not always obvious what version dpkg/apt will consider to be more recent. Operators include the following :

* These treat an empty version as earlier than any version: lt le eq ne ge gt.

* These treat an empty version as later than any version: lt-nl le-nl ge-nl gt-nl.

* These are provided only for compatibility with control file syntax: < > >.

This command doesn't output anything. It only returns with status 0 or 1, hence the echo "y" || echo "n" to get an output.

ps axww | grep SomeCommand | awk '{ print $1 }' | xargs kill
2009-02-28 17:48:51
User: philiph
Functions: awk grep ps xargs

This command kills all processes with 'SomeCommand' in the process name. There are other more elegant ways to extract the process names from ps but they are hard to remember and not portable across platforms. Use this command with caution as you could accidentally kill other matching processes!

xargs is particularly handy in this case because it makes it easy to feed the process IDs to kill and it also ensures that you don't try to feed too many PIDs to kill at once and overflow the command-line buffer.

Note that if you are attempting to kill many thousands of runaway processes at once you should use 'kill -9'. Otherwise the system will try to bring each process into memory before killing it and you could run out of memory. Typically when you want to kill many processes at once it is because you are already in a low memory situation so if you don't 'kill -9' you will make things worse

:rm 1
find $HOME -type f -print | perl -wnlaF'/' -e 'BEGIN{ print "#EXTM3U"; } /.+\.wmv$|.+\.mpg$|.+\.vob$/i and print "#EXTINF:$F[-1]\nfile://$&";' > movies.m3u
svn status | grep '^\?' | sed -e 's/^\?//g' | xargs svn add
2009-02-28 03:00:28
User: dollyaswin
Functions: grep sed xargs

These part of the command:

svn status | grep '^\?' => find new file or directory on working copy

sed -e 's/^\?//g' => remove "^" character on the first character of file name

xargs svn add => add file to subversion repository

You can modify above command to other circumtances, like revert addition files or commit files that have been modified. ^_^

e2label /dev/vg0/lv0 MyFiles
v=/dev/vg0/lv0; lvextend -L+200G $v && resize2fs $v
2009-02-28 02:30:49
User: wwest4
Functions: resize2fs

Live extension of an ext3 file system on logical volume $v by 200GB without the need to unmount/remount.

Requires that you have 1) a version of resize2fs that contains code merged from ext2online, and 2) kernel support for online resizing. (e.g. RHEL 5)

pkill -n firefox
2009-02-28 01:19:59
User: Williebee

Kills the most recently created firefox process.

aptitude show $PROGRAM | grep Vers
2009-02-27 23:24:37
User: aabilio
Functions: grep

Output: Version 3.2-0 (for example if you type # aptitude show bash | grep Vers

Depends on the language of your distribution, because the name of the word "Version" in other languages may be different.

sudo dd if=/dev/sda of=/media/disk/backup/sda.backup
2009-02-27 20:23:37
User: bandit36
Functions: dd sudo
Tags: backup dd

This will create an exact duplicate image of your hard drive that you can then restore by simply reversing the "if" & "of" locations.

sudo dd if=/media/disk/backup/sda.backup of=/dev/sda

Alternatively, you can use an SSH connection to do your backups:

dd if=/dev/sda | ssh user@ssh.server.com dd of=~/backup/sda.backup
rsync -vazuK --exclude "*.mp3" --exclude "*.svn*" * user@host:/path
2009-02-27 19:58:02
User: sudopeople
Functions: rsync
Tags: svn exclude

rsyncs files to a server excluding listed files

also a file can be used to exclude common exclude rules and/or to exclude a ton of files, like so:

rsync --exclude-from '~/.scripts/exclude.txt'

where exclude.txt has one rule per line:



write user anytext
ifconfig | awk '/inet / {print $2}'
2009-02-27 17:05:08
User: haivu
Functions: awk ifconfig

On the Mac, the format ifconfig puts out is little different from Linux: the IP address is space separated, instead of colon. That makes parsing the IP address easier. See releated command for Linux/Unix: