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

All commands from sorted by
Terminal - All commands - 12,380 results
less +G <filename>
2009-03-02 23:34:21
User: leper421
Functions: less

The same as typing 'less filename' then 'G' or '>' or the END key. Comes in handy with shell scripts or aliases:

alias weblog='less +G /var/log/httpd/access_log'

alias errlog='less +G /var/log/httpd/error_log'

ifconfig -a | nawk 'BEGIN {FS=" "}{RS="\n"}{ if($1~ /:/) {printf "%s ", $1}}{ if($1=="inet") {print " -- ",system("arp "$2)}}'|egrep -v "^[0-9]$"
2009-03-02 23:15:13
User: leprasmurf
Functions: ifconfig

Needed to get the Mac of various devices on a solaris box, but didn't have root. This command used awk to display the Network device, the IP, and the MAC a line at a time.

:set ic
ssh -T [email protected] /bin/bash -i
2009-03-02 21:39:30
User: Bender
Functions: ssh

opens a "hidden" remote shell (login will not appear in "last" for example).

This is not really hidden, because the login will be shown in auth.log and the process is visible anyways.

ssh -T = Disable pseudo-tty allocation.

bash -i = interactive shell

awk -F "=| "
2009-03-02 21:09:51
User: Bender
Functions: awk cat file

You can use multiple field separators by separating them with | (=or).

This may be helpful when you want to split a string by two separators for example.

#echo "one=two three" | awk -F "=| " {'print $1, $3'}

one three

alias vb='vim ~/.bashrc; source ~/.bashrc'
2009-03-02 21:01:49
User: haivu
Functions: alias col groff man

Place the line above in your ~/.bahsrc file. Now every time you issue the 'vb' command, you invoke the vim editor to edit it, then source it so the changes take effect immediately.


* This mechanism is not working well if your .bashrc contains commands that should not be sourced more than once.

* This trick also work for your csh or tclsh users: place the following line in your ~/.cshrc file:

alias vc 'vim ~/.cshrc; source ~/.cshrc

Thank you adzap for pointing out the missing quote

:n,m w newfile.txt
2009-03-02 19:40:34
User: milmazz
Tags: vim perl

On command mode in Vim you can save parts of the current buffer in another file.

* The 'n' value represents the first line of the new file.

* The 'm' value represents the last line of the new file.

* newfile.txt is the newfile.

The results are similar to this command in perl:

perl -ne 'print if n..m' in.sql > out.sql
2009-03-02 19:03:07
User: Pistos

Immediately after installing things into your PATH (e.g. under /usr/bin), currently open shells cannot find them ("zsh: command not found"). Use rehash to get the shell to rescan available executables.

sudo find / -type f \( -perm /4000 -a -user root \) -ls -o \( -perm /2000 -a -group root \) -ls
2009-03-02 18:48:17
User: atoponce
Functions: find sudo

Discovering all executables on your system that can be run as another user, especially root, is critical for system security. The above command will find those files with have SUID or SGID bits set and are owned by the root user or group.

du -cs * .[^\.]* | sort -n
2009-03-02 18:43:48
User: cemsbr
Functions: du sort

Very useful when you need disk space. It calculates the disk usage of all files and dirs (descending them) located at the current directory (including hidden ones). Then sort puts them in order.

cat /dev/zero > /dev/null &
2009-03-02 18:18:52
User: gustavold
Functions: cat

Just waste some resources in a philosophical way

find <top_level_dir> -depth -type d -empty -exec rmdir -v {} \;
find -type -f -exec cp {} {}.bak \;
nc -l -p 2000 -e /bin/bash
2009-03-02 15:58:25
User: prayer
Tags: Network netcat

To connect to the shell run:

nc server.example.org 2000
nc -l -p 2000 < song.mp3
2009-03-02 14:55:56
User: raphink
Tags: man

Launch a command from within a manpage, vim style. This is rather trivial, but can be very useful to try out the functions described in a manpage without actually quitting it (or switching to another console/screen/...).

rm file{1..10}
2009-03-02 14:42:05
User: atoponce
Functions: rm

Rather than typing out all 10 files, you can use brace expansion to do the trick for you. This is useful for backup files, numbered files, or any files with a repeating pattern. Gives more control than 'rm file*' as I might want to keep others around.

yum localinstall /path/to/package.rpm
2009-03-02 14:32:23
User: atoponce

When downloading RPMs from the Internet, you don't have to 'rpm -i' or 'rpm -U' to install the package. Especially, if the package has dependencies. If you have YUM setup to access an RPM repository, this command will install the downloaded package, then any dependencies through YUM that it relies on. Very handy on RPM-based systems.

tail -n 0 -f /var/log/messages
2009-03-02 14:21:18
User: atoponce
Functions: tail

In this case, I'm keeping an eye on /var/log/messages, but of course any file will do. When I'm following a file, I generally don't want to see anything other than what has been added due to the command or service I've executed. This keeps everything clean and tidy for troubleshooting.

tail -f file1 (file2 .. fileN)
2009-03-02 11:13:42
User: hberth
Functions: tail
Tags: bash Ubuntu

Useful to e.g. keep an eye on several logfiles.

tail -n 15 /var/log/yum.log | tac
2009-03-02 08:56:04
User: alcik
Functions: tail
Tags: yum tail

It displays, last 15 yum operations (in last operation as first row order) with its dates. Change 15 to any number of operations you need to display or remove "| tac" to see it in reverse order (last operation as last row)

vlc $(curl -s http://twitter.com/statuses/user_timeline/18855500.rss|grep play|sed -ne '/<title>/s/^.*\(http.*\)<\/title/\1/gp'|awk '{print $1}')
2009-03-02 05:36:19
User: tomwsmf
Tags: twitter

This will play the audio goodness posted up on PlayTweets via twitter right form the ever loving cmdline. You do not even need a twitter account. I hashed this out in a bit of a hurray as the kids need to get to sleep....I will be adding a loop based feature that will play new items as they come in...after what your are listening to is over.

http://twitter.com/playTweets for more info on playtweets

sar -u 2 5
2009-03-02 04:54:37
User: rockon

Generated the CPU utilization stats with 5 lines /every 2 seconds.

Needs sysstat package to be installed prior to use sar.

lsof +p xxxx