Linux File StructurePublished: 1/12/2009File SystemBefore reading this read File Structure.doc The Linux filing structure is managed in a selection of directories within a root tree. The filing system is very close to Windows in that directories can have subdirectories. On a Windows based computer you can view the tree to the file structure. You can do the same on Linux based computers. Linux however does not have a c:\. The Linux root directory (C:\) is located at /. This location holds a number of directories that will be explained in detail below.
Remember to view files in directories you can use the CLI command # ls /bin To list the /bin directory # ls –la To list all files and their permissions What's in //binThis directory holds all the binary files that the user will normally run from the CLI. Some of these applications will only run within the CLI and others are set to run within a GUI. The command ‘cat’ is located within this directory. Running this command from within the GUI (double clicking the program) will have no effect as this is a CLI program for displaying the content of a text file.
Other programs can be run from the CLI like ‘kate’ (Linux’s Notepad). All users of the system can run every program within this directory. As a system administrator for your own Linux domain it is your responsibility to make sure that programs in this directory are secure, up-to-date and stable. /sbinThis contains the binaries, programs, scripts and applications that should only be access by users with high privileges. This would be people whom administer the computer. /etcThis is a hugely important directory as it contains most of the main configuration files for the Linux system and applications. If anything needs to be fine-tuned or modified then this can be done by editing the appropriate file within this directory. The Linux community has gathered together to create GUI tools to modify most of these files.
It is possible to manual edit these files but with the use of the CLI command # useradd gizard # passwd gizard # groupadd developer The need to manual edit these files no loner exist. The GUI tools like Kuser and Drakeuser now have a graphical user interface to easily modify these files. The list of directories within /etc/ will differ from computer to computer depending on software installed and Distro’s used. Note: This directories is not the same and Windows “c:\Program files\” as there are no applications installed within /etc/ just configuration files. /homeThis directory stores all the documents that are created by the users of the system. Ever user will be given a directory named after them within this directory. I.e. if your username is “gizard” then your own directory will be /home/gizzard/. You will be able to save files to this area. No other users should be able to access your files within this area. When you click on the “Home” icon on your desktop, this is the location you are taken to. On a college system you would see directories called. /home/3004563 /home/3004564 /home/3004565
/procThis is a very impressive directory in the fact that this directory does not exist. This directory is stored in RAM (virtual Memory) and is never stored onto the hard drive. The files in this directory relate to the systems processes and kernels status. This could be the amount of time these system have been turned on for to what drivers are currently in use. The /proc directory holds many subdirectories with numbers for names. #ls /proc/ 10203/ 34344/ 534533/
These numbers relate to processes (programs running) the system is running. Using the CLI view some of these files.
# cat /proc/23232/cmd /bootThis directory holds the files needed to boot the system. These files are configurable so if you wished to boot your computer with all the drivers to run the latest games and multimedia devices then you can reconfigure the Linux kernel to support this. Change the setting within this directory will then allow the user to choose which kernel version to load (The basic or the full Multimedia). The /boot directory stores the location for the Linux Kernel (mvlinuz). /usrThis directory contains all the applications that are extensive. This could be application like Open Office. There are a number of sub-directories within the /usr directory.
/usr/docThis is the location for some of the applications on the computer.
/usr/shareConfiguration and graphics files for some applications. This in similar to /etc/ for applications. /usr/srcsource code for programming. This contains the files that programmers need to programs applications.
/usr/includesource code for programming, normally header files. This contains the files that programmers need to programs applications.
/usr/X11R6This contains the files, programs and graphics needed for X. X is the application that allows the GUI to be displayed on the screen.
/usr/localThis is where the applications that are not part of the Operating Systems Distro are installed. Also the applications within this location are not network capable applications; they are for the local computer.
/usr/binThis is where applications that are part for the main Distro are stored.
/libLinux is very heavy on dependences (covered in latter sessions). It is important to have the right files on your system if you wish to run a given program. On a Windows computer if you wished to run a game that needed DirectX then any system without DirectX would not be able to play the given game. The same is true for OpenGL and all DLL files. Linux stores commonly used files in the /lib (short for library) directory. Applications use these files. This will be discussed in latter sessions.
/tmpThis directory allows users to store temporary data within it. The data within /tmp cannot be deleted by other users (apart from root) of the system. The files created in the directory /tmp can be read by any valid user on the account and can also be modified. Some programs/applications use this area to temporally store data. This is now becoming less so due to security issues. /devThis is the location of all your hardware devices. Linux classes every device as a file within this directory (/dev). Therefore your floppy drive is classed as being on one file (/dev/fd0). Reading this file will produce every bit located on the inserted floppy disk (even if the disk is empty but not formatted). If you where to write to this file then the data would be written to the floppy disk. This is the same for graphics cards, hard drives, mice and any other device attached to your computer. The /dev location lists hundreds of different devices some of which are not attached to your system. The devices listed within the /dev directory are all the devices that are supported by the current Linux kernel. These devices can be removed but do not take up any resources, as the modules to the devices are not loaded onto the system.
/varThe /var directory contains data that changes with the system. This location holds logs about the system and applications. Mail and the servers web site can also be stored within this directory.
/var/log/var/log contains the log files to the system. A good source of information to find out what are system and users are doing.
/var/mailThe /var/mail directory contains the mail accounts details and emails themselves.
/var/spoolThe /vat/spool contains details about current print processes and other waiting device jobs.
/mntThe /mnt stores the location of the removable devices currently usable on the system. Note that the files within /dev are useless unless the data is formatted. When you wish to use a device like the floppy drive you must first mount this device so then the data can be formatted. The /dev/fd0 device is normally mounted to the /mnt/floppy. The user can then view the /mnt/floppy location using Konqueror to file the files on the floppy.
/lost+foundThis directory should store no files. When a Linux computer crashes or a user shuts down the system unexpectedly the computer becomes unstable. On reboot the system will check the hard drive data for errors. If it can not fix the errors found then the files are placed in the lost and found directory. Normally there is only root that can access this location. As a system administrator for you own computer it is your job to check this location. This is a good way of recovering files that would have been lost. Related PostsLinux File Structure Part 2Last Updated: 1/12/2009When you wish to use the CDROM drive it must first have a cdrom in the drive and data on the cdrom. To view the data you must mount the device to a given place of the Linux filing tree. Everything in Linux is a file. The whole partition of a hard dr Read more... Pipe and RedirectionLast Updated: 1/12/2009The command line is not only a tool for bashing out program names but an elegant and intelligent environment. Some programming languages can be typed directly into the command line. Also tasks that take some time to execute in the background leaving Read more... Mounting a DriveLast Updated: 1/12/2009In Linux, like in UNIX, diskettes and CD-ROMs need to be mounted before they can be used. What mount does is to associate the devices (floppy or CD-ROM drives) to a mount point (a directory) in the root file system. The usual mount point for diskette Read more... Linux in a nut ShellLast Updated: 1/12/2009Why should we bother learning Linux shell command when we have GUI like KDE? Read more... |