Is there a logic to the directory structure?
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Is there a logic to the directory structure?
Okay... having installed and uninstalled a few apps now, I am noticing some unexpected behavior; and that is there seems to be none (or very little) reason behind where the apps get installed to.
Examples of what I am referring to is this... I installed a few games, and they get installed in different folders with no logic behind it:
/usr/games/Game1
/usr/share/games/Game2
/usr/local/games/Game3
And it's the same with work-related apps; I never have a clue if they are in:
/usr/bin
/usr/share/bin
/usr/local/bin
So I ask, is there a logic behind the locations that I am missing? Or just don't understand? I like to keep things tidy and organized... and the seemingly random location of apps is hampering my neatness.
--Jim
Examples of what I am referring to is this... I installed a few games, and they get installed in different folders with no logic behind it:
/usr/games/Game1
/usr/share/games/Game2
/usr/local/games/Game3
And it's the same with work-related apps; I never have a clue if they are in:
/usr/bin
/usr/share/bin
/usr/local/bin
So I ask, is there a logic behind the locations that I am missing? Or just don't understand? I like to keep things tidy and organized... and the seemingly random location of apps is hampering my neatness.
--Jim
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Is there a logic to the directory structure?
It is a mess, with no clear standard being adopted. Any guess which version would run if you have a program with the same name in all three bin locations?
/usr/bin
/usr/share/bin
/usr/local/bin
My bet is that local will be used. I will try it to see.
Garvan
PS
The programs were found in this order.
1. /home/bin/
2. /usr/local/bin/
3. /usr/bin/
This directory
/usr/share/bin
Is not used on my system.
/usr/bin
/usr/share/bin
/usr/local/bin
My bet is that local will be used. I will try it to see.
Garvan
PS
The programs were found in this order.
1. /home/bin/
2. /usr/local/bin/
3. /usr/bin/
This directory
/usr/share/bin
Is not used on my system.
Notebook: DELL Latitude E5520, i5-2520M @ 2.50 GHz, 4GB RAM, Linux Mint 17.2 (2011)
Notebook: DELL Latitude 5280, i5-73000 @ 2.7 GHz., 16 GB RAM, Linux Mint 19.2 (2019)
Notebook: DELL Latitude 5280, i5-73000 @ 2.7 GHz., 16 GB RAM, Linux Mint 19.2 (2019)
Re: Is there a logic to the directory structure?
If the full path is not specified when running a program the system searches locations in the order listed in the local $PATH environment variable.Garvan wrote:It is a mess, with no clear standard being adopted. Any guess which version would run if you have a program with the same name in all three bin locations?
/usr/bin
/usr/share/bin
/usr/local/bin
My bet is that local will be used. I will try it to see.
Garvan
You can see this list by running 'echo $PATH' on the command line.
Re: Is there a logic to the directory structure?
Thank you, it should have been obvious, but I did not think of checking the path.wallaroo wrote:If the full path is not specified when running a program the system searches locations in the order listed in the local $PATH environment variable.Garvan wrote:It is a mess, with no clear standard being adopted. Any guess which version would run if you have a program with the same name in all three bin locations?
/usr/bin
/usr/share/bin
/usr/local/bin
My bet is that local will be used. I will try it to see.
Garvan
You can see this list by running 'echo $PATH' on the command line.
Garvan
Notebook: DELL Latitude E5520, i5-2520M @ 2.50 GHz, 4GB RAM, Linux Mint 17.2 (2011)
Notebook: DELL Latitude 5280, i5-73000 @ 2.7 GHz., 16 GB RAM, Linux Mint 19.2 (2019)
Notebook: DELL Latitude 5280, i5-73000 @ 2.7 GHz., 16 GB RAM, Linux Mint 19.2 (2019)
Re: Is there a logic to the directory structure?
Thanks for the replies.
@Garvan
Thanks, that test was actually quite fascinating... I do have several copies of some programs (different versions) and now I know which one gets executed.
@Oscar799
That link was helpful, but I am still kind of wondering:
It says /bin is for "User Binaries" and /usr is for "User Programs"... now maybe I'm just out of the tech loop here but what exactly is the difference between the two?
And /usr/local/ makes no sense to me... isn't every program installed on my machine a "local" program, or am I not understanding the context of the word in this case?
That page also states that /usr/bin is for "Second-level programs" but what does that mean? If it's programs installed afterwards, then what is the use for /opt ?
Sorry, but this is the Newbie area for my newbie questions after all.
--Jim
@Garvan
Thanks, that test was actually quite fascinating... I do have several copies of some programs (different versions) and now I know which one gets executed.
@Oscar799
That link was helpful, but I am still kind of wondering:
It says /bin is for "User Binaries" and /usr is for "User Programs"... now maybe I'm just out of the tech loop here but what exactly is the difference between the two?
And /usr/local/ makes no sense to me... isn't every program installed on my machine a "local" program, or am I not understanding the context of the word in this case?
That page also states that /usr/bin is for "Second-level programs" but what does that mean? If it's programs installed afterwards, then what is the use for /opt ?
Sorry, but this is the Newbie area for my newbie questions after all.
--Jim
Re: Is there a logic to the directory structure?
Guess I'm not the only one who isn't sure about these things.
I can't seem to find any definitive answer on Google, beyond the link that Oscar799 posted. They all seem to copy and paste the same bit of info and that's it.
I can't seem to find any definitive answer on Google, beyond the link that Oscar799 posted. They all seem to copy and paste the same bit of info and that's it.
Re: Is there a logic to the directory structure?
I don't think it can be explained any more deeply, than there is a standard (FHS) and it varies a bit between some Linux distributions; that is how well they adhere to the FHS specifications..RJim wrote:And /usr/local/ makes no sense to me... isn't every program installed on my machine a "local" program, or am I not understanding the context of the word in this case?
That directory (folder) is in a few Linux distributions as their standard, and for the reasons below is included
- /usr/local Tertiary hierarchy for local data, specific to this host. Typically has further subdirectories, e.g., bin/, lib/, share/.[29]
https://en.wikipedia.org/wiki/Filesyste ... y_Standard
--see the references section for various Linux distribution differences..
- RedHat (Fedora) and Debian or Debian derivations Ubuntu:Mint..
--and for their sake, and until end-of-life attribution to a Linux release, it is unlikely to be that much changed
- Nevertheless, it is via that standards approach FHS, mostly compliant..
Re: Is there a logic to the directory structure?
Using some of the tools available right there in Linux can help a person get used to the directory structure and kinda make some sense of it. Seeing the location of application files, you start getting a feeling for where certain types of files are gonna be located. This is kinda going at things from the reverse direction, but it was helpful to me for understanding the Linux file system.
I'm writing from Fedora 16, where I've installed the Geany text editor. Some commands that give me some info:
Also:
Often, I'll go to the package manager to get a list of installed files for a particular application. For Debian-based distros, I like to use Synaptic for this, but the following also works from the command line (again for Geany):
In Fedora, I'll use Yumex to find the filelist, or else run a command like this:
If you do this type of thing often enough, things become a bit clearer, and these tools are also helpful for when different distros differ in where they put things, because you can take a look at the output of some of these commands and then know right away where to find what, for any particular app.
I'm writing from Fedora 16, where I've installed the Geany text editor. Some commands that give me some info:
Code: Select all
$ which geany
/usr/bin/geany
Code: Select all
$ whereis geany
geany: /usr/bin/geany /usr/lib/geany /usr/share/geany /usr/share/man/man1/geany.1.gz
Code: Select all
$ locate geany
/home/steve/.config/geany
/home/steve/.config/geany/colorschemes
/home/steve/.config/geany/filedefs
/home/steve/.config/geany/geany.conf
/home/steve/.config/geany/tags
/home/steve/.config/geany/templates
/home/steve/.config/geany/ui_toolbar.xml
/home/steve/.config/geany/filedefs/filetypes.README
/home/steve/.config/geany/templates/files
/home/steve/.config/geany/templates/templates.README
/usr/bin/geany
/usr/lib/geany
...
Code: Select all
$ dpkg -L geany
Code: Select all
$ rpm -q -l geany
Re: Is there a logic to the directory structure?
Here's a paragraph that seems kinda helpful:
http://www.goinglinux.com/articles/Inst ... tions.htmlFor files that come pre-installed on your Linux distribution, here are the file locations. The Linux binary system programs are stored in the /bin folder (directory). The /boot folder contains the Linux kernel and the boot loader. The folder /etc contals the system-wide configuration files. These are configuration files for the linux system itself. Shared libraries are stored in /lib. Libraries correspond roughly with Windows .dll files. The /opt folder holds "optional" applications, generally commercial software products and the like. This is where applications like Firefox, Teamviewer, Adobe Air and proprietary printer applications typically go. The /usr folder contains a /bin, a /share and other folders for the programs that you install yourself. Some commercial programs like Skype go in here as well, but almost all of the Free and Open Source applications you find in your Linux distribution's software repositories will go here. Very predictable.
Re: Is there a logic to the directory structure?
Thanks everyone, I know I'm a bit dense but this is really helping me understand the Linux way of arranging files.
Let me make sure I understand this: (please correct any mistakes I may have)
/bin is for system commands like ls, top, grep, that are common among all Linux systems
/usr/bin is for user commands that are distro specific... I notice that all the Mint commands are in here
/usr/local/bin is for programs specific to my system. I notice the few programs I compiled from source are the only things in this folder...
and "apt" for some reason is also in here.
/opt I really have no idea... I have my lcd-console-display driver in here, as well as firefox, and my printer driver. Seems to be a mix of stuff.
From what I can tell not many packages seem to obey these standards... For example, in /usr/bin, I also have commands in here too such as "less" and "zip" and "link". Shouldn't these be in /bin since they are not really distro specific? Or have I still missed it?
Thanks for your help guys, just want to get to know my system a bit better!
Let me make sure I understand this: (please correct any mistakes I may have)
/bin is for system commands like ls, top, grep, that are common among all Linux systems
/usr/bin is for user commands that are distro specific... I notice that all the Mint commands are in here
/usr/local/bin is for programs specific to my system. I notice the few programs I compiled from source are the only things in this folder...
and "apt" for some reason is also in here.
/opt I really have no idea... I have my lcd-console-display driver in here, as well as firefox, and my printer driver. Seems to be a mix of stuff.
From what I can tell not many packages seem to obey these standards... For example, in /usr/bin, I also have commands in here too such as "less" and "zip" and "link". Shouldn't these be in /bin since they are not really distro specific? Or have I still missed it?
Thanks for your help guys, just want to get to know my system a bit better!
Re: Is there a logic to the directory structure?
I totally empathise with these sentiments and I think the unix style directory structure is long over-due for rationalization and simplification as it is designed for corporate networks with dumb terminals and not applicable to personal devices... and it's just confusing and inconvenient. I like the software packages to be installed as self contained enitities and not spread all over the place.
p.s. if you want to get a feel for the how things are organized try the command
My reaction was
p.s. if you want to get a feel for the how things are organized try the command
Code: Select all
tree /
Re: Is there a logic to the directory structure?
I don't know if this is "standard" but at my job where most of us have Solaris or Linux desktops, /bin and /usr/bin are local to each box while /usr/local/bin (and other dirs under /usr/local) are NFS mounted from a server that holds binaries for various variants of the OSes. So it's *not* local despite the name. This is to ease administration of upgrades etc.