1

I'm running Windows 10, and have BASH terminal in VisualStudioCode. My problem is that commands such as LS do not work. After some googling, i found that using this command fixes it:

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

This however breaks some other stuff, and so, I copied output of echo $PATH, amalgamated the result with above-mentioned export command, and saved it into the file. Pasting resulting command into terminal fixes everything.

And I have to do that every single time I open new terminal, which is awkward.

Is there any way to add parts from the first export command to PATH? I know about "Edit the enviroment variable" option in windows, but either that does not work, or i'm doing it wrong, so telling me how to apply, eg. /usr/bin in there so that it works the same way as if I entered export PATH=/usr/bin into command line would help. Eventually, is there perhaps a way to autorun specific command each time new terminal is opened? That would help too.

3
  • Add the line to your .bashrc. Also, you can skip the echo part if you extend PATH instead of overwriting, like so: PATH=$PATH:/new/stuff/goes/here:/more/new/stuff
    – Panki
    Commented Jun 18, 2021 at 11:23
  • Ok that did work! I was confused, because upon launching terminal, i still see bash: cut: command not found - any idea where does that come from?
    – Przemek
    Commented Jun 18, 2021 at 12:14
  • As commented, each shell has one or more configuration files (usually a .*conf or .*rc -- note that .*conf and .*conf are NOT typos of *.conf or *.rc; So for Bash, it is .bashrc, not bash.rc. Read the appropriate shell manual for why). Also, and this is very significant, in Unix-like systems, there is no such thing as a global/system environment. There are, however, several system-wide default shell configuration files in /etc (the shell documentaion will tell you which files and their names).
    – C. M.
    Commented Jun 18, 2021 at 19:39

2 Answers 2

0

Quoted from the question here as an answer:

Here's the fix that worked for me: create C:\Users\username\.bashrc file, and put the line you need to input manually into that line, it will run every time you launch bash.

0

Should you be having to alter your $PATH almost on a per application basis? I know that this practice is common in Windows. Since you have /usr/local/bin in your original $PATH:-

Try never changing your $PATH, so that applications may fail, due to multiple changes of $PATH.

Simply place symbolic links in /usr/local/bin pointing to the true locations of your programs - which are placed in logical locations.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .