Ubuntu – How to create shortcuts in terminal?

command line

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?

Best Answer

  • 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

  • Related Question