Organization of the file system
File is a concept familiar to any computer user. For each user's file is a separate subject, which is the beginning and end and is different from all others file name and location (as is "and" where is "). As with any file you can create, move and destroy, but without external interference, he will remain intact indefinitely. The file is designed for storage of any type of text, graphics, sound, executable programs, and much more. The analogy with the file allows the user to quickly adapt to work with the operating system.
For Linux file-not least the notion than to the user: all data stored on any media, necessarily within any file, otherwise they simply are not available for any operating system or for its users. Furthermore, all devices connected to a computer (as keyboard and ending any external devices, such as printers and scanners) as a Linux file (called files holes). Of course, the file containing conventional data is very different from the file, for the treatment to the device, so Linux identified several different types of files. Basically, the user is dealing with files in three types: regular file for storing data, directories and faylami- links, it is about them and is described in this lecture, on the files of other types see a lecture work with external devices.
Separate data field in one of the media, which has its own name.
System files: Directories
File system from a user's perspective is the "space", which posted files, a file system makes it possible to identify not only "as a file named", but "where it is." Files distinguished only by name, it would be too inefficient: about each file had to remember he called and the care that the names will never recur. Furthermore, a mechanism to work with groups of subject-related files (for example, components of the same program, or a different chapter dissertation). In other words, files must be systematized.
The method of storage and access to the information media, or his section. Classical file system is a hierarchical structure in which a file is complete by him.
Linux can work with different types of file systems, which differ list of supported capabilities, productivity in different situations, reliability and other features. More on Linux with different file systems is discussed in the lectures work with external devices. In this lecture will describe to Ext2/Ext3 file system, today's de facto standard file system for Linux.
Most modern file systems (but not all!) Use as a basic organizing principle directories. Directory is a list of links to other files or directories. To say that the directory contains the files or other directories, but in reality it only refers to the physical location of data on disk is usually not associated with the deployment directory. Catalogue, which is referred to in this directory, or a subdirectory called nested directory. Catalogue in the file system more like the library catalogue, which contains references to the joint for some signs of books and other sections of the catalogue (files and subdirectories). Reference to the same file can be found in several places at once, it could make access more convenient file. In each Ext2 file system directory is a special type of file ( "d" from the English. "Directory"), different from the normal file data: it can only contain links to other files and directories.
In no Linux file system folders and documents. There are directories and files, to which much broader.
Quite often, instead of the directory can be found folder (s folder). This term is well within the view of the files as objects that can decompose for folders, but part of the file system, which is contrary to the submission, thus upper. In particular, the term "file" is not that link to a file can be present simultaneously in several places, the file may be a reference to another file, etc. In this capacity Linux file system is very important
to be effective, so everywhere will be more appropriate term "catalogue".
In the file system, organized by directories on any file to be referred to as least one directory, or file will not be available inside the file system, in other words, would not exist.
The names of files and directories
The main characteristic of files and directories - their names. In Linux file and directory names can be no longer than 256 characters, and may contain any characters other than "/". The reason for this limitation is obvious: This symbol is used as a separator in the name of the road, so must meet within names. And Linux has always distinguish between upper and lower case letters in the names of files and directories, so "methody", "Methody and METHODY" will be three different names.
There are a few characters allowed in the names of files and directories, which, however, must be used with caution. This is the so-called special characters "*", "\", "&", "<", ">", "; "," ( ",") "," | ", As well as gaps and tabulation. The fact is that these characters are of particular importance for any command shell, it will need to specifically ensure that the command shell accept these characters as part of the file name or directory. A special symbol meaning "-" for Linux already commands described in the lecture terminal and the command line, there also discussed how to change its interpretatsiyu1. That why the command shell need special characters, it goes to lectures Opportunities command shell.
Character and Russian names
As can be seen, while all vstrechavshihsya names of files and directories upotreblyalis only Latin alphabet characters and some punctuation. This is not a coincidence and due to the desire to ensure that the examples cited the same way looked at any system. Linux in the names of files and directories permitted to use any of the characters of any language, but such freedom requires victims, which Methodius, for example, could not go.
In fact, had long been a symbol (letter), each language has traditionally been presented as a single byte. This provision imposes very strict limitations on the number of letters in the alphabet: there can be no more than 256 and less Governing characters, numbers, punctuation and other things - and the less. Extensive scripts (eg ieroglificheskie Japanese and Chinese) had to replace simplistic their presentation. In addition, the first 128 characters of the 256 best always left unchanged, the relevant standard ASCII, including Latin, numbers, punctuation, and the most popular of those characters that are typed on the keyboard. Interpretation of the remaining 128 characters depends on what is encoded in the system. For example, the Russian encoding KOI8-R 228 th symbol of the table with the letter "D", and Western encoding ISO-8859-1 the same character with the letter "a" with two dots on it (as my letter "e" ).
Filenames recorded to disk in one encoding look ridiculous if you browse the catalogue was another. Worse. Many encoding complete range of characters with the numbers 128 is not 255, so a character can never be! This means that such a distorted name from the keyboard (for example, to rename it) will not directly have to enter into various Action Items described in the lecture opportunities command shell. Finally, many languages, including Russian, historically have several kodirovok2. Unfortunately, there is currently no standard way to specify the encoding directly to the file name, so in a single file system is a single encoding when naming files.
There is a universal code, including letters written all peace-UNICODE. Standard UNICODE now all bOlshee distribution and meant to be common to all the texts stored in electronic form. But until he reached the desired universality, particularly in the area of file names. One character in UNICODE can hold more than one byte, and that his main disadvantage, as many useful applications, excellent working with odnobaytnymi encoding must thoroughly or even convert to teach them to treat UNICODE. Perhaps the reason for the lack of this encoding and also that the UNICODE standard is a very cumbersome, and it may be ineffective in dealing with the file system, where speed and reliability of a very substantial quality.
This does not mean that naming files should not use languages other than English. While exactly know what encoding specified filename, problems would arise. But Mefody decided that guarantees the transfer of Russian named file to a different system can be made only passing with him the encoding setting, even two: in our system and in the addressee (unknown what!) . Another, much easier, way to send a file to use in its name only ASCII characters.
Many people familiar with the concept of the expansion is part of the file name after the point, usually confined to a few smvolami and pointing to the type of data file. In the Linux file system, there is no requirement for the expansion: the file name can be any number of points (including none), but after the last point could be any number simvolov3. While expansion is not binding and is not imposed on Linux technology, they are widely used: the expansion enables individuals or program without opening the file, only his name to identify what type of data it contains. But remember that the increase is only a set of agreements on various categories of files. Strictly speaking, the data file may not match the claimed increase for one reason or another, so to rely entirely on the expansion simply will not work.
Determine the type of content and file can be on the basis of the data. Many formats predusmotrivayut indication at the beginning of the file should be interpreted as further information: as a program, input data for the word processor, HTML page, the sound file, an image or something else. Available Linux users always have utility file, which is designed precisely to identify the type of data contained in the file.
Methodius, forgetting that contained in the file "-filename-with-", which he created at the last lecture, I was already see its contents with the help of commands cat. But it stopped Gurevich, who advised to find out that the data contained in the file. It is possible that this is a binary file executable programs in the file may meet sequence, which accidentally coincide with the Governing terminal sequences. The behaviour of the terminal after that can be unpredictable and inexperienced Methodius unlikely to be able to cope with it. Methodius was quite accurate response from the utility file: its file-English text encoding ASCII. file able to distinguish between many types of data, and almost certainly will give the correct information. The utility has never "trusted" file extension (if present), and analyzes the data itself. file differentiates not only different data, and different types of files, in particular, will report if the study is not a normal file, but, for example, the catalogue.
The concept of a directory to let all objects placed on data storage media (such as disk). In most modern file systems using a hierarchical model of data: There is a directory that brings all data in the file system is the "root" of the file system root. Root may contain any of the file system, and in particular, sub (catalogues level nesting). Those, in turn, can contain any of the file system and subdirectories (second-level nesting), etc. Thus. all that is written to disk files, directories and special files to a "root": either directly (contained therein), or on some level nesting.
Hierarchy invested in each other directories can be correlated with hierarchical data in the system: unite thematically related files in a directory, thematically related directories in a single directory, etc. If strictly hierarchical principle, it would be better than the level of nesting directory, the more private signal to be combined data contained therein. If this principle is not followed, there will soon be much easier to fold all the files in one directory and find the correct ones than done a search on all subdirectories system. However, in this case of any organizing files say no.
The structure of the file system can be represented graphically in the form dereva4, "Root" is the root and tops are all directories. Fig. dir-tree displays a directory tree italics marked files directly outline - name directories.
In any Linux file system, there is always only one root, which is called "/". User Linux always work with a single directory tree, even if different data located on different media: more stringent or network drives, removable drives, CD-ROMs and so Clause 5 To connect, and disable file systems on different devices in one general tree, the procedures mount and unmount, as it goes to lectures work with external devices. Once the file systems on different platforms connected to a common tree of the data available to them as if they were a single file system: the user may not even know what the device which files are stored.
The situation in any directory tree directories accurately and clearly described by the full path. Full path always starts from the root and consists of all the nodes encountered in the movement of the ribs tree to the desired directory inclusive. Name neighboring peaks separated by the symbol "/" ( "slash"). In Linux full path, for example, the directory "methody" in the file system as shown in Fig. dir-tree recorded as follows: first symbol "/", a root and then added to it "home" and then specify the "/" followed by the name of the desired directory "methody", the result is a complete path "/ home / methody "6.
Location file in the file system similarly defined by the full path, only the last element in this case is not a directory name and file name. For example, the full path to a file Methodius "-filename-with-" would look like this: "/" home/methody/-filename-with- 7.
Organization of a file system directory tree does not appear cycles: ie directory can contain a directory, which contains himself. This limits the full path to a directory or file in the file system will end.
Placing components of the system: Standard FHS
Let's try to deal in more detail, as arranged Linux directory tree and where it could be found. Fragment tree directories typical Linux file system (Some Linux, which uses Methodius) is Methodius decided to examine its file system, starting with the root: Gurevich advised to use the ls command to the directory where the directory is a full directory path: utility output ls list everything that is contained in this directory.
Utility ls withdrew list subdirectories root. This list will be the same or almost the same in all the Linux distributions. At the root of a Linux system is usually only subdirectories with standard names. Moreover, not only the name but also the type of data that can go into a folder, also regulated by this standard. The standard is called Filesystem Hierarchy Standard ( "standard" design of file systems).
Let us briefly, is that in each of the subdirectories root. We will not give complete lists of files for each directory described and Methodius will be able to view them through the command ls directory name.
The name of the directory comes from the word "binaries" ( "binary", "executable"). This directory is executable basic utilities. These are such programs, which may require system administrator or other users for ustraneneniya malfunction in the system or in rebuilding after a crash.
"Boot" - boot the system. This directory files are needed for the first phase of downloads: Download the kernel and usually very core. You almost never need to work directly with these files.
In this catalogue are all available in the files holes: a special type of files intended for the treatment of various system resources and devices (s "devices", "device", hence the abbreviation directory). For example, files / dev / ttyN with virtual console, where N is the number of Virtual Console. Data User at the first virtual console, the system reads from the file / dev/tty1 in the same file written data, which should withdraw to the user console. In files holes really are not any data to support their data is transmitted. More on the principle of working with faylami- holes it goes to lectures work with external devices.
Catalogue for system configuration files. It stores information on the specific configuration of the system: the information about registered users, available resources, different settings. Details of the system configuration files will be discussed in lectures configuration files.
There are directories of users, home directories, hence the name "home". The office of all files created by users of other system files an obvious advantage: serious damage to the system or the need to update not affect most valuable information-user files.
The title of the catalogue-short for "libraries" (en "library"). Libraries are meeting most standard functions needed for many programs: operations, I / O, drawing elements of the GUI, etc. To not include these functions in the text of each programme, using standard library functions are significantly saves disk space and making it easier to write programs. This directory contains libraries needed for the most important system utility (located in the / bin and / sbin).
Directory to mount (from the English. "Mount"), temporarily connect file systems, such as removable storage media (CD-ROM, etc.). Details of the mounting file systems it goes to lectures work with external devices.
In this directory, all files "virtual" - they are not on the disk, and RAM. These files contain information about programs (processes) to be performed at this time in the system.
Home directory system administrator-root user. The idea to run separately from the rest of the home directories of users is that the home may be placed on a separate device, which is not always available (for example, on a network drive), a home directory root should be present in any situation.
Catalogue for critical system tools (a directory name-short for "system binaries"): in addition to the utility / bin contains programs for download, backup, recovery. The power to implement those programs have only the system administrator.
The directory is designed for temporary files: in the program files to store intermediate data necessary for work. After the program files lose their meaning and must be removed. Normally the directory / tmp cleaned every time the system.
Catalog / usr is the "State of the State". You can find the same subdirectories bin, etc, lib, sbin, and the root. However, the root will only tools needed for loading and recovery in an emergency, all other programs and data are located in subdirectories of / usr. Applied programmes in the current system usually found a lot, so this section of the file system can be very high.
The title of the catalogue-short for "variable" ( "variable data"). It posted the data that are created in the process and the various programs designed to transfer to other programs and systems (print queue, and e-mail, etc.) or for the attention of system administrator (system logs containing the minutes of the system). Unlike / tmp here are the data that may be needed after their program created completed.
Standard FHS governs not only listed directories, but also their subdirectories, and sometimes even leads the list of files that must be present in certain katalogah8. This standard is consistently observed in all Linux systems, but not without heated dispute between the developer while leaving each of the new version.
The standard of files and allows people, and even predict the program, which is a component of the system. For people, this means that it can quickly orient in a Linux system (where the file system is organized according to the standard) and find what it needs. For programming standard file location is the possibility of automatic interaction between the various components of the system.
Methodius has been possible to capture some premimuschestvami, which provides the use of the standard files: for the previous lectures he using tools without specifying the full path to the executable file, for example, instead of cat / bin / cat. Command shell "knows" that executable files located in the directory / bin, / usr / bin, etc. - in these catalogues, it looks for an executable file cat. Thus, each newly installed in the program is immediately available user from the command line, it does not require any system restart or start any proceedings - simply place an executable file in an appropriate directory.
Recommendations standard of files and directories based on the principle distribute in different subdirectories files, which are used differently in the system. By type of files they can be divided into the following groups:
custom / system files
User files are all files created or owned any of the components of the system. About a distinction user and system files it has been higher.
changing / unchanged files
By unchanged files are all static software components: libraries, executable files, etc.-all that does not change itself without interference from the system administrator. Changing is those changes without human intervention in the system: system logs, press releases, etc. The provision of permanent files in a separate structure (for example, / usr) allows the use of a file system on a "read only", which reduces the probability of accidental damage and can be used to store this file system CD-ROM and other media, available only for reading.
separated / nerazdelyaemye files
This distinction is useful in the case of a network, which operates several computers. Much of the information that may be stored on a computer and used the rest of the network (to such information, for example, many programs and user home directories). However, some files can be shared between the systems (for example, files for the initial system load).
one character "-" means that the next word is the key and the tab spaces and share options from the command line.
2 Methodius himself several times and received e-mails that begin with "bNOPNYa" or "bMHLYuMHE" is the result of the text encoding of CP-1251, in the encoding KOI8-R.
3 Unlike the old file systems, LVA of "8 +3" (DOS, ISO9660 etc.), where filename is permitted no more than one point and the expansion could be no more than 3 characters. This limitation has identified as many of today known file extensions, such as "txt" for a text file.
4 Here is a tree in the strict mathematical sense: a graph-oriented cycles without a root nodes, in which each vertex has exactly one rib.
5 This is different from technology used in Windows or Amiga, where each device, which is the file system used by its root, the designated letters, such as "a", "c", "d", etc.
6 very similar way to write full path used in Windows, with the difference that the root partition is designated device letters followed colon, and is used as a separator character "\" ( "reverse slash").
seven full directory path formally is no different from the path to the file, that is the full path can not be said for sure whether his last element of the file or directory. To distinguish the directory path, sometimes using the list with the symbol "/" at the end of the path: "/ home / methody /".
8 Kraktoe description of the standard hierarchical directory Linux can be obtained, while a team man hier.