Linux File and file system overview

Source: Internet
Author: User
Article Title: Linux File and file system overview. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

1. File Type

The most significant difference between Linux and Windows is that Linux processes directories and devices in front of files, which simplifies the processing of various types of devices and improves efficiency. There are four main types of Linux Files:

(1) common files

Including text files, Shell scripts, binary executable programs, and various types of data

(2) Directory files

In Linux, directories are also files, including file names and sub-directory names and pointers to those files and sub-directories. When a directory file is stored in Linux, the only place where the file name is stored. When the file corresponds to the directory, that is, it is connected by a pointer, it constitutes a directory file. Therefore, when operating a directory file, operations on the file content are generally not involved, but operations on the correspondence between the directory name and the file name.

In addition, each file in Linux is assigned a unique value, which is called an index node. The index node is stored in an index node table, which is not allocated during disk formatting. An index node contains all information about the file, including the address of the disk data and the file type.

(3) Link file

A linked file is equivalent to a "shortcut" of Windows, but it has more powerful functions. Direct access to files in different directories, file systems, and even on different machines without occupying the disk again.

(4) Device Files

In Linux, all devices are operated in the same way as files, which greatly facilitates your use. In Linux, device-related files are generally stored in/dev, including Block devices and character devices.

Block devices are data reading/writing devices. They are Block devices (such as blocks composed of cylinders and fan blocks). The simplest devices are hard disks (/dev/hda1.

Character devices mainly refer to devices with serial ports.

2. File Attributes

-Rwx

The object owner can set the object access attributes to three different access permissions: readable (r), writable (w), and executable (x ). The file has three different user levels: file owner (u), user group (g), and other users (o) of the system ).

Type of the file to be displayed with the first character:

-Indicates a common file;

D indicates the directory file;

L indicates the link file;

C Indicates a character device;

B Indicates the block device;

P indicates the named pipe, such as a FIFO file;

F indicates a stack file, such as a LILF file;

The first character is followed by three character groups, indicating the permissions of the file owner (u), user group (g), and other users (o) of the system on the file, -If you do not have this permission -.

3. File System

3.1 ext2 and ext3

Ext3 is a common default file system in Linux. It is an upgraded version of ext2. The Linux ext2/ext3 file system uses an index node to record file information, acting as a file allocation table in windows. An index node is a structure that contains information such as the length of a file, creation and modification time, permission, ownership, and location on the disk. A file system maintains an array of index nodes. Each file or directory corresponds to the unique element in the index node array. The system assigns a number to each index node, that is, the index number of the node in the array, which is called the index node number. The linux File System saves the node number and file name of the file index in the directory at the same time. Therefore, the directory is only a table that combines the file name and its index node number. Each pair of file names in the Directory and the index node number are called a connection. A file has a unique index node number that corresponds to it. For an index node number, multiple file names can correspond to it. Therefore, the same file on the disk can be accessed through different paths.

By default, the file system used in Linux is Ext2, which is indeed efficient and stable. However, with the application of the Linux System in key services, the weakness of the Linux file system is gradually revealed: The ext2 file system used by the system by default is not a log file system. This is a critical weakness in key industries. This article describes how to use the ext3 Log File System in Linux.

The Ext3 file system is developed directly from the Ext2 file system. Currently, the ext3 file system is very stable and reliable. It is fully compatible with the ext2 file system. You can smoothly transition to a file system with sound log functions. This is actually the original intention of the initial design of the ext3 log file system.

Ext3 log file system features:

1. High Availability

After the system uses the ext3 file system, the system does not need to check the file system even after it is shut down abnormally. After a crash occurs, it takes tens of seconds to restore the ext3 file system.

2. Data Integrity:

The ext3 file system can greatly improve the integrity of the file system and avoid unexpected downtime damage to the file system. There are two modes available for ext3 file systems to ensure data integrity. One of them is the "Maintain file system and data consistency at the same time" mode. In this way, you will never see junk files stored on the disk due to abnormal shutdown.

3. File System speed:

Although the ext3 file system may have to write data multiple times during data storage, in general, ext3 is better than ext2. This is because the log function of ext3 optimizes the disk drive read/write headers. Therefore, the read/write performance of the file system is not lower than that of the Ext2 file system.

