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

Commands by hemanth from sorted by
Terminal - Commands by hemanth - 21 results
calc() { bc <<< $*; }
xrandr -q | grep -w Screen
find / -type f -exec wc -c {} \; | sort -nr | head -100
sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).in-addr.arpa domain name pointer\(.*\)\./\4.\3.\2.\1\5/' \ lookups.txt
2009-08-22 09:37:20
User: hemanth
Functions: sed
Tags: sed
-1

Reverse DNS lookups, from a file with list of IP's, here the file is called lookups.txt

for i in `seq 1 255`; do ping -c 1 10.10.10.$i | tr \\n ' ' | awk '/1 received/ {print $2}'; done
2009-08-22 09:34:27
User: hemanth
Functions: awk ping tr
Tags: ping
2

Ping sweep without NMAP

for i in `cat names.txt`; do host -r $i [nameserver]; done
2009-08-22 09:26:31
User: hemanth
Functions: host
Tags: host
0

DNS cache snooping

chage -l <user>
for u in `cut -f1 -d: /etc/passwd`; do echo -n $u:; groups $u; done | sort
2009-08-22 09:06:02
User: hemanth
Functions: echo groups
Tags: sort cut for groups
3

"cut" the user names from /etc/passwd and then running a loop over them.

find . -type d -empty -delete
2009-08-22 09:03:14
User: hemanth
Functions: find
Tags: find rmdir
6

You can also use, $ find . -depth -type d -exec rmdir {} \; 2>/dev/null

echo $(( $RANDOM % 10 + 1 ))
echo init 0 | at now + 2 hours
export PS1='\D{%a %D %T}> '
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n
isoinfo -d -i filename.iso
2009-07-30 17:01:30
User: hemanth
Functions: isoinfo
3

Get details about an ISO image , without burning it or mounting it .

man -t man | ps2pdf - > man.pdf
renice 19 -p $$
recode ..HTML < file.txt > file.html
oggenc --tracknum='track' track.cdda.wav -o 'track.ogg'
cdparanoia -B
2009-07-29 07:56:12
User: hemanth
Functions: cdparanoia
-1

Rip audio tracks from CD to wav files in current dir

sudo wget -c "http://nmap.org/dist/nmap-5.00.tar.bz2" && bzip2 -cd nmap-5.00.tar.bz2 | tar xvf - && cd nmap-5.00 && ./configure && make && sudo make install
2009-07-26 11:36:53
User: hemanth
Functions: bzip2 cd make sudo tar wget
-6

Just copy and paste the code in your terminal.

Note : sudo apt-get for debian versions , change as per your requirement .

Source : www.h3manth.com

wget <URL> -O- | wget -i -