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





Maintained by Jon H.

Site originally by David Winterbottom (user root).

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

All commands from sorted by
Terminal - All commands - 12,388 results
sed G
2009-05-02 12:11:40
Functions: sed

G option cause a file to be spacing line by line.

mencoder -oac copy -ovc copy part1.avi part2.avi part3.avi -o full_movie.avi
2009-05-02 07:44:32
User: pyrho

Using mplayer's mencoder, you can merge video files together.

'-oac' specifies the audio encoding (here copy, to just copy and not compress)

'-ovc' specifies the video encoding (same thing).

symlinks -r $(pwd)
2009-05-01 23:33:10
User: kFiddle
Tags: symlinks links

The symlinks command can show status of all symbolic links, including which links are dangling, which symlinks point to files on other file systems, which symlinks use ../ more than necessary, which symlinks are messy (e.g. having too many slashes or dots), etc. Other useful things it can do include removing all dangling links (-d) and converting absolute links to relative links (-c). The path given must be an absolute path (which is why I used $(pwd) in the example command).

gdb command: apropos <keyword>
2009-05-01 23:19:35
User: kFiddle
Functions: apropos gdb
Tags: gdb apropos help

Most of you are probably familiar with the "apropos" command for searching man pages. However, did you know there's a similar command inside of gdb? If, for example, you wanted to know all gdb commands that related to threads, you could type "apropos thread". Type "help some_command" to receive more information about a command. Type "help" by itself to see a list of help topics.

tar cvzf - data1 data2 | uuencode data.tar.gz | mail -s 'data' you@host.fr
2009-05-01 23:13:08
User: log0
Functions: mail tar uuencode

An easy one but nice to keep in mind.

wodim cdimage.iso
2009-05-01 21:53:27

Does life get much easier? Read up about wodim for an understanding of its origins in relation to the older `cdrecord` utility

cd $(dirname $(find ~ -name emails.txt))
2009-05-01 21:26:58
User: haivu
Functions: cd dirname find
Tags: bash dirname

This command looks for a single file named emails.txt which is located somewhere in my home directory and cd to that directory. This command is especially helpful when the file is burried deep in the directory structure. I tested it against the bash shells in Xubuntu 8.10 and Mac OS X Leopard 10.5.6

mencoder your_video.flv -oac mp3lame -ovc xvid -lameopts preset=standard:fast -xvidencopts pass=1 -o your_video.avi
pr -l 40 bitree.c > printcode; split -40 printcode -d page_
perm=( 6 4 4 ) ; for elem in ${perm[@]}; do echo `expr 7 - $elem` ; done
2009-05-01 12:08:19
Functions: echo

Umask is obtained subtracting 7 from each cypher of octal format. I store octal perm format in an array,then for each element of array I subtract 7. The result is the umask.

cd /mnt/old && tar cvf - . | ( cd /mnt/new && tar xvf - )
cat /etc/psa/.psa.shadow
2009-04-30 18:08:12
User: jigglebilly
Functions: cat

I'm sure almost everybody knows this by now. This command will pull the password for the admin login of any plesk machine.

sftp -oPort=3476 user@host
2009-04-30 16:48:38
Functions: sftp

I use this for connect via sftp to a server listening on a non default ssh port.

python -c "import socket; print '\n'.join(socket.gethostbyname_ex(socket.gethostname())[2])"
2009-04-30 16:10:43
User: haivu
Functions: python
Tags: Network python

The socket.gethostname() call returns the host name of the computer. The socket.gethostbyname_ex() call returns a list of three items: The host name, the list of aliases for this host, and a list of IP addresses. Recall that Python?s array starts with index 0, the socket.gethostbyname_ex(?)[2] expression refers to the list of IP addresses. Finally, the print statement prints out the IP addresses, one per line.

sudo shred -zn10 /dev/sda
2009-04-30 13:02:43
User: dcabanis
Functions: shred sudo

Shred can be used to shred a given partition or an complete disk. This should insure that not data is left on your disk

p=$(netstat -nate 2>/dev/null | awk '/LISTEN/ {gsub (/.*:/, "", $4); if ($4 == "4444") {print $8}}'); for i in $(ls /proc/|grep "^[1-9]"); do [[ $(ls -l /proc/$i/fd/|grep socket|sed -e 's|.*\[\(.*\)\]|\1|'|grep $p) ]] && cat /proc/$i/cmdline && echo; done
2009-04-30 12:39:48
User: j0rn
Functions: awk cat grep ls netstat sed

Ok so it's rellay useless line and I sorry for that, furthermore that's nothing optimized at all...

At the beginning I didn't managed by using netstat -p to print out which process was handling that open port 4444, I realize at the end I was not root and security restrictions applied ;p

It's nevertheless a (good ?) way to see how ps(tree) works, as it acts exactly the same way by reading in /proc

So for a specific port, this line returns the calling command line of every thread that handle the associated socket

ifstat -nt
2009-04-30 11:38:31

ifstat, part of ifstat package, is a tool for displaying bandwidth and other statistics. The -n option avoid to display header periodically, the -t option put a timestamp at the beginning of the line.

Works for me on Debian and CentOS

while :; do xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "$(find <image-directory> -type f -iregex '.*\.\(bmp\|gif\|jpg\|png\)$' | sort -R | head -1)"; sleep 30m; done
2009-04-30 03:09:52
Functions: sleep
Tags: bash find xfce

Change your wallpaper every thirty minutes (or however long you like, I suppose) to a randomly selected image in a directory and subdirectories. Bear in mind this is not safe to use if anyone else has write access to your image directory.

sudo vol_id -u /dev/sda1
2009-04-30 01:40:58
User: agentk
Functions: sudo

Shows the UUID of a filesystem or partition that can be used in kernel root options and in fstab.

Run it without the -u option to generate more information. eg:

~/ sudo vol_id /dev/sda2








xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s <image-file>
2009-04-30 01:40:52
Tags: xfce

Simply changes the wallpaper of xfce4 from the command line. Not for multiple displays.

w | egrep -v '(load|FROM)' | awk '{print $2}' | sed 's/^/tty/' | awk '{print "echo \"The Matrix has you...\" >> /dev/" $1}' | bash
2009-04-29 22:04:56
User: copremesis
Functions: awk egrep sed

This works just like write or wall ... cept one thing the sender is anonymous ... if you really want to drive everyone insane replace echo \"The Matrix has you...\" with cat /dev/urandom

nice one to do on April fool's day

mkdir `date | sed 's/[: ]/_/g'`
2009-04-29 21:28:45
User: copremesis
Functions: mkdir sed

use today's time stamp to make a unique directory for today or an hour ago ...

shopt -s histappend
2009-04-29 19:49:53

If histappend options is set in bash, the file .bash_history will not be overwrite and history list is append to it.

touch /etc/nologin
2009-04-29 19:43:14
User: udim
Functions: touch
Tags: login

Also with optional message:

echo "no login for you" > /etc/nologin

(This doesn't affect your current X session - you're already logged in!)

2009-04-29 19:08:37

pinfo package provide a nice info alternative based on ncurses.