Is there a logic to the directory structure?

Quick to answer questions about finding your way around Linux Mint as a new user.
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.
Locked
RJim

Is there a logic to the directory structure?

Post by RJim »

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. :mrgreen:

--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.
User avatar
Oscar799
Level 20
Level 20
Posts: 10398
Joined: Tue Aug 11, 2009 9:21 am
Location: United Kingdom

Re: Is there a logic to the directory structure?

Post by Oscar799 »

Image
User avatar
Garvan
Level 4
Level 4
Posts: 300
Joined: Sun May 29, 2011 3:26 am
Location: Thailand
Contact:

Re: Is there a logic to the directory structure?

Post by Garvan »

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.
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)
wallaroo
Level 3
Level 3
Posts: 156
Joined: Thu Feb 09, 2012 3:42 am
Location: Australia

Re: Is there a logic to the directory structure?

Post by wallaroo »

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
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.

You can see this list by running 'echo $PATH' on the command line.
User avatar
Garvan
Level 4
Level 4
Posts: 300
Joined: Sun May 29, 2011 3:26 am
Location: Thailand
Contact:

Re: Is there a logic to the directory structure?

Post by Garvan »

wallaroo wrote:
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
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.

You can see this list by running 'echo $PATH' on the command line.
Thank you, it should have been obvious, but I did not think of checking the path.

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)
RJim

Re: Is there a logic to the directory structure?

Post by RJim »

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. :mrgreen:

--Jim
RJim

Re: Is there a logic to the directory structure?

Post by RJim »

Guess I'm not the only one who isn't sure about these things. :lol:
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.
DrHu

Re: Is there a logic to the directory structure?

Post by DrHu »

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?
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..

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]
Also remember that Linux is a multiuser, multitasking OS, and so does consider remote directories etc in considering its file system design.. There isn't an absolute standard, because various Linux distributors have historically used some locations that were included into the FHS (File Hierarchy Standard) for compatibility's sake!
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..
The reason it is slow to change, if it would ever be done is this compliance need to match/keep older customers of a particular Linux distributor's versions.
--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..
User avatar
MALsPa
Level 8
Level 8
Posts: 2040
Joined: Mon Nov 19, 2007 10:17 pm
Location: albuquerque

Re: Is there a logic to the directory structure?

Post by MALsPa »

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:

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
Also:

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
...
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):

Code: Select all

$ dpkg -L geany
In Fedora, I'll use Yumex to find the filelist, or else run a command like this:

Code: Select all

$ rpm -q -l geany
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.
User avatar
MALsPa
Level 8
Level 8
Posts: 2040
Joined: Mon Nov 19, 2007 10:17 pm
Location: albuquerque

Re: Is there a logic to the directory structure?

Post by MALsPa »

Here's a paragraph that seems kinda helpful:
For 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.
http://www.goinglinux.com/articles/Inst ... tions.html
RJim

Re: Is there a logic to the directory structure?

Post by RJim »

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! :D
perduta

Re: Is there a logic to the directory structure?

Post by perduta »

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

Code: Select all

tree /
My reaction was :roll:
User avatar
bjornmu
Level 3
Level 3
Posts: 189
Joined: Wed Dec 19, 2012 2:50 am
Location: Trondheim, Norway

Re: Is there a logic to the directory structure?

Post by bjornmu »

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.
Locked

Return to “Beginner Questions”