Alias command in Linux

4 Nov, 2007  |  Posted by Danesh  |  in Linux

The alias command is used to create shortcuts to commands. Let’s see how it works.

I use the alias command to create shortcuts for commands I use frequently. For example the cp(copy) and mv(move) commands, my alias simply adds -i to cp and mv commands causing them to be interactive thus preventing any accidental deletes or file overwrites.

Running the alias command will show you all the current aliases available.

[dummy@macho ~]$ alias
alias l.=’ls -d .* –color=tty’
alias ll=’ls -l –color=tty’
alias ls=’ls –color=tty’
alias vi=’vim’

alias cp=’cp -i’. This command will ad -i to the cp(copy) command. Now, every time the cp command is executed it will be interactive. No more accidental deletes :)

alias mv=’mv -i’. This command will ad -i to the mv(move) command. Now, every time the mv command is executed it will be interactive. No more accidental overwrites :)

[dummy@macho ~]$ alias cp=’cp -i’
[dummy@macho ~]$ alias mv=’mv-i’
[dummy@macho ~]$ alias
alias cp=’cp -i’
alias l.=’ls -d .* –color=tty’
alias ll=’ls -l –color=tty’
alias ls=’ls –color=tty’
alias mv=’mv-i’
alias vi=’vim’

  • Digg
  • del.icio.us
  • BlinkList
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Furl
  • Google
  • Live
  • Facebook
  • Pownce
  • TwitThis
  • E-mail this story to a friend!
Tags: ,

7 Responses so far | Have Your Say!

  1. takizo  |  November 5th, 2007 at 10:57 am #

    alias rm=’rm -rf’ will speed up your remove :)

    takizo - Gravatar
  2. Danny  |  November 5th, 2007 at 4:20 pm #

    thanks Takizo but don’t forget the possibility to wipe out the whole installation as well ;)

    Danny - Gravatar
  3. takizo  |  November 5th, 2007 at 5:01 pm #

    then you can use grep /dev/xxx to restore your data. — . LoL ;)

    takizo - Gravatar
  4. Danny  |  November 5th, 2007 at 6:56 pm #

    painful but yes I agree….

    Danny - Gravatar
  5. Sriram  |  November 5th, 2007 at 7:51 pm #

    Hello Danny..Thanks for dropping by my site..Your site is just awesome.
    I’m a person who’s into technology as well;I love networking and hacking(the better side of it).

    Sriram - Gravatar
  6. Danny  |  November 6th, 2007 at 3:50 pm #

    Sriram, you have some cool reads on your blog too man. Looking forward to new reads :)

    Danny - Gravatar
  7. alias » Alias command in Linux  |  November 12th, 2007 at 3:45 pm #

    [...] Read the rest of this great post here [...]

    alias » Alias command in Linux - Gravatar

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>