Select Page

The Linux Folder Structure is pretty different from that of Windows. If you’ve been a Mac user, it’s very similar to what you’ve been using, even if you didn’t know it. A “folder structure” is a collection of files and the folders they reside in. We’ll explore differences and similarities between Linux and Windows, and hopefully make things a little clearer.

First of all, you need to understand the Zen of the Linux file system. In Windows, you’re probably used to opening Explorer and seeing the various drives. Your floppy is one drive, usually called the “a” drive.

The hard drive, if you had only one, was usually the “c” drive, on which were your programs and data. The CD-ROM drive was the “d” drive. You could click each one and use things inside it. Each of these is a “filesystem” – an independent folder structure. Windows just arranged a way for you to access all of these different filesystems on different disks.

In Linux, there is one filesystem. That’s right. One. Instead of having you access a different filesystem for each drive, Linux grafts all the different drives into one giant filesystem. The process of grafting a filesystem into that giant one is called mounting. It’s even the same if you’re browsing a network. You don’t browse to a separate, network filesystem. Linux actually grafts that network drive temporarily to its giant filesystem. And that filesystem has a folder structure.

The Linux folder structure is referred to in the following way. There aren’t any letters like “c.” The very top level is / which is called slash. So if there was a file at the top level named sample.txt, you’d refer to it as /sample.txt. If that file were in a folder one down from the top, it would be /folder/sample.txt and so on. To refer to that folder, you would write /folder. When you put a floppy disk in, Linux grafts it in as /mnt/floppy/. A CD-ROM is mounted as /mnt/cdrom/.

This may remind you a little of web addresses. That is because the Linux folder structure was adapted from the filesystem of Unix. Unix is a powerful operating system that has been around for a long time, and was in many of the original computers powering the Internet.

That top level is the root of the folder structure. This is where we get the term root which is the highest security clearance a Linux computer can have. Remember the importance of root access. If you haven’t already read the article on root privileges, you should do so now. By default, assume that everything in the folder structure belongs to root. This means that if your normal login name is bryan and you log in as that, you really can only change the things in /home/bryan. If you try to go in as bryan and change something in the “/etc/” folder, you will not be able to save the changes. If you need to change something there, you will need use the sudo command at the console along with the command to run and then type your password (this assumes you’re an administrator). This will allow you to edit and do things as if you were root. Other folders in the folder structure will only allow root to see the contents of a file or folder. So Bryan can’t even see some things unless he goes into root mode.

Below is a typical Linux folder structure.

The top level folders (those just below /) are:

  • /bin – these are the programs that your system absolutely must have to run. Think of these as a bin or bucket at the hardware store filled with tools.
  • /boot – these are the files Linux uses when it boots up.
  • /dev – all the hardware on your system is catalogued here so that Linux knows what hardware you have and how to reach that hardware.
  • /etc – these are the configuration files for the system. This folder is where Linux sets how things should be run and when.
  • /home – this is the users’ home where all users files are stored. Beneath this folder are folders for everyone that uses the computer. So if Bryan and Steven have to share a computer, when Bryan logs in, he uses the “home” folder /home/Bryan, while Steven uses /home/Steven. In Mac OS X, these are in a folder named /Users
  • /lib – this is where Linux stores the libraries for basic tasks that it handles.
  • /lost+found – this is where files that are recovered by the system during maintenance are placed.
  • /media – this is where the system mounts other drives to by default.
  • /mnt – this is another place where drives may be mounted.
  • /opt – this is for “optional” software, which could really be anything.
  • /proc – this is for process status files, so that Linux knows what’s being worked on and what hardware is being used.
  • /root – this is the “home” directory for root.
  • /sbin – these are more programs that the system needs, but many of them can only be used by “root.”
  • /shared – mine is empty so I’m not sure what it’s for- my guess is you could share files here with other users of your computer.
  • /srv – files relating to a few services exposed as servers.
  • /sys – system information.
  • /tmp – these are temporary system files.
  • /usr – essentially, this is the “Program Files” of Linux. Programs, libraries and graphics for programs not essential to run Linux are stored here.
  • /var – this is where Linux stores system logs, printer and email queues, as well as various information it needs.

When you log into Gnome, or your desktop of choice, you might think “Hey, if I just log in as root here, I can do anything in Linux.” This is technically true. However, try not to ever log into your desktop as root. It can potentially cause all kinds of problems. When you have the root password, you have total power over a computer. That kind of power should be used carefully and cautiously. Always log in as a normal user.

Your normal user account will have what’s called a “home” directory, roughly equivalent to what Windows was trying to do with the My Documents folder. It’s located at /home/yourusername/. It’s the place where all your stuff is. It essentially is your private kingdom. You can install things into it, store things in it, create or destroy folders in it, etc. And other users can’t even see what’s in it. It’s downright amazing!

Outside this folder, however, you will find that you have limited powers. For some of them, you’ll be able to see what’s in all the other folders, but you won’t be able to do anything to them, because they’re owned by root or another user.

For example, you can go into /usr/bin, which is where all your programs are stored, and see a list of them, but you can’t delete them or add any new ones there without being root.

So the Linux folder structure is different than that of Windows. In some ways, very different. But all in all, much better. Take the time to familiarize yourself with the folders in the filesystem if you want to. Don’t worry about doing it, since, if you’re logged in in your normal user account, you won’t be able to mess anything up!