Linux file system

file managementlinuxlinux-distributions

What are the conventions for file locations in Linux? So far I've managed to deduce:

/proc (references to running processes)

/dev (references to all hardware)

/etc (configuration files)

/home (home)

/mnt (mounted devices)

/media (removable devices like CDs, USB disks)

…but other parts are still unclear, for example:

Where do I put downloaded source?

/usr/src

/usr/local/src

Where do I put compiled programs?

/bin

/usr/bin

/usr/local/bin

What is the difference between /bin and /sbin?

How do the distributions differ?

I realise these are not one question, but it would seem to me they should all be answered together. Hopefully others are also confused.

Best Answer

You might want to read the Filesystem Hierarchy Standard; it's a useful reference.

Your home directory is where most of that should go. Pretend you're not the sysadmin; pretend you're yet another person with an account on the system. Within your home directory, e.g. /home/pufferfish, you can do whatever you want. /home/pufferfish/bin, /home/pufferfish/lib, and /home/pufferfish/src are all conventional choices, but none of it really matters.

For compiled programs, whichever directory/directories you use, make sure it/they is/are on the PATH so that you can actually run them without typing in the script or executable's entire path.

The distributions don't really differ much. I've found that the package manager on one might install binaries in /usr/bin, while some libraries may go elsewhere, and another system might install things in yet another place. I generally have to do some research to find where things go each time.