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 wwest4 from sorted by
Terminal - Commands by wwest4 - 37 results
watch -n 5 -d cat /proc/mdstat
e2label /dev/vg0/lv0 MyFiles
v=/dev/vg0/lv0; lvextend -L+200G $v && resize2fs $v
2009-02-28 02:30:49
User: wwest4
Functions: resize2fs
4

Live extension of an ext3 file system on logical volume $v by 200GB without the need to unmount/remount.

Requires that you have 1) a version of resize2fs that contains code merged from ext2online, and 2) kernel support for online resizing. (e.g. RHEL 5)

while [ 0 ]; do echo -e "HTTP/1.1 302 Found\nLocation: http://www.whatevs.com/index.html" | nc -vvvv -l -p 80; done
2009-02-19 18:04:01
User: wwest4
Functions: echo
4

any HTTP requests to the machine on the specified port will be redirected to http://www.whatevs.com... quick, dirty, works fine for sites w/

ipconfig /flushdns
alias rk='d=$(dcop|grep $PPID) && s=$(dcop $d konsole currentSession) && dcop $d $s renameSession'
2009-02-14 00:02:43
User: wwest4
Functions: alias
1

usage: renam

in a script you must replace $PPID with $(awk '{print $4}' /prod/$PPID/stat)

while [ 0 ]; do expr 2365200000 \- `date +%s` \- `date --date "YYYY-mm-dd HH:MM:ss" +%s`; sleep 1; clear; done
2009-02-13 20:02:37
User: wwest4
Functions: expr sleep
1

watch the seconds of your life tick away - replace YYYY-mm-dd HH:MM:ss w/ your birthtime.

alias chop="tr -d '\r\n'"
2009-02-13 01:44:11
User: wwest4
Functions: alias
0

similar to perl chop()

alias mute="dcop kmix Mixer0 toggleMasterMute\(\) ; dcop kmix Mixer0 masterMute\(\) | sed -e 's/true/muted/' -e 's/false/unmuted/' "
2009-02-12 04:56:33
User: wwest4
Functions: alias
1

arguably better than using the driver interface. lots of potentially cool stuff to be done w/ the dcop client.

nmap -sP 192.168.1.100-254
2009-02-11 20:44:43
User: wwest4
15

nmap accepts a wide variety of addressing notation, multiple targets/ranges, etc.

\[command]
2009-02-11 19:34:21
User: wwest4
84

e.g. if rm is aliased for 'rm -i', you can escape the alias by prepending a backslash:

rm [file] # WILL prompt for confirmation per the alias

\rm [file] # will NOT prompt for confirmation per the default behavior of the command

rm -- --myfile
dig foo.org mx +short
jstat -gc [jvmpid]
dos2unix dostxt unixtxt
2009-02-05 21:11:43
User: wwest4
0

converts non-ISO dos text files for use on unix systems.

touch -acm yyyymmddhhMM.ss [file]
2009-02-05 21:07:09
User: wwest4
Functions: touch
0

...changes modify time and access time. also:

touch -r [file1] [file2] # make file2 timestamp match file1

ldconfig -p
2009-02-05 21:02:59
User: wwest4
Functions: ldconfig
3

shows which shared lib files are pointed to by the dynamic linker.

export SSH_AUTH_SOCK=`find /tmp/ssh* -type s -user [user] -mtime -1 | head -1`
2009-02-05 20:55:41
User: wwest4
Functions: export head
1

Must be done as root - will cause subsequent ssh connections to use the identities available via the [user]'s agent socket.

xxd < orig | sed 's/A/B/' | sed 's/HEXA/HEXB/' | xxd -r > new
2009-02-05 20:25:04
User: wwest4
Functions: sed
3

Replaces A with B in binary file "orig" and saves the result to "new". You must have the hex representations of A & B. Try od: echo -e "A\c" | od -An -x

echo -n "search> ";read QUERY && wget -O - `wget -O - -U "Mozilla/5.0" "http://images.google.com/images?q=${QUERY}" 2>/dev/null |sed -e 's/","http/\n","http/g' |awk -F \" '{print $3}' |grep -i http: |head -1` > "$QUERY"
2009-02-05 19:50:53
User: wwest4
Functions: echo wget
2

prompts for a search term and then pulls down the first result from google images

rpm --query --filesbypackage [packagename]
find $PWD -exec rpm --query -f {} \; | sort -u | grep -v "not owned"
2009-02-05 19:33:43
User: wwest4
Functions: find grep rpm sort
0

shows all RPMs with files in the current directory & its subdirectories.

find /path/to/dir -type f -mtime +[#] -exec rm -f {} \;
2009-02-05 19:24:13
User: wwest4
Functions: find rm
1

deletes logs not modified in over [#] days - modify to compress or move, as needed

dd if=/dev/zero bs=1024 count=1440 > floppy.img && mkdosfs floppy.img
2009-02-05 18:56:55
User: wwest4
Functions: dd mkdosfs
2

mount with:

mount -t msdos -o loop ./floppy.img /tmp/mnt

openssl s_client -connect [host]:[sslport] -cipher LOW
2009-02-05 18:37:50
User: wwest4
6

...if you get a certificate back, the server is accepting weak SSL ciphers