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

Commands by nottings from sorted by
Terminal - Commands by nottings - 13 results
tr -dc A-Za-z0-9_ < /dev/urandom | head -c 10 | xargs
echo "export LESS='FiX'" >> ~/.bashrc
2010-11-08 21:58:25
User: nottings
Functions: echo
7

stop man page content from disappearing on exit

echo "export LESS='FiX'" >> ~/.bashrc

man bash

'q'uit out of man page

content will stay on screen

echo ${PIPESTATUS[@]}
ls |tee >(grep xxx |wc >xxx.count) >(grep yyy |wc >yyy.count) |grep zzz |wc >zzz.count
ps -o lstart <pid>
bash -x ./post_to_commandlinefu.sh
ctrl + \
2009-02-25 18:52:57
User: nottings
7

useful for loops like for i in $(cat list_of_servers); do ssh -q $i hostname; done

if there is an unreachable server, you can just press ctrl + \ to skip that server and continue on with the loop

x11vnc -display :0 -auth $(ps -ef|awk '/xauth/ {print $15}'|head -1) -forever -bg &
2009-02-19 18:55:54
User: nottings
Functions: ps
4

the $15 may change for you depending on your distro, etc...

while read line; do echo "$(date),$(hostname),$line"; done < somefile.txt
set -o vi
egrep '^[^#]' some_file
for i in $(cat listofservers.txt); do konsole --new-tab -e ssh $i; done
2009-02-19 16:32:36
User: nottings
Functions: cat ssh
4

creates a new tab for each of N servers in listofservers.txt and ssh's to said servers

then, try the "send to all sessions" feature of konsole to do the same work on all servers at the same time. BIG time saver, but be careful!

ex some_file "+set ff=unix fileencoding=utf-8" "+x"
2009-02-19 16:23:21
User: nottings
Functions: ex
5

converts encoding of a file to unix utf-8

useful for data files that contain what would be usable ascii text but are encoded as mpeg or some other encoding that prevents you from doing common manipulations like 'sed'