Hide

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.

Hide

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:

Hide

News

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.
Hide

Tags

Hide

Functions

All commands from sorted by
Terminal - All commands - 11,856 results
test `uname` = Linux && lsb_release -a || ( test `uname` = SunOS && cat /etc/release || uname -rms )
2009-07-07 20:51:30
User: virtualshock
Functions: cat test uname
-7

Found in comments section works on most Linux flavors.

echo 0 >/selinux/enforce
2010-02-17 16:33:26
User: svnlabs
Functions: echo
-7

just change SELINUX=enforcing to SELINUX=permissive, and you're done. Reboot if you want to prove it.

savesIFS=$IFS;IFS=$(echo -en "\n\b"); for items in `ls *.7z`; do 7zr e $items ; done; IFS=$saveIFS
uname -a
last reboot
ps aux | grep -i firefox | grep -v grep | awk '{print $2}' | xargs -t -i kill -9 {}
2009-02-19 18:50:00
User: blackdude
Functions: awk grep kill ps xargs
-7

This is a nice way to kill processes.. the example here is for firefox!!! substitute firefox for whatever the process name is...

curl -s -u user:password http://twitter.com/statuses/friends_timeline.rss | grep title | sed -ne 's/<\/*title>//gp' | head -n 4 | say -v Bruce
2009-03-20 20:14:13
User: sixtus
Functions: grep head sed
-7

You need curl.. and a Mac of course.

zcat /usr/share/man/man1/grep.1.gz | grep "color"
2009-02-04 09:38:45
User: root
Functions: grep zcat
-7

This decompresses the file and sends the output to STDOUT so it can be grepped. A good one to put in loops for searching directories of gzipped files, such as man pages.

nslookup {ip}
sudo dpkg -i packagename.deb
2009-09-25 09:54:04
User: bkn390
Functions: sudo
-7

Install a deb package you have downloaded (synaptic has to be closed).

(dpkg-dev needs to be installed)

After that you may have to run following:

sudo apt-get install -f

(that should fix any dependency problems)

I am using ubuntu linux

Dir=dirname; mkdir $Dir && cd $Dir
2011-04-06 14:53:57
User: saibbot
Functions: cd mkdir
Tags: cd mkdir
-7

Create a directory called "dirname" and navigate into it.

function command_not_found_handle(){ apt-get install $( apt-file search "$1" | grep bin | grep -w "$1" | head -n1 | cut -d ':' -f 1 ) && $* ; }
2011-04-06 19:58:32
User: Juluan
Functions: cut grep head install
-7

Work only with bash and apt-file installed.

When it found an unknow command, it will search for a file named "scribus" (in my example), in a folder named bin and then install the corresponding package.

After installation, it will run the command.

Usefull juste after reinstalling linux and missing lot of package.

grep -v ^# file.conf | grep -v ^$ > new_file.conf
find . -type f | wc -l
watch '/home/mm/bash/keypress.sh |/home/mm/bash/evento.sh'
2009-06-07 20:57:49
User: m33600
Functions: watch
-7

evento.sh needed for awk syntax

the aplay command makes a camera sound. It takes a picture of who looked at the display

#!/bin/bash

# evento.sh: deteta evento e fala

awk '{print}' | espeak -v pt -stdin

awk '/e/{print "emergencia"}' | espeak -v pt -stdin

aplay -q /home/mm/bash/camera.wav # -q inibe verbose do comand aplay

exit 0

dir /ad /s /b
vifind() { vi `find . -name "$1"` }
dd if=/dev/zero bs=1M | ssh somesite dd of=/dev/null
help
2009-09-10 00:43:31
User: suxer
-7

for bash commands don't use man use help

find . -name "-help" -exec mv {} help.txt \;
ps auxwww | grep outofcontrolprocess | awk '{print $9}' | xargs kill -9
<Ctrl+o>
2011-08-19 00:09:53
User: bugmenot
Tags: bash hotkey
-7

Type out the command and simply press to see the list of options for that command without having to type --help.

Shift ZZ
man ettercap
2010-01-29 14:28:38
User: Abiden
Functions: man
-7

A very interesting man page!