linux – How to define a global alias in BASH?

Question:

I'm using Terminal on Linux and I'm tired of repeating the same commands over and over again.

For example, I use a command practically all day, then I create an alias to make things easier.

Example:

  alias tt="php artisan tinker --env=local"

  alias artisan="php artisan --env=local"

However, every time the Terminal is closed, these shortcuts "go in the bag". Then I have to set everything back when I open Terminal again or restart my Ubuntu ;

How can I leave these Global Aliases ? Is there any way to do this?

Answer:

You can add these lines to the /etc/profile file. Once the user logs in, the information is loaded.

$ sudo vim /etc/profile
ou
$ sudo nano /etc/profile

profile:

#...
alias tt="php artisan tinker --env=local"
alias artisan="php artisan --env=local"

To apply the changes, you must log out.

Scroll to Top