Problem installing $ PATH directories

For some strange reason, I get a "No such file or directory" error for my $PATH variable. I tried to change my path using export , changing it from what it originally was for each permutation from one directory path to the original.

When there is one directory (for example, export PATH=/bin ), I get "/ bin: Is Directory". But as soon as I add several directories (for example, export PATH=/bin:/sbin ), I get "There is no such file or directory."

I am interested to know what is the cause of this problem!

+4
source share
3 answers

RE; your comment:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/uβ€Œsr/local/mysql/bin: No such file or directory will be generated if you have a line that says:

 $PATH 

maybe on its own, or maybe you have $PATH=... That is, the shell tries to execute a program with the name:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/uβ€Œsr/local/mysql/bin

Lose $ on the left side.

+1
source

I am not sure if you are using the export option. You almost certainly have spaces, and you shouldn't, according to the following transcript:

 pax> PATH= /bin bash: /bin: is a directory pax> PATH= /bin/sbin bash: /bin/sbin: No such file or directory 

The first is because you temporarily set the path to an empty line when you try to start this directory. This is because you can do things like:

 pax> xyzzy=1 pax> echo $xyzzy 1 pax> xyzzy=2 bash -c 'echo $xyzzy' 2 pax> echo $xyzzy 1 

In other words, this is a way to change the environment variable for one command and automatically return it after the command completes.

The second case is simply because there is no /bin/sbin directory. Therefore, he discovers that before he complains that you are trying to start the directory.

Setting a variable in bash is a non-whitespace thing (unless you have spaces in the directory names, in which case they must be specified). In addition, they should be divided into two parts. Therefore, you are looking for things like:

 PATH=/bin PATH=/bin:/sbin PATH="/bin:/sbin:/directory with spaces in it:$HOME/bin" 
+1
source

The export function only changes the variable for the current terminal session.

Enter PATH inside ~/.bash_profile if you want to change it constantly.

For this modification you need to close the current terminal and open it again.

0
source

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


All Articles