Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where exactly in .bashrc set PATH?

Tags:

linux

path

debian

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

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

Then I typed in bash:

source .bashrc

These produced error:

bash: PATH: command not found

I am using Debian Squeeze. In a similar question here it was advised to modify /etc/login.defs. I don't want to do this as in the very login.defs it is written:

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

How to add folder foo to PATH in .bashrc?

like image 721
cpp Avatar asked Aug 18 '13 17:08

cpp


People also ask

Where is PATH in bashrc?

Open the . bashrc file in your home directory (for example, /home/your-user-name/. bashrc ) in a text editor. Add export PATH="your-dir:$PATH" to the last line of the file, where your-dir is the directory you want to add.

Where are paths set in Linux?

To set $PATH globally, you'll need to add the directory using the same command you used while adding temporary and permanent setup, but either in the /etc/environment or the /etc/profile file.

Where $path is stored?

The PATH environment variable is an important security control. It specifies the directories to be searched to find a command. The default systemwide PATH value is specified in the /etc/profile file, and each user normally has a PATH value in the user's $HOME/. profile file.


2 Answers

You are using the wrong syntax. Drop the spaces:

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

Regarding /etc/login.defsor any other global configuration: Well, it is global configuration, so probably a bad idea to add paths within your $HOME directory there. ;)

like image 132
nmaier Avatar answered Oct 13 '22 04:10

nmaier


Just use the following line in your .bashrc

export PATH=/home/username/foo:$PATH
like image 45
MSM Avatar answered Oct 13 '22 03:10

MSM