Linux directory structure

From Mandrivausers Wiki

Jump to: navigation, search

The purpose of this article is to aid your understanding of the way the Linux filesystem, or directories (folders), are laid out, and to help you learn the basics of manoeuvering through them.

[edit] Understanding the Directory Structure

Without covering every directory, here's a metaphor to help you understand how the directories (folders) are laid out.

/ is the yard, and the directory /home is the house where you keep your stuff. In /home, there can be different directories (rooms) for the different people who live in the house.

Let's say Joe, the owner of the computer, is going to let his little sister Jen use his computer. There's a room in the house for both Joe and Jen: /home/joe and /home/jen. That is where each of them can keep their personal stuff, and neither of them have rights to the other's directory. You see, in Linux, every file, like an mp3, and even every directory, like /home/joe, belongs to somebody. We'll see how great this can be for security and stability later.

The directory /dev is the garage where the devices are kept. Within /dev there's /dev/cdrom (for your CD drive), /dev/fd0 (for your floppy drive), and so on. However, these are more like files that define the device drive rather than what is on the cdrom in the drive, say.

/mnt is a special directory. Distributions usually mount devices in /dev for you, but here's what is happening. To use a device, i.e. to be able to see files on a cdrom, you need to mount the /dev/cdrom to /mnt/cdrom. Now, if you look in /mnt/cdrom, you will see the files on the plastic disc in the drive /dev/cdrom. Picture /dev/cdrom as the engine, and /mnt/cdrom the running car. Which would you rather get into? The same goes for your floppy disks - /dev/fd0 usually gets mounted to /mnt/floppy.

So let's recap the filesystem layout:

/ - the root directory - every other directory is contained within / (and that is why we usually write their names preceded with a / - it's the root of the filesystem.)

/bin - This isn't a bin for trash! This is where system binaries are kept. Binaries are executable files that you can run, and they are for programs that run the operating system.

/boot - All the files for booting up your computer and loading the OS are kept in here.

/dev - All your devices, like CDROMs and floppy drives, are in here.

/etc - this is where the system configuration files are kept (the way the OS is setup, so to speak).

/home - Within home, there is always a directory for each user. If your name is Joe, you are only allowed to download and save files (or change existing files) in /home/joe (sometimes called ~).

/usr - this is where applications go. Inside /usr looks very much like a mini / but the difference is instead of OS binaries or configs, it's the binaries or configs for applications not vital to the OS such as office or games. All users are allowed to run apps in /usr , but they aren't allowed to alter or delete the files there in any way.

  • /usr/bin - binaries for apps like office or games
  • /usr/etc - configs or setup for them
  • /usr/src - source code for the apps (preinstalled packages)

/var - If you're running a server, the files that you are serving other people on the internet (like music or webpages) would be contained in here.

[edit] External links

Personal tools