Why is there no /usr/bin in Windows?
Solution 1
Usually there should not be any issues. However, you need to watch out for two things:
- Avoid name collisions. In particular, make sure the standard path components (like
C:\windows
etc.) come first, so no system utility is hidden in the path. - The
PATH
variable may not contain more than 8191 characters. So if you have many program folders that you want to add, you may have to pick and choose. If you assume an average path length of 50 characters per program, that gives you space for about 160 programs in the PATH.
The reason this is not done by default is probably simply that the command line is used relatively rarely on Windows, so there was never a pressing need to have everything in the path. Most programs that need to invoke other programs have adapted to this, and use the full path for invocations.
Finally, if you would like to work on the command line a lot, like on Linux, I recommend you install Cygwin. It provides a Linux-like environment on Windows, and lets you work on the command line. It also maintains its own PATH
variable, which you can customize without impacting other Windows applications.
Solution 2
The answer to this depends on the type of program you are talking about. If you are talking about programs that use shared libraries (DLLs):
C:\Program Files
is the correct place for them. You cannot put the files for these programs into the same folder because they are likely to have name collisions. If you are talking about programs that use static libraries (no DLLs):
C:\ProgramData\Bin
is the correct place for them. This is akin to:
/usr/local/bin
on Linux. This directory is available via a folder variable:
ProgramData=C:\ProgramData
If you need to get programs with shared libraries onto your Path, you can symlink them:
mklink C:\ProgramData\Bin\alfa.exe "C:\Program Files\Alfa\alfa.exe"
Related videos on Youtube
dotancohen
Updated on September 18, 2022Comments
-
dotancohen over 1 year
I am a Linux user spending some time in Windows and I am trying to understand some of the Windows paradigms instead of fighting them. I notice that each program installed in the traditional manner adds the executables to
C:\Program Files
and then adds a shortcut to the Desktop / Start Menu containing the entire path. However, there is no common directory with links to the software, i.e.
C:\bin\bar.exe
which would link toC:\Program Files\foo\bar.exe
Therefore, after installing an application the only way to use the application is via the menus or by navigating to the executable in the filesystem. One cannot simply
Win-R
to open the run dialogue and then typebar
orbar.exe
as is possible withnotepad
ormspaint
. I realize that Windows 8 improves on this with the otherwise horrendous Start Screen which does support typing the name of the app, but again this depends on the app having registered itself for such.Would I be doing any harm by adding
C:\Program Files
recursively to the Windows path? I do realize that there will be name collisions (i.e. uninstall.exe) but could there be other issues? -
dotancohen over 10 yearsThank you, I actually am using Cygwin in mintty for most things now. However, Python is a beast and needs the original
cmd
, even with the-i
flag. -
airstrike over 7 years@dotancohen You can use WSL instead if you're running Windows 10. Works virtually perfectly for python development.