Finding your way around the Linux filesystem

Posted by Anonymous on Mon 26 Sep 2005 at 14:23

Tags: none.

If you've ever been confused at all the directories present within your Linux system here is a quick overview of the directories in common use, and what they contain.

All of this information was condensed from the text in the output of the following command:

skx@home:~$ man 7 hier

If you have the manpages package installed (recommended) you can run it yourself.

/

This is the root directory. This is where the whole tree starts.

/bin

This directory contains executable programs which are needed in single user mode and to bring the system up or repair it.

/boot

Contains static files for the boot loader. This directory only holds the files which are needed during the boot process. The map installer and configuration files should go to /sbin and /etc.

/dev

Special or device files, which refer to physical devices. See "man 1 mknod" for details on creating new nodes.

/etc

Contains configuration files which are local to the machine. Some larger software packages, like X11, can have their own sub-directories below /etc. Site-wide configuration files may be placed here or in /usr/etc. Nevertheless, programs should always look for these files in /etc and you may have links for these files to /usr/etc.

/etc/opt

Host-specific configuration files for add-on applications installed in /opt.

/etc/skel

When a new user account is created, files from this directory are usually copied into the user's home directory.

/etc/X11

Configuration files for the X11 window system (optional).

/home

On machines with home directories for users, these are usually beneath this directory, directly or not. The structure of this directory depends on local administration decisions.

/lib

This directory should hold those shared libraries that are nec- essary to boot the system and to run the commands in the root filesystem.

/mnt

This directory contains mount points for temporarily mounted filesystems

/opt

This directory should contain add-on packages that contain static files.

/proc

This is a mount point for the proc filesystem, which provides information about running processes and the kernel. This pseudo-file system is described in more detail in "man 5 proc".

/root

This directory is usually the home directory for the root user

/sbin

Like /bin, this directory holds commands needed to boot the system, but which are usually not executed by normal users.

/tmp

This directory contains temporary files which may be deleted with no notice, such as by a regular job or at system boot up. (Debian does clean /tmp as part of the boot process - unless you prevent it.

/usr

This directory is usually mounted from a separate partition. It should hold only sharable, read-only data, so that it can be mounted by various machines running Linux.

/usr/bin

This is the primary directory for executable programs. Most programs executed by normal users which are not needed for booting or for repairing the system and which are not installed locally should be placed in this directory.

/usr/bin/X11

The traditional place to look for X11 executables; on Linux, it usually is a symbolic link to /usr/X11R6/bin.

/usr/games

Binaries for games and educational programs (optional).

/usr/include

Include files for the C compiler.

/usr/include/g++

Include files to use with the GNU C++ compiler.

/usr/lib

Object libraries, including dynamic libraries, plus some executables which usually are not invoked directly. More complicated programs may have whole subdirectories there.

/usr/local

This is where programs which are local to the site typically go.

/usr/local/bin

Binaries for programs local to the site.

/usr/local/sbin

Locally installed programs for system administration.

/usr/local/src

Source code for locally installed software.

/usr/sbin

This directory contains program binaries for system administration which are not essential for the boot process, for mounting /usr, or for system repair.

/usr/share

This directory contains subdirectories with specific application data, that can be shared among different architectures of the same OS.

/usr/src

Source files for different parts of the system, included with some packages for reference purposes. Don't work here with your own projects, as files below /usr should be read-only except when installing software.

/usr/src/linux

This was the traditional place for the kernel source. Some distributions put here the source for the default kernel they ship. You should probably use another directory when building your own kernel.

/var

This directory contains files which may change in size, such as spool and log files.

/var/cache

Data cached for programs.

/var/lib

Variable state information for programs.

/var/lock

Lock files are placed in this directory.

/var/log

Miscellaneous log files.

/var/run

Run-time variable files, like files holding process identifiers (PIDs) and logged user information (utmp). Files in this directory are usually cleared when the system boots.

/var/spool

Spooled (or queued) files for various programs.

/var/spool/at

Spooled jobs for at.

/var/spool/cron

Spooled jobs for cron. See command scheduling with cron for more details.

 

 


Posted by Anonymous (66.179.xx.xx) on Mon 26 Sep 2005 at 22:21
FHS is a bit more complete. You should at least provide a pointer.

[ Parent | Reply to this comment ]

Posted by Anonymous (213.164.xx.xx) on Tue 27 Sep 2005 at 11:56

[ Parent | Reply to this comment ]

Posted by Anonymous (193.92.xx.xx) on Tue 27 Sep 2005 at 16:21
Yes Yes...You should even. :)

