13

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.

4 Answers 4

14

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.

6

Its just so happens that there is a standard in the Unix-like OS world called the Filesystem Hierarchy Standard that explains the best practices that most Unix vendors follow. Its a good read and well worth going over if you spend much time in *nix environments.

Filesystem Hierarchy Standard

Answers to your questions:

Both /usr/src and /usr/local/src work. Your choice. Just keep is consistent.

/bin is for required commands for users. I would NOT place custom binaries there.

/sbin is for system binaries (usually sysadmin stuff). It contains stuff for booting and fs utils.

/usr/bin is where most user commands live and you will usually find that most Linux package management systems place binaries or at least symlinks to binaries here.

/usr/local/bin is safe place to put you're own compiled code that is unique to that machine.

6

Maybe you should take a look at these:

alt text

alt text

3

/usr/local/ is for software that was compiled on this system. It's similar to /usr/, just that it wasn't installed from packages.

/sbin/ vs /bin/ (and /usr/sbin/ vs /usr/bin): s stands for superuser. Programs that normal users shouldn't care about and often shouldn't have permission to run

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .