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 using alias

Commands using alias from sorted by
Terminal - Commands using alias - 192 results
alias sucs="sort | uniq -c | sort -n"
2009-07-21 10:55:06
User: inof
Functions: alias
0

This alias finds identical lines in a file (or pipe) and prints a sorted count of them (the name "sucs" descends from the first letters of the commands). The first example shows the number of logins of users; the one who logged in most often comes last. The second example extracts web client IP addresses from a log file, then pipes the result through the "sucs" alias to find out which clients are performing the most accesses. Or pipe the first column of ps(1) output through "sucs" to see how many processes your users are running.

alias w3m='w3m -cookie'
echo alias grep=\'grep --color=auto\' >> ~/.bashrc ; . ~/.bashrc
2009-07-05 07:44:13
User: 0x2142
Functions: alias echo
Tags: color grep
7

This will create a permanent alias to colorize the search pattern in your grep output

alias launchpadkey="sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys"
2009-06-17 12:02:27
User: azeey
Functions: alias
Tags: alias apt-key
9

Makes it easy to add keys to new ppa sources entries in apt sources.list

Now to add the key for the chromium-daily ppa:

launchpadkey 4E5E17B5
alias findstring="find . -type f -print | xargs grep $1"
kill_daemon() { echo "Daemon?"; read dm; kill -15 $(netstat -atulpe | grep $dm | cut -d '/' -f1 | awk '{print $9}') }; alias kd='kill_daemon
2009-05-26 20:39:56
User: P17
-5

Just find out the daemon with $ netstat -atulpe. Then type in his name and he gets the SIGTERM.

alias setvol='aumix -v'
2009-05-21 22:39:40
User: b2e
Functions: alias
2

If you're addicted to command-line solutions of ordinary actions or if you just want to set your volume from bed via mobile phone SSH, you can set this alias and use it as

setvol 50

for setting volume on 50% gain

Works only with ALSA, tested on Ubuntu 8.10. Give me some info about your experience.

TIP: Try aslo command "mute" to toggle mute/unmute sound. But I don't know if this works on all distros.

alias lso="sudo lsof -i -T -n"
2009-05-14 04:01:05
Functions: alias
-2

list what applications using what ports

alias agi="sudo apt-get install" #package_names
2009-05-14 03:31:47
Functions: alias
-3

these are some aliases you can use in bashrc to shorten the amount of typing needed to use apt-get, also can be used as reference if you can't remember alot of commands or command parameter variations,etc...

Please comment with more apt-get aliases if I missed any, thx

alias sbrc="source ~/.bashrc" && alias nbrc="nano ~/.bashrc"
2009-05-13 02:41:37
Functions: alias
-19

alias for editing .bashrc and sourcing it with a quick command, very useful for quickly adding and modifying alias' and functions in bashrc, create lots of alias from commandlinefu very quickly, use nano vim or any other edit if you want, very useful if you have a barcode scanner and you want to run commands quickly with barcodes

rm_cache() { rm -f $HOME/.mozilla/firefox/<profile>/Cache/* }; alias rmcache='rm_cache'
alias s='ssh -l root'
2009-05-07 15:57:12
User: GouNiNi
Functions: alias
-20

When you have to manage lot of servers, it's boring to type ssh root@myhost for each connection. Now you can type juste "s someting" and you are connected.

You can too add bash_completion script to complet with tab the name of your servers. This will be the next tips from me ;)

alias xdef_load='xrdb -merge ~/.Xdefaults'
2009-05-05 16:34:06
User: P17
Functions: alias
0

Reads in the ~/.Xdefaults lexicographically sorted with, instead of replacing, the current contents of the specified properties.

alias b='cd -'
alias somafm='read -p "Which station? "; mplayer --reallyquiet -vo none -ao sdl http://somafm.com/startstream=${REPLY}.pls'
2009-05-05 12:13:46
User: denzuko
Functions: alias
-1

This is the alias command that I discussed in my prior release which you can add to your ~/.bashrc.

This command asks for the station name and then connects to somafm, Great for those who have linux home entertainment boxes and ssh enabled on them, just for the CLI fiends out there ( I know I'm one of them ;)

You can find future releases of this and many more scripts at the teachings of master denzuko - denzuko.co.cc.

alias dfr='df;free'
2009-04-28 11:30:31
User: ximo88
Functions: alias
-9

A short way to give us relevant report in a moment done about quantities on disk usage, memory and swap in our Linux Systems.

alias h='history'
2009-04-28 11:20:03
User: ximo88
Functions: alias
-8

typing history it's a long way but typing only h it's my way it works in whatever distro or OSes or shells that you use, you know, only for easyness :)

alias lg='ls --color=always | grep --color=always -i'
2009-04-11 23:15:12
User: kFiddle
Functions: alias grep
Tags: ls alias color grep
5

This is a simple command, but extremely useful. It's a quick way to search the file names in the current directory for a substring. Normally people use "ls *term*" but that requires the stars and is not case insensitive. Color (for both ls and grep) is an added bonus.

alias backup_dir='mkdir -p .backup && cp * .backup'
2009-04-06 14:43:21
User: k00pa
Functions: alias cp
-3

Add this to .bashrc, then you can quickly create backups from files on current directory, but it only backups files on current directory.

useful when changing config files, coding something or just trying something stupid.

alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'"
2009-03-30 19:08:49
User: penpen
Functions: alias
Tags: Linux unix
8

rot13 maps a..mn..z (A..MN..Z) to n..za..m (n..za..m) and so does this alias.

alias l='ls -CFlash'
2009-03-30 17:11:31
Functions: alias
2

create a short alias for 'ls' with multi-column (-C), file type syntax additions (slashes after directories, @ for symlinks, etc... (-F), long format (-l), including hidden directories (all ./, ../, .svn, etc) (-a), show file-system blocks actually in use (-s), human readable file sizes (-h)

alias up="cd .."; alias upp="cd ../.."; alias uppp="cd ../../.."; alias upppp="cd ../../../.."; alias uppppp="cd ../../../../.."
alias tree="tree -CAFa -I 'CVS|*.*.package|.svn|.git' --dirsfirst"
2009-03-27 05:13:39
User: isaacs
Functions: alias
Tags: tree
7

I got really tired of having tree always show me tons of .svn and .git stuff that I don't care about. With this alias, "tree" uses pretty colors, snazzy line graphics, and ignores any source control and package mumbojumbo. (Customize the *.*.package glob, of course.)

alias showip="ifconfig eth0 | grep 'inet addr:' | sed 's/.*addr\:\(.*\) Bcast\:.*/\1/'"
2009-03-25 07:50:12
User: dizzgo
Functions: alias
Tags: ifconfig alias IP
0

parses the output of ifconfig to show only the configured ip address (in this case from interface eth0).

the regexp is quick'n'dirty im sure it can be done in a better way.

--> this alias does not show your "internet ip" when you're in a nat-environment

alias tproxy='ssh -ND 8118 user@server&; export LD_PRELOAD="/usr/lib/libtsocks.so"'