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 from sorted by
Terminal - Commands using alias - 206 results
alias flashplay="mplayer \$(find /proc/\$(pgrep -f 'libgcflash|libflashplayer')/fd/ -printf '%p %l\n' |grep FlashXX | cut -d\ -f1)"
2011-12-19 09:29:57
User: Aissen
Functions: alias
0

Alias to play flash videos with mplayer. You can replace mplayer with your favorite video player.

This alias supports Chrome & Firefox's way of handling the flash plugin. It will play all the videos in the cache. Note that certain videos might never make it to the cache, if the publisher ask for them not to: they will just be loaded in RAM.

A variant if you're just interested in playing the audio, for example for a music :

alias flashmusic="mplayer -vo null \$(find /proc/\$(pgrep -f 'libgcfl|libflashplayer')/fd/ -printf '%p %l\n' |grep FlashXX | cut -d\ -f1)"
alias gtasks='chromium-browser --app=https://mail.google.com/tasks/ig'
2011-12-05 22:11:00
User: Bonster
Functions: alias
-4

requires a gmail account, it opens Google tasks in a self contain window, to write your todo list and have it sync online yay =)

alias cls='printf %b '\''\033c'\'''
2011-11-01 14:31:30
Functions: alias
0

Syntax outside of an alias would be printf %b \\033c. This clears the screen and removes scrollback. Works on gnome-terminal and the XFCE's Terminal, and XTerm. It does clear the screen in Konsole and the Mac Terminal, but does not clear scrollback.

alias mid='printf "\e[8;24;80;t"'
2011-11-01 14:25:45
Functions: alias
0

Uses printf command to resize terminal.

So far, this is tested to NOT work in Konsole. Works with Mac Terminal, XFCE Terminal, XTerm, gnome-terminal.

alias me="echo '`ifconfig | grep inet | grep broadcast | awk '{print $2}'`' && uname -n"
2011-10-30 19:36:42
User: timrand
Functions: alias
0

Creates an alias that reports your hostname and IP for you computer. Getting the quotes in an alias with awk commands can be a painful. Need uname and ifconfig--both are included in most unix distributions, I believe. Hope it is useful.

alias ..='cd ..'
alias install='sudo apt-get install'
2011-10-27 19:53:01
User: haivu
Functions: alias
Tags: Ubuntu alias
-6

I put this line in my ~/.bashrc file (which I source via ~/.bash_profile). Now, when I need to install a package, I typed *install* instead of the longer version.

alias calc='python -ic "from math import *; from random import *"'
2011-10-24 08:15:41
User: Bonster
Functions: alias
0

use python as calculator, press ctrl+d to exit

reminder: when doing factions add atleast one decimal number like so

22.0/7 or 22/7.0

alias dateformatcodes="date --help | sed -n '/^FORMAT/,/%Z/p'"
2011-10-20 17:43:36
Functions: alias
0

Prints out the list of date(1) format codes, for quick easy reference.

dateformatcodes
alias busy='rnd_file=$(find /usr/include -type f -size +5k | sort -R | head -n 1) && vim +$((RANDOM%$(wc -l $rnd_file | cut -f1 -d" "))) $rnd_file'
2011-10-16 00:05:59
User: frntn
Functions: alias cut find head sort vim wc
0

Enhancement for the 'busy' command originally posted by busybee : less chars, no escape issue, and most important it exclude small files ( opening a 5 lines file isn't that persuasive I think ;) )

This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim.

alias cn='cat > /dev/null'
2011-09-16 00:00:28
Functions: alias
-2

cn stands for "Cat Null"

.

The idea is that sometimes you run across something on maybe a webpage - like commandlinefu - that you want to try out on your terminal. You could put a '#' in and then paste it, but what if it is several lines?

.

This command will echo the pasted characters to the screen and divert them to the bit bucket.

.

Put this simple alias in your .bashrc, hit cn, paste away, and hit a ctrl+c or a ctrl+d when you are done to get your prompt back.

alias oports="echo -e "User:\tCommand:\tPort:\n----------------------------" && lsof -i 4 -P -n | awk '/LISTEN/ {print $3, $1, $9}' | sed 's/ [a-z0-9\.\*]*:/ /' | sort -u -k 3 -n | xargs printf '%-10s %-10s %-10s\n'"
alias oports="echo 'User: Command: Port:'; echo '----------------------------' ; lsof -i 4 -P -n | grep -i 'listen' | awk '{print \$3, \$1, \$9}' | sed 's/ [a-z0-9\.\*]*:/ /' | sort -k 3 -n |xargs printf '%-10s %-10s %-10s\n' | uniq"
alias cd1='cd $( ls -1t | grep ^d | head -1)'
alias cps="ps -u root U `whoami` --forest -o pid,stat,tty,user,command |ccze -m ansi"
alias cdd="history -a && grep '^ *[0-9]* *cd ' ~/.bash_history| tail -10 >>~/.bash_history && history -r ~/.bash_history"
2011-07-13 09:44:16
User: knoppix5
Functions: alias
1

This alias is meant to append n (here is n=10) most recently used cd commands to the bottom of history file. This way you can easily change to one of previous visited directories simply by hitting 1-10 times arrow up key.

Hint: You can make more aliases implying the same rule for any set of frequently used long and complex commands like: mkisof, rdesktop, gpg...

map() { if [ "$1" != "" ]; then alias $1="cd `pwd`"; fi }
2011-07-11 15:46:19
User: javidjamae
Functions: alias
1

Put the function in your .bashrc and use "map [alias]" to create the alias you want. Just be careful to not override an existing alias.

alias google='open http://www.google.com/search?q="'
2011-06-29 20:23:20
Functions: alias
1

Syntax:

google query_with_spaces "

so, make sure to end your query with a double quote

alias cd1='cd $( ls -lt | grep ^d | head -1 | cut -b 51- )'
alias ltr 'ls -altr'
2011-06-11 03:22:13
User: drb532
Functions: alias
-4

Create an alias to list all contents of the current directory in "reverse" time order. Thus the last modified file will appear just above your next prompt. Useful for remembering where you left off modifying files in a folder or just noting recent changes.

csh format but bash syntax similar

alias nbtstat='nmblookup -S -U <server> -R'
2011-05-19 18:56:37
User: bradyr
Functions: alias
0

it's a mixed environment where I work, and since we still use WINS services, this is often a quick and dirty way for me to obtain a mac-address for a hostname. please note that nmblookup is part of the samba suite. Just another one of those nearly useless commands that is super cool when and only when you need it.

alias viaco='task="$(basename "$(pwd)")"; if [ -f "$task.c" ]; then vi -c "set mouse=n" -c "set autoread" -c "vsplit $task.out" -c "split $task.in" -c "wincmd l" -c "wincmd H" $task.c; fi'
2011-05-13 13:35:02
User: yolila
Functions: alias vi
-1

1. Get name of task by task=$(basename "$(pwd)")

2. Check whether "$task.c" exists as a file

3. open "$task.c", "$task.in", "task.out" in vim with such layout.

-------------------------------

|            | $task.in    |

|            |                |

|$task.c  |-----------------|

|            | $task.out  |

|            |                |

-------------------------------

alias screenr='screen -r $(screen -ls | egrep -o -e '[0-9]+' | head -n 1)'
alias cal='cal | grep --color=auto -E "( |^)$(date +%e)|$"'
alias df="df | awk 'NF == 1 {printf(\$1); next}; {print}'"
2011-04-09 06:43:51
User: MeaCulpa
Functions: alias
-4

Personally I think line wrap in default df command is annoying for scripting & seeing. So I overwrite it. Maybe more work should be done if wrapped line is over 2...