0

The way  Linux  organizes its files on the hard drive is vastly different from how Windows handles this task. New  Linux  users coming from Windows sometime have a hard time maneuvering though directories or come with notions that  Linux  should manage its files in the same vain as Windows.

This article was written to help new users get a grasp on moving through directories on their new installation. One key point to make is Windows deals with "drives" as in your C: drive or D: drive,  Linux  deals with something called 'mount points'. These are locations where other hard drives, CD/DVD burners, etc... connect to the root partition. Don't worry it will all make sense latter on.

It All Begins With Root: /

The root directory known simply as '/' is the starting point. Without getting to technical, the root directory acts like the 'C: Drive' in Windows. A  Linux  system can not fully boot without a root partition, in the same way as deleting your C:WINDOWS folder will make your Windows computer inoperable.

It's In: /bin

The /bin folder holds important system programs. The 'bin' is short for 'binary'. Some of the popular programs: date, less, more, cat, dmesg. These programs are essential in order to start and have a complete operating system. While you may never use one of these programs personally, the system relies on some of them.

Where Everything Starts: /boot

As the name implies, /boot is where the crucial files reside, mainly the kernel. Without the kernel, you don't have a system. Another crucial program located in /boot is the bootloader. Just like  Linux  needs the kernel to function. The bootloader is there to actually locate the kernel and begin running it.

Every Device Is A File: /dev

In  Linux , every device is a file. What this means is, when you connect a hard drive to your system it gets a 'device file' that allows the system to interact with it. When the kernel locates a new hard drive it is assigned a file like "/dev/sda". The /dev part is the directory and the 'sda' part is the file that connects to the hardware. So if you wanted to format your whole drive you could type in the command 'dd if=/dev/null of=/dev/sda'. This would copy /dev/null into your hard drive. /dev/null is a "bit bucket". Meaning that everything that gets sent to it gets deleted.

Configuration-ness: /etc

 Linux , being a customizable system keeps all the programs config' files in this directory. Most programs come with a sensible and secure default behavior. But what happens if you want to change it? The /etc holds a slew of text files for you to open and customize how your programs operate. An important note to make is /etc manages global defaults. What this means is if you change a file this directory, it will affect the whole system.

The Shared Libraries: /lib

The /lib directory is a way to keep all software libraries in one central location. Most (if not all) files here have a file extension of '.so' to let you know they are 'shared object' files. These files are code that can be used by multiple programs. This helps prevent a problem known as 'software bloat'. Windows also has these files; they are called 'Dynamically Linked Libraries' or DLL for short. As a regular  Linux  end user, you will most likely never have to change anything in this folder. Depending on how you install software on your computer, you might come across a 'missing shared object' problem if your software "depends" on another program to function. The Windows equivalent is 'DLL hell'.

When You Don't Shut Down Correctly: /lost+found

This directory is used when the user does not shut down the system correctly (turning it off when the system is still up and running). Upon the next boot, the system will try and correct itself by scanning the hard drive for corrupt files and try to correct any problems that arise. If anything is found, it will be placed in the /lost+found directory for the systems administrator (you!) to see and look over.

Where The 'Mount Points' Live: /mnt and /media

The /mnt and /media directories are for 'attaching' other devices to the root directory. In Windows, when you insert a USB thumbstick, you will see the system gives it a drive letter (E:). Depending on which  Linux  distribution you use, the device will either 'auto mount' or the user has to mount the device manually. Most newer, newbie friendly distros will auto mount the device and place it in one of these directories. You will be able to browse the files within your thumbstick at /mnt/usb or /media/usb. Each distribution is different, so my example could not exactly match your results.

/media is the newcomer to the  Linux  scene. Most older distributions exclusively used /mnt to manage these devices, but /media is gaining ground as the default location to mount devices.  Linux  allows you to mount any device anywhere (as long as you have the permissions). So it is completely feasible to mount one device under '/bin/mount' or '/var/log'. This is usually not a good idea and the /mnt and /media directories where put in place to make this easier.

The 'Optional' Directory: /opt

This is where users can install software if no other suitable location can be used. Most software from major  Linux  distributions have 'software repositories' which allow users to easily add and remove tons of programs. But what happens when you need a program that isn't in the repository? In order to separate repository software packages from 'external' packages, sometimes the best way to install them is putting them in /opt. This practice is rarely used though and each distribution is different. Some will place the popular KDE into /opt, while other distributions won't.

My personal rule of thumb is to use /opt when the software you are installing defaults to this directory (The Google Earth program does this) or I am installing a program that I didn't get in the software repository.

The Kernel's Directory: /proc and /sys

Both of these directories hold a wealth of information about the status of your system. Files like '/proc/cpuinfo' contain information about your CPU (speed, vendor, cache size). The /proc directory is slowly being faded out in favor of /sys.

You Were Here And Now Your Gone: /tmp

The /tmp directory is short for 'temporary'. So with that in mind, I am sure you can deduce why this directory is used. You got it, to manage temporary files. Programs can generate a lot of 'junk output' or need to write to a file to handle a task; but the file can be deleted once the task is completed. This directory provides a central location to do this and not fill your other directories with these files.

Where The Programs Live: /usr

The /usr directory is a monster. Articles could be written just to explain it all. But to keep things short and sweet, the /usr is where all of your 'secondary' programs are stored. Granted you love your music player, but it's not crucial to your operating system actually functioning. So instead of putting all the executables in /bin, we break it up a bit. We place crucial system programs in /bin and non-critical programs into /usr/bin. The /usr directory could be seen as the Windows equivalent as C:Program Files.

The Not So Temporary Files: /var

/var (for varying or variable) acts like /tmp in the sense that the files located are 'temporary' but less 'temporary' then those in /tmp. What this really means is the /tmp directory will most likely be deleted every time the system reboots, while the files in /var will not. /var is a place to keep 'persistent' files. An example would be log files. Most system administrators wouldn't want to delete their log files on every reboot, but the files could be removed or 'shrunk' to a more manageable level at the administrators whim.

Another example would be '/var/mail' directory. It contains the mail being sent to users on the system. Some users will have hundreds of messages, while other users will have a few or none. The directory is growing and shrinking depending on the usage by the users. So in order to keep the disk usage under manageable levels, we place this activity under /var. On large systems, the system administrator will use a separate hard drive and 'mount' the hard drive at /var. This allows the frequent disk access to remain on one hard drive and keep the overall system speedy.

Conclusion

Well I hoped that this article has better acquainted you to how files are stored on a  Linux  system. If I left anything out (or for general praise), please feel free to comment on the article.





Source by Brandon Sherwood

Post a Comment

 
Top