0

My Ubuntu installation does not have the alias command. Usually it would be in /usr/bin along with other basic commands like which. I can type:

which which
/usr/bin/which

but

which alias

interesting that it doesn't say alias not found; other Linuxes would say that.

I ran

sudo find / -name "alias" -print

and this did not find it either.

Could a kind person please tell me how to install alias? I tried sudo apt-get install alias but this did not work.

2 Answers 2

2

alias is actually built in to your shell environment (which is bash by default). To learn more about it, run man bash and then search for the alias builtin by typing /alias<ENTER>. (/ to tell man to search again).

A few tidbits I have come to learn about alias:

  • To run a command in its original form, run \command
  • Aliases do not work in shell scripts
  • Functions are preferred to aliases in most cases due to the higher flexability, but aliases are still useful for simple renames or common switches
  • Add your aliases to the end of your ~/.bashrc (or ~/.zshrc, or whatever)
1

To make an alias just add the following line at the end of ~/.bashrc

alias <commcnd>='/path/to/executable'

Or,

alias <command>='some command -option'

For example to use rm -i as an alias say,rr, just add the following line at the end of ~/.bashrc

alias rr='rm -i'

Next run the following in terminal,

source ~/.bashrc

Now onwards when you run rr filename it will implied as rm -i filename

To know if you set an alias try the following in terminal,

type rr

Output will be like,

rr is aliased to `rm -i'

Hope these would help.

2
  • Alternately you can also put aliases inside ~/.bash_aliases. If you do so you need to source it.
    – sourav c.
    Dec 11, 2013 at 4:02
  • @Mimi do you have any further query? Let me know.
    – sourav c.
    Dec 11, 2013 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .