5 - the appointment of the main directories

Lecture



This lecture focuses on the Linux file system and the purpose of the main directories. First, let's see how the file system is implemented in Windows . There is a physical hard disk, which is divided into logical partitions and each section is assigned a Latin letter starting with the letter C (C :, D :, E: etc.). Each logical partition has directories and files. If we add, for example, another hard disk, the next free letter will be assigned to it.

Linux is organized differently. The basis of everything is the so-called “root” or “root”. Denoted by the symbol / . The root of the file system is a virtual object in the kernel. The kernel creates a virtual root, and then mounts disks (file systems) to it using the mount command. Users working in Windows are initially hard to get used to the fact that file systems need to be mounted before use and unmounted after. But over time you will get used to it. In addition, if before, inserting a disk into the drive, it had to be first mounted to the file system tree, now these actions are performed automatically. Later we will talk more about mounting, but for now let's consider the purpose of the main Linux directories.

/ bin - this directory contains utilities (executable files) for working at the system level. Examples include ls, date, cp, pwd , etc.

/ sbin - this directory contains system utilities and programs that are designed to manage the system itself. Example: shutdown, init, ifconfig .

/ boot — This directory contains the system startup files: the kernel, the GRUB files , the initrd , and the kernel configuration file. An initrd is a ramdisk image that is used to mount a temporary file system for the duration of the kernel boot. In fact, the initrd contains the necessary modules that allow you to mount the real file system and continue initialization and system boot.

/ boot / grub / - directory contains the GRUB boot loader and its configuration files.

/ etc - this directory contains most of the system configuration files. We have many subdirectories each of which is responsible for a specific area. consider some of them. / alsa - enhanced sound device support, /sane.d - scanner support, / X11 - graphics subsystem files, /init.d - scripts that manage services, /rc0.d - /rc6.d - contain scripts that should be executed at the appropriate level ( runlevel ), /cron.d - files of the periodic process start service, / cups - print service files, / samba - configuration files of the same system, / udev - files of the same subsystem.

/ home - home directories of users registered in the system are placed in this directory. As a rule, the names of home directories coincide with the user login.

/ root - root user directory.

/ selinux is a directory of the subsystem of the same name, which appeared not so long ago and allows for more strict control of user rights (including root) for greater security.

/ lib - this directory stores the libraries of the operating system and applications.

/ lib / modules / - directory containing kernel modules. This directory contains subdirectories that match the kernel versions that were installed on the system. That is, for each version of the kernel there is its own set of modules. This is very important and you need to pay attention to it. Often, when compiling the kernel, they forget to change the version, the new kernel uses the modules of the previous version when it is loaded, and the system does not boot. The current kernel version can be found using the uname -r command, the returned version will necessarily coincide with the name of one of the directories in / lib / modules / .

/ lib / modules / kernel version / kernel / drivers / - modules that support individual devices (video adapters, network cards, sound cards, etc.). For example, /lib/modules/2.6.28-15-generic/kernel/drivers/net/ contains modules for supporting various network cards.

/lib/modules/2.6.28-15-generic/kernel/fs/ - support modules for different file systems.

/lib/modules/2.6.28-15-generic/kernel/net/ - modules for supporting various types of networks ( Apple Talk , X25 , IPX and others).

/ mnt - directory is intended for mounting in it block devices that are not part of the Linux system. For example, the Windows partition of a hard disk is not part of Linux and is mounted in this directory exactly. Also a few years ago both CDROM and Floppy disks were mounted into this directory. Now can be mounted either in / media or directly to the root. Depends on the distribution.

/ media - designed to mount block devices that are physically connected to the system during its operation. The most common devices are flash drives, external drives. Devices are mounted to this directory as a rule automatically by the udev subsystem.

/ usr - all applications are saved in this directory (not to be confused with utilities). Linux application files, unlike Windows applications, are stored in the appropriate folders depending on the type. Therefore, in the / usr directory there are such subdirectories as / etc - for configuration files, / bin - for executable files, / lib - application libraries and others. That is, it turns out that / usr is like a root for applications. I also want to note that in many distributions application configuration files may not be located in / lib / etc / , but in / etc , and the / lib / etc / directory may not exist. The / usr directory also hosts various services such as apache , bind, and others that are not directly related to Linux . For applications that, due to certain reasons, it is necessary to store all their files in one directory (for example, they are different cross-platform applications), they invented the / opt directory. For example, there may be applications such as OpenOffice, Picasa, Chrome .

/ tmp - Directory for storing temporary files that are needed while running programs. In this directory, temporary files exist while the application that created them is running. As soon as the application stops working the temporary files are deleted. Temporary files may contain various information and some of them may be located in the / home / username / tmp / directory .

/ var - various system files are stored in this directory, such as, for example, logs of various subsystems or spooled directories of printers, e-mail, etc. For the system administrator, special attention to the directory / var / log / where just contain log files. Since these files are constantly growing, it is necessary to closely monitor the free space on the hard disk where the wheelchair / var is located . Consider the appointment of several more subdirectories located in / var . / var / lock / - files that signal the blocking of one or another system resource are stored here. / var / run / - in this directory, the running services create subdirectories containing the file and the service process identifier. For example, the file /var/run/cron.pid contains the cron service process identifier. The commands cat /var/run/cron.pid and ps ax | grep cron will show that the numbers are the same. / var / mail / - user mailbox files. / var / spool / - queues of various programs or services are stored in this directory. For example, / var / spool / cups / - contains job queues for printers.

We still have three important root directories / dev, / proc and / sys . Consider the purpose of the directory / dev . In the / dev directory there is a special type of files - device files. We can say that these files are access points to the hardware of the computer. In more detail about types of files we will speak further. In the meantime, you need to understand that each file in the / dev directory is a real physical or logical device. For example, the sda file in the / dev directory is a hard disk with the Sata interface (or SCSI ), the sda1 , sda2 files (etc.) are the logical partitions of this disk. The file / dev / ttyS0 is the serial port com1 , / dev / ttyS1 is com2 , etc. Files / dev / tty1, / dev / tty2 .... / dev / ttyN are console files. Do the following experiment. Log in to the second and third console. Go to the second console and type the following comma *** y: echo HELLO! > / dev / tty3 . Now go to the third console and you should see HELLO! . That is, we redirected the output of the echo command to another console. Two words about the designation of hard drives in Linux . IDE interface disks are designated as hda , hdb, hdc or hdd . If the drive is connected to the first IDE connector as master , then it will be defined as hda , if as slave , then hdb , etc. Disks with SCSI or SATA interfaces are denoted as sda, sdb, sdc , etc. SATA drives are designated slightly differently than IDE . The name of the SATA drive does not depend on which SATA connector you have connected the drive to. For example, you have six SATA slots (we number them from 0 to 5). Regardless of which connector to connect the drive, it will be called sda . If you have two or more SATA drives in the system, then the drive that is connected to the connector with the lowest number will be designated as sda , and then in order. Consider the following. If your SATA drive was always connected, for example, to the second slot (and it was called sda ), and then you connected another drive to the first slot, then the new drive will now be called sda , and your old drive will be called sdb .

The directories / proc and / sys will be covered in the next lecture.


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

LINUX operating system

Terms: LINUX operating system