Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

  • Print
  • + Share This
This chapter is from the book

Understanding How Linux Stores and Organizes Files

If you have not used Linux before, the way that Linux stores and organizes files is likely to be new to you because the layout is quite different from Windows and Mac OS X.

In the Windows world, each disk drive is labeled with an identifying letter such as C: for your hard disk and D: for the CD/DVD drive. In the Linux world, however, everything is part of the same filesystem organization. As such, if you have two or three hard disks, a CD drive, and a USB stick all plugged in, they will all be part of the same folder structure.

The diagram shown in Figure 4-9 should give you an idea of how everything hangs together.

Figure 4-9. Linux filesystem organization

Right at the top of the tree is the root folder, referred to as /. Inside this folder are a number of special system folders, each with a specific use. As an example, the /home folder contains a number of home directories for each user on the system. As such, the user account has the home folder set to /home/matthew.

Which Folder Does What?

The folder structure in a modern Linux distribution such as Ubuntu was largely inspired by the original UNIX foundations that were created by men with large beards. Although you don’t really need to know what these folders do, since Ubuntu looks after the housekeeping for you, some of you may be interested in the more important folders. To help, we present the Linux folder hit list in Table 4-1.

Table 4-1 Linux Folders

Folder

Use

/boot

This folder contains important files to boot the computer, including the bootloader configuration and the kernel.

/dev

Each device on your system (such as sound cards, Webcams, etc.) has an entry in this folder. Each application accesses the device by using the relevant items inside /dev.

/etc

Systemwide configuration files for the software installed on your system are stored here.

/home

Each user account on the system has a home directory that is stored here.

/lib

Important system software libraries are stored here. You should never need to delve into this world of the unknown.

/media

Media devices such as CD drives and USB sticks are referenced here when they are plugged in. More on this later.

/mnt

Other devices can be mounted too. Again, more on this later.

/opt

Optional software can be installed here. This folder is usually used when you want to build your own software. If you don’t build your own software, you ignore this folder.

/proc/sys

Information about the current running status of the system is stored here.

/root

This is the home directory for the main superuser.

/bin

Software that is vital for the system to be able to boot is stored here.

/sbin

Software that should be run only by the superuser is stored here.

/usr

General software is installed here.

/var

This folder contains log files about the software on your computer.

Configuration Files

In Table 4-1, /etc is described as storing systemwide configuration files for your computer. Aside from these files that affect everyone, there are also configuration files for each specific user. Earlier, when you customized Ubuntu’s look and feel, the settings were applied only to your current user account. So where are those settings stored?

Inside your home directory are a number of folders that begin with a dot (.), such as .config and .libreoffice. These folders contain the configuration settings for user-specific applications. By default, these dot folders are hidden in the graphical file viewer because you rarely need to access them. You can view these hidden files and folders when you are viewing your home folder by clicking View > Show Hidden Files in the menu or by pressing Ctrl-H.

Using Windows Files on Another Partition

For those of you who spend a considerable amount of your life on Windows partitions, you may want to be able to access these partitions from Ubuntu. This is no problem, although you will need to edit a special configuration file to do this. Luckily, you need to edit this file only once, and then everything will be set up.

Ubuntu should automatically recognize any Windows partitions you have on your computer and set them up for you; however, you may need to modify them or add your own. Search for Disk Utility in the Dash and write down the partition numbers and filesystem for your Windows partitions. The partition number will look something like /dev/hdb1 or /dev/sdb1, and the filesystem will be either FAT, VFAT, or NTFS.

The next step is to create some mount points. When your Windows partitions are enabled, they are accessed via a particular folder in Ubuntu. This is called a mount point. As an example, if you have a mount point as /media/win1 and on your Windows partition you want to access your Work folder, you would access it from Ubuntu as /media/win1/work.

Mount points usually live in the /media folder. Create a different mount point for each Windows partition. As an example, if you have three Windows partitions, run the following commands:

foo@bar:~$ sudo mkdir /media/win1
foo@bar:~$ sudo mkdir /media/win2
foo@bar:~$ sudo mkdir /media/win3

Now open up the following configuration file:

foo@bar:~$ sudo gedit /etc/fstab

The /etc/fstab file maps partition numbers to mount points. At the bottom of the file, add a line like this for each mount point:

/dev/hdb1 media/win1 vfat users,rw,owner,umask=000 0 0

You will need to change the partition number (the first column), mount point (second column), and filesystem (third column) for your relevant partitions.

Now reload /etc/fstab to enable the partitions:

foo@bar:~$ sudo mount -a

Some hard disk icons for the new partitions now appear.

  • + Share This
  • 🔖 Save To Your Account