[ Parent | Reply to this comment ]

Posted by fsateler (201.214.xx.xx) on Wed 28 Sep 2005 at 01:45
[ View Weblogs ]
I've always wondered about /srv. Supposedly, all services that your computer provides should have their files there... However, internet servers have always had the files they serve in /var/www, or not? Should they have those files in /srv/www?
--------
Felipe Sateler

[ Parent | Reply to this comment ]

Posted by Anonymous (213.164.xx.xx) on Wed 28 Sep 2005 at 09:16
"The methodology used to name subdirectories of /srv is unspecified as there is currently no consensus on how this should be done..."
-- http://www.pathname.com/fhs/pub/fhs-2.3.html#SRVDATAFORSERVICESPR OVIDEDBYSYSTEM

[ Parent | Reply to this comment ]

Posted by eric (82.249.xx.xx) on Sat 1 Oct 2005 at 17:30
[ View Weblogs ]
I'm always confused about where I should mount other filesystems : I got some FAT and EXT3 partitions I use to store data (iso, backups, sources...) or media (videos, music...) and I don't know where I have to mount this filesystems.
I use /mnt (/mnt/media, /mnt/data for example) but where is the preferred location to this type of mount filesystems ???
(I don't use /home because I want to give access to some usergroups (example : data, media))

any idea ?

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Sun 2 Oct 2005 at 12:48
[ View Steve's Scratchpad | View Weblogs ]

I've always used /mnt for this purpose.

Actually one of the first things that I do when I install a Debian system is :

rm /floppy /cdrom

mv /media/cdrom*   /mnt
mv /media/floppy*  /mnt

rmdir /media

That way all mount-points are beneath /mnt.

I don't see the point of having a seperate mount directory for removable media and remote hosts. So they both live together.

Steve
--

[ Parent | Reply to this comment ]

Posted by eric (82.249.xx.xx) on Sun 2 Oct 2005 at 18:29
[ View Weblogs ]
I profit from this article about the debian filesytem hierarchy to ask a question about the options to give to a 'configure' script when compiling a program from source.
Since this article about checkinstall, I usually make debian packages for programs which are not in Debian (or in the branch I use : sarge actually).
I install these programs in /usr/local, but I'd prefer install it the 'debian way' i.e. using the debian way of organizing directories.

This is what './configure --help' give me :

Fine tuning of the installation directories:
  --bindir=DIR           user executables [EPREFIX/bin]
  --sbindir=DIR          system admin executables [EPREFIX/sbin]
  --libexecdir=DIR       program executables [EPREFIX/libexec]
  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
  --libdir=DIR           object code libraries [EPREFIX/lib]
  --includedir=DIR       C header files [PREFIX/include]
  --oldincludedir=DIR    C header files for non-gcc [/usr/include]
  --infodir=DIR          info documentation [PREFIX/info]
  --mandir=DIR           man documentation [PREFIX/man]
I think I can complete (correctly) some of these options, but not all.
I think
--bindir=/usr/bin
--sbindir=/usr/sbin
--datadir=/usr/share
--sysconfdir=/etc
--localstatedir=/var
--libdir=/usr/lib 
--includedir=/usr/include
--infodir=/usr/info
--mandir=/usr/man
are ok, but are they really ?
and what about other options (libexecdir, sharedstatedir, localstatedir, oldincludedir...) ?

I hope someone can help me...

thanks all.

[ Parent | Reply to this comment ]

Posted by grimoire (80.5.xx.xx) on Thu 6 Oct 2005 at 12:25
You probably need to read the Debian maintainer's guides to find out the correct places for a Debian package to place files.

Incidentally, if you're creating packages from the testing or unstable releases to run on stable, then backporting using the Debian source is probably the best way to do it.

[ Parent | Reply to this comment ]

Sign In

Username:

Password:

[Register|Advanced]

 

Flattr

 

Current Poll

What do you use for configuration management?








( 684 votes ~ 10 comments )