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

All commands from sorted by
Terminal - All commands - 11,605 results
ldd <executable binary>
2009-02-07 23:13:40
User: al3x
Functions: ldd
2

provides list of shared libraries required by executable

rpm -qlp <package.rpm>
2009-02-07 23:11:59
User: al3x
Functions: rpm
0

allows to check inside rpm file w/o installing it

ls -al /proc/<PID>/fd
2009-02-07 22:57:03
User: al3x
Functions: ls
1

Useful for examining hostile processes (backdoors,proxies)

dscacheutil -flushcache
alias acs='apt-cache search'
alias agi='sudo apt-get install'
sudo echo 1 > /proc/acpi/asus/camera
2009-02-07 21:57:01
User: orie
Functions: echo sudo
0

In some applications on eeepc xandros 7, default OS, video ccamera is not available untill you enter this command

find /path -name \*.php -user nobody -exec grep -nH whatever {} \;
2009-02-07 20:53:56
User: al3x
Functions: find grep
0

allows to grep very narrow subset of files

find /path -type d -perm 777 -exec chmod 755 {} \;
cat /proc/<PID>/environ
2009-02-07 20:49:19
User: al3x
Functions: cat
0

Good to find out about hostile processes

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