command line - I am trying to create an alias to run an application. Is there away to bypass creating an alias just to change directories? - Ask Ubuntu


this question has answer here:

i new linux , want create alias run application.

currently, access via terminal typing:

cd /usr/local/bin packettracer 

is there way can pass creating alias change directories? want able type pt example terminal , instantly run, rather typing 2 separate commands.

thank in advance!

when type echo $path should see /usr/local/bin in path , there no need change directory in first place. can run executable typing packettracer - there no need cd it.

even if not in path, don't need change program's / script's directory separate command; can run prefixing executable's name full path, in case:

/usr/local/bin/packettracer 

therefore alias can be:

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

or even

alias pt='packettracer' 

before setting alias, check command want use doesn't exist using type command. see not in use:

$ type pt bash: type: pt: not found 

once have suitable alias, make permanent can add end of ~/.bashrc file (use favourite text editor; example, open terminal , type nano .bashrc add alias, save , exit, , alias available open new shell).


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User