2

I'm using Ubuntu 14.04. I often use cd .. command in terminal. I want to replace the command with .. or some other shortcut.

Can I do that? If yes, how to do it?

0

1 Answer 1

3

This is usually called alias and not shortcut.

to do that:

alias CD='cd ..'

Now you can use the command CD instead of cd ..

But you have to note this will be just dynamic and you'll l ose all aliases when you close terminal and start again. To make it permanent you have to add it to your .bashrc.

Run the command

gedit .bashrc

Add the above line (alias declaration) then save and close and source the .bashrc using

source .bashrc

And now the alias CD is permanent .


You can list all aliases you use in your system(ubuntu come with some default aliases such as ls, egrep...), you can just type the command alias and you can list all aliases in the system

2
  • Worked like charm!! BTW, what does source .bashrc line does?
    – Abhishek
    Jul 9, 2015 at 13:11
  • It just "fetch" i.e run the file, Execute commands from a file in the current shell.
    – Maythux
    Jul 9, 2015 at 13:12

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