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.

Universal configuration monitoring and system of record for IT.
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

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

Top Tags

Hide

Functions

Hide

Credits

All commands from sorted by
Terminal - All commands - 12,134 results
service mysqld restart
2013-12-18 19:13:56
User: denni
-4

This command restarts mysql service.

ls -Sl * | head
2009-03-27 23:20:32
User: colinpj
Functions: ls
-4

head by default displays first ten lines of its output. Use 'head -nXX' to display the XX largest files

echo 'mkcd() { mkdir -p "$@" && cd "$_"; }' >> ~/.bashrc
2010-01-13 09:37:56
User: phaidros
Functions: cd echo mkdir
-4

combines mkdir and cd

added quotes around $_, thanx to flatcap!

nc -w 5 -v -l -p 80 < file.ext
/etc/rc.d/init.d/ntpd start
2013-12-18 20:49:42
User: denni
-4

This command starts up the time synchronization service.

sudo chmod -R g=u-w,g+X *
echo 'example' | sed -e 's/^\(.\)/\U\1/'
ls | xargs du -sh
find . -type d | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
2013-07-16 10:08:34
User: opexxx
Functions: find sed
Tags: sed find
-4

show directory three

help builtin
rm -rf `find -maxdepth 1 -mindepth 1 -mtime +7`
2009-05-22 11:46:57
User: tatwright
Functions: rm
-4

This is useful for command line 'recycle bins' and such like

seq -w 100 | sed 's/^/login/'
2009-10-15 13:56:56
User: lawrence
Functions: sed seq
-4

This command generates a sequential login list. Good to be used as a source of new logins.

dpkg-reconfigure -phigh xserver-xorg
cat .ssh/id_rsa.pub | ssh user@server 'cat >> ~/.ssh/authorized_keys2'
2012-07-12 15:42:10
User: er0k
Functions: cat ssh
-4

for passwordless login

alias trash="rm -fr ~/.local/share/Trash"
2009-02-27 01:55:30
Functions: alias
-4

Force empties the user trash

# indicates a comment in shell
2009-03-16 23:15:33
User: mpb
-4
#

Using the "#" in shell is surprisingly useful.

Some of the uses I found:

a) As a visible copy buffer in shell history (caveat: do not use for passwords :-)

b) To build complex commands until ready then hit the HOME, DEL, ENTER keys to run it

c) Placing reference data into shell history (search for tags with CTRL-R TAGNAME)

d) Putting aside a "work in progress" command to focus on another task (HOME # ENTER)

sudo apt-get remove --purge `dpkg -l | awk '{print $2}' | grep gnome` && apt-get autoremove
2009-04-28 10:34:42
User: kelevra
Functions: awk grep sudo
Tags: awk apt-get dpkg
-4

Useful for removes a package and its depends, for example to remove the gnome desktop environment, also configuration files will be removed, you should be carefully and sure that you want to do this.

watch "df | grep /this/folder/"
echo "" > .bash_history
which <command> > /dev/null 2>&1 && echo Success!
2013-03-13 10:04:42
User: skkzsh
Functions: echo which
Tags: which
-4

or

which <command> > /dev/null 2>&1 || echo Error!

For example, I write

which colordiff > /dev/null 2>&1 && alias diff=colordiff

in my `~/.bashrc`.

perl -p -i -e ?s/New/Old/g? *.html
2009-11-16 13:40:13
User: chappado
Functions: perl
-4

-p -> loop (same as -n in sed)

-i -> edit files

-e -> execute command

replace Old with New in all *.html files

dd if=/dev/zero of=/tmp/bigfile bs=1024k count=100
curl -s http://www.google.com/ig/api?weather=$(curl -s "http://api.hostip.info/get_html.php?ip=$(curl -s icanhazip.com)" | grep City | sed 's/City: \(.*\)/\1/' | sed 's/ /%20/g' | sed "s/'/%27/g") | sed 's|.*<temp_f data="\([^"]*\)"/>.*|\1\n|'
ping -qc 10 server.tld | awk -F/ '/^rtt/ {print $5}'
2011-10-12 21:07:06
User: atoponce
Functions: awk ping
Tags: awk ping
-4

Quick and dirty one-liner to get the average ping(1) time from a server.

man !!
2010-09-24 13:38:17
User: pahnin
Functions: man
-4

when we work with terminal often we open man pages for help if we did some mistakes

and when we want to open the man page for command we are working with this one helps

as many people may be knowing that '!!' performs the last command action

we use it in sudo !! to perform the last action with root previleages

man !! will also be helpful and handy

thanx