Input source ~/.bashrc error dircolors\lesspipe: command not found solution

question

enter

source ~/.bashrc

The following error is reported

Command 'lesspipe' is available in the following places
 * /bin/lesspipe
 * /usr/bin/lesspipe
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found

Solution

Enter on the command line

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

This method can ensure that you can use the commands under bin normally in this command line , such as source, ls, etc.

permanent solution

First execute the above mentioned, export in the command line.

Then modify the .bashrc file in your user directory, change it back if you make a mistake, and cancel the last change if you don’t know what is wrong.

vim ~/.bashrc

Focus on observing whether the statement of export ... $PATH ... is correct.

For example, my previous mistake was that I forgot to add PATH when configuring the cuda tool.

My .bashrc looks like this when it goes wrong:

...

export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
export PATH=/home/zhoug/cuda-10.2/lib64/

As you can see, I did not add $PATH in the middle of line 4, so an error occurred.

As I said before, either change to:

export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
export PATH=$PATH:/home/zhoug/cuda-10.2/lib64/

Either delete these lines and change them to the original one last time

...

# export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
# export PATH=/home/zhoug/cuda-10.2/lib64/

Then, source the modified .bashrc .

source ~/.bashrc

Your system commands will return to normal.

reason

Seeing this, you should also know, that is, after you update your .bashrc and source

vim ~/.bashrc
source ~/.bashrc

When the system parsed the path PATH of your export, it did not resolve the correct location.

That 99.99% may be because you did not modify the .bashrc modification.

In this case, if you want to execute system commands, you can only do this, for example, if you want ls

/usr/bin/ls

So you have to modify back to your .bashrc file, you have to use vim like this:

/usr/bin/vim ~/.bashrc

But the most difficult problem you encounter should be that when you want to source in this way, you will report the error I said at the beginning:

/usr/bin/source
Command 'lesspipe' is available in the following places
 * /bin/lesspipe
 * /usr/bin/lesspipe
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found

The possible reason is that source is a combined command, and then when this combined command is executed, the correct PATH path is still required when calling lesspipe and dircolors.

The workaround I mentioned works fine for this problem.

reference

Linux error: -bash: path xx: No such file or directory solution

Guess you like

Origin blog.csdn.net/m0_46948660/article/details/129702261