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.

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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags



Commands using alias from sorted by
Terminal - Commands using alias - 213 results
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

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

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. 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

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...

alias QUERY='psql -h $MYDBHOST -p 5432 -d $MYDB -U $MYLOGIN --no-align'
2011-04-08 12:44:33
User: cp
Functions: alias

alias for psql command line; works similar for Oracles sqlplus commandline interface.

if you do not provide stdin you will end up in the db shell.

alias screensaver='for ((;;)); do echo -ne "\033[$((1+RANDOM%LINES));$((1+RANDOM%COLUMNS))H\033[$((RANDOM%2));3$((RANDOM%8))m$((RANDOM%10))"; sleep 0.1 ; done'
alias rot13="tr a-zA-Z n-za-mN-ZA-M"
alias va='vi ~/.aliases; source ~/.aliases && echo "aliases sourced"'
2011-03-10 06:41:37
User: greggster
Functions: alias echo

When setting up a new aliases file, or having creating a new file.. About every time after editing an aliases file, I source it. This alias makes editing alias a bit easier and they are useful right away. Note if the source failed, it will not echo "aliases sourced".

Sub in vi for your favorite editor, or alter for ksh, sh, etc.

alias big='BIG () { find . -size +${1}M -ls; }; BIG $1'
2011-03-10 06:33:00
User: greggster
Functions: alias find

This is for bash - make an alias - also a good blueprint for making aliases that take arguments to functions. If for Solaris use "-size +${1}000000c" to replace "-size +${1}M"

alias sagi="yes | sudo apt-get install"
2011-03-06 03:45:47
User: theepicsnail
Functions: alias
Tags: alias apt-get

This alias is quicker to type than 'sudo apt-get install', and it automatically says yes to the prompt that shows up sometimes.

alias rdp='rdesktop -u <user> -g 1600x1200 -D -r disk:home=/home -r clipboard:PRIMARYCLIPBOARD'
2011-02-04 16:22:49
User: bbbco
Functions: alias

Sets an alias to remote desktop to the specified console, along with options to ensure the RDP session takes up the whole screen, includes a home directory mapping, and clipboard mappings.

alias ping='ping -n'
alias vim="vim -p"
2010-12-30 22:53:33
User: tommed
Functions: alias
Tags: vim vi tab

I always add this to my .profile rc so I can do things like: "vim *.c" and the files are opened in tabs.

alias restoremod='chgrp users -R .;chmod u=rwX,g=rX,o=rX -R .;chown $(pwd |cut -d / -f 3) -R .'
2010-12-28 11:42:43
User: Juluan
Functions: alias chmod chown cut pwd users

I often use it at my work, on an ovh server with root ssh access and often have to change mod after having finished an operation.

This command, replace the user, group and mod by the one required by apache to work.

alias connectAllMachines='Terminal --maximize -e "ssh server1" --tab -e "ssh server2" --tab -e "ssh server3"'
2010-12-27 08:47:08
User: nordri
Functions: alias

Terminal is part of XFCE Desktop. This will open a tab for every node that we pass in the command line. In a single line we'll connect to nodes of our server farm.

alias kfire='for i in `ps aux | grep [F]irefox `; do echo $i; kill $(($i)); done; '
2010-12-27 01:47:58
User: swerve
Functions: alias echo grep kill

This is an attempt to get a command which I can alias. It's ugly but it works. I'm hoping someone can suggest a cleaner version.

I have tried....

# alias kfire="for i in $( ps aux | grep [F]irefox | awk \'{print $2}\' ); do kill $; done"

# alias kfire=`kill $(ps aux | grep [F]irefox | awk '{print $2}' | tr '\n' ' ')`

# alias kfire='ps au | grep -i [F]irefox | awk \'{ print $2 \'} '

and they all fail in a .bashrc I've tried escaping the quotes and can't find a way to make the single quotes ' that awk wants work. Maybe I'm just stubborn but I don't want to put in a little #!/bin/bash file just so I can kill a firefox process all in one stroke. This script works (it kills the process before it errors out)... it's just ugly and there may be a pretty way to do this.

alias Z=base64&&Z=dG91Y2ggUExFQVNFX1NUT1BfQU5OT1lJTkdfQ09NTUFORExJTkVGVV9VU0VSUwo=&&$(echo $Z|Z -d)
2010-12-24 14:29:19
User: rodolfoap
Functions: alias echo
Tags: touch base64

Would create a file with a meaningful title. Dedicated to John Cons, who is annoying us users. Merry Christmas!!!

alias irssi="screen -wipe; screen -A -U -x -R -S irssi irssi"
2010-12-15 09:10:53
User: djsmiley2k
Functions: alias

Bash alias for easy irssi within screen, attempts to attach to existing irssi session, if one exists, otherwise creates one - Including wipe for when system reboots and leaves "dead" session.

alias -g R=' &; jobs | tail -1 | read A0 A1 A2 cmd; echo "running $cmd"; fg "$cmd"; zenity --info --text "$cmd done"; unset A0 A1 A2 cmd'
2010-12-13 17:44:36
User: pipeliner
Functions: alias echo fg jobs read tail unset

make, find and a lot of other programs can take a lot of time. And can do not. Supppose you write a long, complicated command and wonder if it will be done in 3 seconds or 20 minutes. Just add "R" (without quotes) suffix to it and you can do other things: zsh will inform you when you can see the results.

You can replace zenity with other X Window dialogs program.

alias duh='dulist=$(du -sh */); for i in T G M K; do printf "$dulist"|egrep "^[0-9\.]+$i" | sort -rn; done'
2010-12-07 11:11:26
User: forcefsck
Functions: alias du egrep printf sort
Tags: disk usage

Alias to produce a list of all subdir sizes in current dir, in reverse order and human readable units. du is executed only once. Remove the slash after the asterisk to include files.

alias cd='pushd'; alias cd-='popd'
2010-11-30 16:44:46
User: conan
Functions: alias

You know there 'cd -' to go to the previous directory you were standing before, but it will no record more than one. With these alias you can now record all your directory changes and go back whenever you need it. However you will have to get accustomed to use 'cd ~' from now on to go to your home directory.

alias capture='IMAGE="/home/user/Pictures/capture-`date +%Y%m%d%H%M%S`.png"; import -frame $IMAGE; echo "Image saved as $IMAGE"'