I am new to Linux and I want to create an alias to run an application.

Currently, to access it via the terminal I am typing:

cd /usr/local/bin

Is there any way I can by pass creating an alias just to change directories? I just want to be able to type pt for example into the terminal and it instantly run, rather than typing two separate commands.

Thank you in advance!


1 Answer 1


When you type echo $PATH you should see /usr/local/bin is already in your path and there is no need to change to that directory in the first place. You can run the executable simply by typing packettracer - there is no need to cd to it.

Even if it is not in your PATH, you don't need to change to a program's / script's directory as a separate command; you can run it by prefixing the executable's name with the full path, in this case:


Therefore your alias can simply be:

alias pt='/usr/local/bin/packettracer'

or even

alias pt='packettracer'

Before setting an alias, check that the command you want to use doesn't already exist using the type command. Hopefully you will see that it is not in use:

$ type pt
bash: type: pt: not found

Once you have a suitable alias, to make is permanent you can add it to the end of your ~/.bashrc file (use your favourite text editor; for example, open a terminal and type nano .bashrc add the alias, save and exit, and the alias will be available as soon as you open a new shell).


Not the answer you're looking for? Browse other questions tagged or ask your own question.