Linux doesn't have an equivalent to Windows's %ProgramFiles%
variable because it doesn't need one. There's a standard location for programs that are installed in their own directory: /opt
. Bit most programs aren't installed there, because they come in packages, and their files are located where they will be found by other programs. The reasons why Windows has a %ProgramFiles%
variable are in fact largely historical:
- Windows has drive letters. Even if
\Program Files
was the standard location, there'd still be the question of whether it's c:\Program Files
, D:\Program Files
, etc. Linux has never had this issue because symbolic links allow a directory to appear anywhere, regardless of which physical storage medium it's on. (Modern Windows don't need this because they have an equivalent feature, but the location remains modifiable for backward compatibility.)
- Windows lets the administrator choose the name of system directories. Linux doesn't; that's ok because it never did, whereas Windows had to accommodate administrators who chose different locations for backward compatibility.
- Every Windows program comes with its own installer, so there's no real package management mechanism, and the only way to keep track of what files belong to what package is to have one package per directory. That's beginning to change, but not quite there yet. In contrast, Linux usually stores files where they will be found and lets the package manager keep track of who they belong to.
Linux does have environment variables that specify paths: PATH
for executable commands, LD_LIBRARY_PATH
for shared libraries, MANPATH
for manual pages, etc. They're all about where to find files, not where to put files. Where to put files isn't something that programs know, it's something that package managers know. Package managers have their data files, they don't need environment variables to tell them where things are.
The directory structure on Linux systems is standardized in the Filesystem Hierarchy Standard. There's no need for environment variables for most of these, either because the location is standard or because there's no need for a single location.
The fact that different distribution have different package systems isn't due to having different directory structures. It's one of the main differentiators between distributions.