🔍 See Original Answer on Ask Ubuntu 🔗
I am trying to create an alias to run an application. Is there away to bypass creating an alias just to change directories?
November 15, 2016
Edited: November 15, 2016
November 24, 2022
Copy to clipboard: false
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:
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).