4. Data Conversion

It is very easy to convert an ext2 file system to an ext3 file system. Simply Type Two commands to complete the conversion process. You do not need to take the time to back up, restore, and format partitions. Use the tune2fs tool provided by an ext3 File System to easily convert the ext2 file system to an ext3 log file system. In addition, the ext3 file system can be directly loaded into the ext2 file system without any changes.

5. Multiple log Modes

Ext3 has multiple log modes, one of which is to define the data in the file system, that is, the data of all file data and metadata) logging (data = journal mode); another mode is to record logs only for metadata, but not for data, that is, the so-called data = ordered or data = writeback mode. System Administrators can choose between system speed and file data consistency based on the actual work requirements of the system.

3.2 swap File System

As we all know, modern operating systems have implemented the "virtual memory" technology, which not only breaks through the physical memory restrictions in terms of functionality, so that programs can manipulate space larger than the actual physical memory, more importantly, "Virtual Memory" isolates the security protection network of each process so that each process is not disturbed by other programs.

The role of the Swap space is described as follows: when the system's physical memory is insufficient, a part of the physical memory needs to be released for use by the currently running program. The released space may come from a program that has not been operated for a long time. The released space is temporarily saved to the Swap space, then, the stored data is restored from Swap to the memory. In this way, the system always performs Swap switching when the physical memory is insufficient.

3.3 vfat File System

In Linux, the FAT file system (including FAT12, FAT16, and FAT32) used in DOS is called the vfat file system.

3.4 NFS File System

The Network File System is one of the file systems supported by FreeBSD, also known as NFS. It is also a unique feature of Linux. NFS allows a system to share directories and files with its users on the network. Moreover, NFS file systems are widely used, especially in embedded systems, because they have fast access speed and high stability. By using NFS, users and programs can access files on the remote system just like accessing local files.

The following are the most obvious advantages of NFS:

L local workstations use less disk space, because the data can be stored on a machine and accessed through the network.

L the user does not have to have a home directory in each network machine. The Home directory can be placed on the NFS server and is available everywhere on the network.

L such as soft drive, CDROM, and Zip? Such storage devices can be used by other machines on the network. This reduces the number of removable media devices on the network.

3.5 File System

The file system used by the CD has good support for the CD in Linux. It can not only read and write the CD, but also burn the CD.

4. Linux directory structure

/Bin: Common commands used to store Linux in this directory. In some versions, the commands are the same as those in the root directory.

/Boot this directory stores all the programs used during system startup. some information here will be used when lilo is used to guide Linux.

/Dev this directory contains all external devices used in Linux. It is actually the port used to access these external devices. You can access these external devices, it is no different from accessing a file or directory. For example, if you type "cd/dev/cdrom" in the system, you can see the files in the optical drive. If you type "cd/dev/mouse", you can see the files related to the mouse.

/Cdrom the directory is empty when the system is just installed. You can mount the optical drive file system to this directory, for example, "mount/dev/cdrom"

/Etc This directory stores various configuration files and sub-directories used for system management, such as network configuration files, file systems, X system configuration files, device configuration information, and set user information.

/Sbin this directory is used to store system management programs of the system administrator.

/Home if you create a user named "xx", there is a corresponding "/home/xx" path under the/home directory to store the user's home directory.

/Lib This directory is used to store the shared libraries dynamically connected by the system. Almost all applications will use the shared libraries in this directory.

/Lost + found this directory is empty in most cases. However, some files are temporarily stored here after a sudden power failure or abnormal shutdown.

/Mnt this directory is usually empty. You can temporarily mount another file system to this directory.

/Proc can obtain system information in this directory, which is generated by the system itself in the memory.

/Root if you log on as a Super User, this is the main directory of the Super User.

/Tmp is used to store temporary files generated during execution of different programs

/Many usr applications and files are stored in this directory.

The content of the/var directory is changed frequently. You can see the name of the Directory, which is abbreviated as vary./var contains/var/log, which is the directory used to store system logs. The/var/www directory defines the directory where the Apache server site is stored;/var/lib is used to store some library files, such as MySQL and the location where the MySQL database is stored.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.