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



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,412 results
awk '{print $1}' /var/log/httpd/access_log | sort | uniq -c | sort -rnk1 | head -n 10
httpd -S
*/15 * * * * /path/to/command
2009-08-30 14:53:08
User: sharfah

Instead of using:

0,15,30,45 * * * * /path/to/command

2009-08-30 14:41:16
User: linuxswords

for mousevents, move the mouse over the window and click/move etc.

usefull for getting mouseKeys, or keyKeys. also usefull for checking if X gets those mouse-events.

wget --reject html,htm --accept pdf,zip -rl1 url
2009-08-30 14:05:09
User: linuxswords
Functions: wget

If the site uses https, use:

wget --reject html,htm --accept pdf,zip -rl1 --no-check-certificate https-url
gpg --search-keys
mpg123 -s input.mp3 | faac -b 80 -P -X -w -o output.m4b -
2009-08-30 13:15:37
User: linuxswords
Functions: mpg123

to convert a whole directory, put all mp3 files in a for loop

for i in $(ls *mp3); do mpg123 -s $i | faac -b 80 -P -X -w -o ${i%mp3}m4b -; done
rkhunter --check
2009-08-30 12:53:33
User: unixbhaskar
Tags: Security shell

rkhunter (Rootkit Hunter) is a Unix-based tool that scans for rootkits, backdoors and possible local exploits. rkhunter is a shell script which carries out various checks on the local system to try and detect known rootkits and malware. It also performs checks to see if commands have been modified, if the system startup files have been modified, and various checks on the network interfaces, including checks for listening applications.

chkrootkit -x | less
curl -s http://tinyurl.com/create.php?url=http://<website.url>/ | sed -n 's/.*\(http:\/\/tinyurl.com\/[a-z0-9][a-z0-9]*\).*/\1/p' | uniq
xmms2 pause && echo "xmms2 play" | at now +5min
2009-08-30 04:35:10
User: Vrekk
Functions: at echo

you can also run "xmms2 pause & at now +5min

ZIP=48104; curl http://thefuckingweather.com/?zipcode=$ZIP 2>/dev/null|grep -A1 'div class="large"'|tr '\n' ' '|sed 's/^.*"large" >\(..\)/\1/;s/&d.* <br \/>/ - /;s/<br \/>//;s/<\/div.*$//'
2009-08-29 19:33:35
User: sleepynate
Functions: grep sed tr

grab the weather, with a little expletive fun. replace the 48104 with a US zipcode, or the name of your city (such as ZIP="oslo"), unless you want to know what the weather is like for me (and that's fine too)

httpd2 -V
ip addr show
2009-08-29 12:52:02
User: unixbhaskar
Tags: Network shell

Like many other thing in Linux ,you can see the same thing in different way.

httpd2 -M
2009-08-29 12:19:34
User: unixbhaskar
Tags: web browser

You can try it . Nice shell interface to search google from the command line.Visit http://goosh.org in your browser.

2009-08-29 12:08:30
User: unixbhaskar
Functions: last
Tags: login shell

This command will reveal login has been made to the system as well as when the reboot occurs. It uses a file called /var/log/wtmp,which captures all the information about the successful login and reboot information. It has many switch ,by which you can get an idea when people login how long they stay.

while read server; do ssh -n user@$server "command"; done < servers.txt
2009-08-29 06:52:34
User: sharfah
Functions: read ssh

The important thing to note in this command, is the "-n" flag.

nikto.pl -h yourwebserver
2009-08-29 04:54:43
User: unixbhaskar
Tags: Security shell

This is wonderful perl script to check the web server security and vulnerability .Get it from here :http://www.cirt.net/nikto2

Here are some key features of "Nikto":

? Uses rfp's LibWhisker as a base for all network funtionality

? Main scan database in CSV format for easy updates

? Determines "OK" vs "NOT FOUND" responses for each server, if possible

? Determines CGI directories for each server, if possible

? Switch HTTP versions as needed so that the server understands requests properly

? SSL Support (Unix with OpenSSL or maybe Windows with ActiveState's Perl/NetSSL)

? Output to file in plain text, HTML or CSV

? Generic and "server type" specific checks

? Plugin support (standard PERL)

? Checks for outdated server software

? Proxy support (with authentication)

? Host authentication (Basic)

? Watches for "bogus" OK responses

? Attempts to perform educated guesses for Authentication realms

? Captures/prints any Cookies received

? Mutate mode to "go fishing" on web servers for odd items

? Builds Mutate checks based on robots.txt entries (if present)

? Scan multiple ports on a target to find web servers (can integrate nmap for speed, if available)

? Multiple IDS evasion techniques

? Users can add a custom scan database

? Supports automatic code/check updates (with web access)

? Multiple host/port scanning (scan list files)

? Username guessing plugin via the cgiwrap program and Apache ~user methods

firefox --safe-mode
2009-08-29 04:36:19
User: unixbhaskar

Sometime you need to run firefox from the command just to rectify something about it.Means,if some of the addon broke you firefox setting or theme broke your ff setting then fall back to commandline i.e shell and type the mentioned command. It will open up an information box with few option along with the checkbox besides them(means you can select them) to start the web browser in safe mode.Besically deactivating all the addon and theme,except the default one.Once you are done/rectified thing ..close that session and reopen the browser normally.It should work.

ssh [email protected] [anycommand](i.e uptime,w)
2009-08-29 04:27:37
User: unixbhaskar
Functions: ssh
Tags: ssh shell

Once it is connected to the remote server by that ssh protocol,the mentioned command will start working on that server.

2009-08-29 04:06:11
User: unixbhaskar
Tags: Security shell

If you follow my other posting regarding "vipw" and "vigr' then no explanation required.It has done the same thing as did with those two command.Open the /etc/sudoers file and attach a lock with it. Once you are done with it ,the lock gets released and the changes reflected to the original file.It will open a tmp file in vi editor to give you the chance to edit the sudoers file securely.visudo parses the sudoers file after the edit and will not save the changes if there is a syntax error. Upon finding an error, visudo will print a message stating the line number(s) where the error occurred and the user will receive the "What now?" prompt. At this point the user may enter "e" to re-edit the sudoers file, "x" to exit without saving the changes, or "Q" to quit and save changes. The "Q" option should be used with extreme care because if visudo believes there to be a parse error, so will sudo and no one will be able to sudo again until the error is fixed. If "e" is typed to edit the sudoers file after a parse error has been detected, the cursor will be placed on the line where the error occurred (if the editor supports this feature).

PS: Although I have had experienced myself and few people shown to me that it behaves badly in some distribution ,noteably SLES.But the problem can be rectified with little caution.

2009-08-29 03:56:07
User: unixbhaskar
Tags: Security shell

If you follow my previous posting regarding "vipw" then no explanation required.The same method goes behind this command also.It will open an tmp file in vi editor to give you the enlisting to edit the group file.And most importantly to attach a lock with it.Once you are done ,the lock is released and the changed reflected to the original file.So you can securely edit the group file over the network without the fear of being tampered .

2009-08-29 03:46:42
User: unixbhaskar
Tags: Security shell

Now a bit of explanation required for this command.Once you type the command it opens up an vi editor with an temporary file enlisting the password file information .So if you make an change it will not reflected in the passwd file until you save the file.The reason behind using this command over other way to view the password file in network environment is that it locks the password file when you start working with it.So no one can temper with it during that period.Once you are done(means you save the tmp file) ,it will release the lock associated with it.I think it's a better mechanism to view the sensitive data like passwd file.Never ever use other tool like cat, nano or any other means.