Where exactly in .bashrc to install PATH?

At the end of the .bashrc file, I added these lines to set the path to the foo folder in my home directory:

 PATH = $PATH:/home/username/foo export PATH; 

Then I typed bash:

 source .bashrc 

There was an error:

 bash: PATH: command not found 

I am using Debian Squeeze. In a similar question , it was recommended to modify /etc/login.defs here. I do not want to do this, as it is written in the login.defs name itself:

 add the rest [of your paths] in the shell startup files 

How to add foo folder to PATH in .bashrc?

+4
source share
3 answers

You are using the wrong syntax. Drop the spaces:

 export PATH=$PATH:/home/username/foo 

Regarding /etc/login.defs or any other global configuration: well, this is a global configuration, so it is probably a bad idea to add paths to your $HOME directory.;)

+23
source

Just use the following line in your .bashrc

 export PATH=/home/username/foo:$PATH 
+4
source

There are syntax differences between the one used for mac and CentOS, however, the following syntax is used on CentOS and RedHat.

export PATH="/path/directory:$PATH" then make source .bashrc

I'm not sure about other Linux distributions, but it will work on CentOS and RedHat.

0
source

Source: https://habr.com/ru/post/1497687/


All Articles