Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu how to create a shortcut that execute a command

When I work I often do:

cd ~/dev/lab/prod/

It is just an example but I would like to be able just to run:

prod

With the same effect (changing into the ~/dev/lab/prod folder).

like image 927
PierreD Avatar asked Mar 06 '26 12:03

PierreD


1 Answers

Alias is what you are looking for.

For bash you have to do following steps:

1) Open your .bashrc

nano ~/.bashrc

2) Add new alias (at the end of file)

alias prod='cd ~/dev/lab/prod/'

3) Save and close the file

4) Source the .bashrc file

source ~/.bashrc

5) Use created alias prod for cd ~/dev/lab/prod/ command

like image 133
Vladas Maier Avatar answered Mar 09 '26 08:03

Vladas Maier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!