You’re trying to add a directory to your $PATH so it will always be in your linux $PATH and accessible anywhere.

You can add your ‘path’ to $PATH with below command:

$ export PATH=$PATH:/path/to/dir

However each time you exit the terminal or start a new terminal instance, or reboot the system this path is lost and you need to run the export command again.

To set it permanently follow one of the two below:

User Wide

This method will effect your ‘current user’ only. According to your shell, add your path into your .profile, .bash_profile, .zprofile.

For instance, add it to /home/user/.profile or in short ~/.profile:

# ~/.profile

export PATH=$PATH:/path/to/dir

Then source the file to activate the new $PATH:

$ source ~/.profile
You can add it into .bashrc,.zshrc as well but I do not prefer this method. Since environment variables should be set in ~/.profile.

System Wide

This method will effect all users in your system. It means that if you add path with this method the path will be visible for all users in the system. In order to execute that you have to have root privileges.

Add your ‘path’ to /etc/profile/:

# /etc/profile

export PATH=$PATH:/path/to/dir

All done!