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 mnikhil from sorted by
Terminal - Commands by mnikhil - 27 results
find /var -mount -ls -xdev | /usr/bin/sort -nr +6 | more
zpool create tank /path/to/file/a /path/to/file/b
2009-05-16 10:46:17
User: mnikhil
Tags: zfs zpool
-2

This command creates an unmirrored pool using

files. While not recommended, a pool based on files can be

useful for experimental purposes.

zpool create tank mirror c0t0d0 c0t1d0 mirror c0t2d0 c0t3d0
2009-05-16 10:44:56
User: mnikhil
Tags: zfs zpool
-2

command creates a pool with two mirrors, where each mirror contains two disks.

zpool create tank raidz c0t0d0 c0t1d0 c0t2d0 c0t3d0 c0t4d0 c0t5d0
2009-05-16 10:44:05
User: mnikhil
-2

The following command creates a pool with a single raidz root vdev that consists of six disks.

gtar cpf - . | (cd /dest/directory; gtar xpf -)
2009-05-15 13:23:00
User: mnikhil
Functions: cd
Tags: gtar, gtar
1

It copies the entire current working directory to the destination directory with compression enabled.

setenv GREP_COLOR '1;37;41'
echo "Xc" | tr "Xo" "\033\017
alias grep 'gnu grep -i --color=auto'
2009-02-07 18:54:56
User: mnikhil
Functions: alias grep
1

Alias the grep command to show colored results by default.

alias nsl 'netstat -f inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail +2'
find $(pwd) -type f -exec grep -l "$(echo "\r")" {} \;
2009-02-07 18:53:00
User: mnikhil
Functions: find grep
1

its useful to run dos2unix command later on them.

find ./source -depth -print | cpio -cvo> /destination/source_data.cpio; cd /destination; cpio -icvmdI ./source_data.cpio; rm -rf ./source_data.cpio
2009-02-07 18:51:49
User: mnikhil
Functions: cd cpio find rm
0

Copy data to the destination using commands such as cpio (recommended), tar, rsync, ufsdump, or ufsrestore.

Example:

Let the source directory be /source, and let the destination directory be /destination.

# cd /source

# cd ..

# find ./source -depth -print | cpio -cvo> /destination/source_data.cpio

# cd /destination

# cpio -icvmdI ./source_data.cpio

# rm -rf ./source_data.cpio

find / -xdev -size +1024 -exec ls -al {} \; | sort -r -k 5
ls -la | awk '$3 == "oracle" || $3 == "root" {print $9}'
ls -la | awk '{print $5, " " ,$9}' | sort -rn
prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
cd /some/directory \&\& tar cf - | cd /some/directory \&\& tar xvf - */
psnup -2 file.ps | lpr
psnup -4 -pa4 -Pa4 file.ps file2.ps
now=`date +"%Y/%m/%d" -d "04/02/2005"` ; end=`date +"%Y/%m/%d" -d "07/31/2005"`; while [ "$now" != "$end" ] ; do now=`date +"%Y/%m/%d" -d "$now + 1 day"`; echo "$now"; done
sar -g 5 5
find . -name "*.jpg" | perl -ne'chomp; $name = $_; $quote = chr(39); s/[$quote\\!]/_/ ; print "mv \"$name\" \"$_\"\n"'
last | awk '$1!~/wtmp/{logs[$1]++}END{for (i in logs) print i, logs[i]}'
last | awk '{ print $1 }' | sort | uniq -c | grep -v wtmp
rpm -qa --qf '%{name}'
rpm -qa --last