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 oernii2 from sorted by
Terminal - Commands by oernii2 - 13 results
export DISPLAY=$(tr '\000' '\n' < /proc/`pidof Xorg`/cmdline | egrep '^:[0-9]+')
2012-12-18 07:26:16
User: oernii2
Functions: egrep export tr
-2

Not always does Xorg run on :0. For times like those, this script allows you to find out which it is.

alias html2ascii='lynx -force_html -stdin -dump -nolist'
delay until 16 && import_db.sh
2012-03-01 12:38:32
User: oernii2
1

the "delay" utility is an invaluable tool for me. with gnu-screen it allows you to schedule something and have it run and output to the current terminal, unlike "at".

You can also use it like "sleep" with seconds and also with date:

delay until 13:33 friday && echo test

get it from: http://onegeek.org/~tom/software/delay/current/delay.c

(author: Tom Rothamel)

function xzv() { THREADS=`grep processor /proc/cpuinfo | wc -l`; for file in $*; do pv -s `stat -c%s $file` < $file | pxz -q -T $THREADS > $file.xz ; done; }
2011-12-14 08:22:08
User: oernii2
Functions: file wc
0

You need: pxz for the actual work (http://jnovy.fedorapeople.org/pxz/). The function could be better with better multifile and stdin/out support.

lvs | awk '{printf("/dev/%- 40s %-7s %10s %20s %6s %5s %5s %5s %5s\n", $2 "/" $1, $3, $4, $5, $6, $7, $8, $9, $10)}'
strace -ff -e trace=write -e write=1,2 -p SOME_PID
ssh -o UserKnownHostsFile=/dev/null root@192.168.1.1
2010-04-08 14:55:58
User: oernii2
Functions: ssh
Tags: ssh
8

you may create an alias also, which I did ;-)

alias sshu="ssh -o UserKnownHostsFile=/dev/null "

while :;do killall -USR1 dd;sleep 1;done
2010-04-07 09:23:31
User: oernii2
Functions: killall
Tags: dd progress speed
9

every 1sec sends DD the USR1 signal which causes DD to print its progress.

dd if=/dev/nst0 |pv|dd of=restored_file.tar
2010-04-07 09:21:18
User: oernii2
Functions: dd
8

piping through 'pv' shows a simple progress/speed bar for dd. This is a replacement for my otherwise favorite 'while :;do killall -USR1 dd;sleep 1;done'

watch -n1 snmptable -v2c -c public localhost diskIOTable
2010-03-19 11:31:52
User: oernii2
Functions: watch
4

Show a simple table with disk IO for the specified host. you monitor a LOT of different thing. Mostly used for MRTG and similar, but this is nice for a quick look, which disk is busy.

"public" is your SNMP community

ensure that snmpd is running on the host which you intend to monitor

env PS4=' ${BASH_SOURCE}:${LINENO}(${FUNCNAME[0]}) ' sh -x /etc/profile
for kern in $(grep "initrd " /boot/grub/grub.conf|grep -v ^#|cut -f 2- -d-|sed -e 's/\.img//g'); do mkinitrd -v -f /boot/initrd-$kern.img $kern; done
runas /user:administrator net stop wuauserv
2009-06-30 09:29:03
User: oernii2
4

Windows only: stops windows update and the nagging restart window.

You need your admin password for this one.