Linux file system basics

Source: Internet
Author: User
Tags temporary file storage
Basic knowledge of Linux operating system file system 1. Linux file structure is the method for organizing files stored on disks and other storage devices. It is mainly reflected in the organization of files and directories. Directory provides a convenient and effective way to manage files. Linux operating system file system Basics 1. Linux file structure is the way to organize files stored on disks and other storage devices. It is mainly reflected in the organization of files and directories. Directory provides a convenient and effective way to manage files. Linux uses a standard directory structure. during installation, the installer has created a file system and a complete and fixed directory structure for the user, and specify the role of each directory and the file type. /The root directory contains too many threads, too many threads, and too many threads. etc lib sbin tmp usr var variable has been used when there are too many other such variables. d cron. d X11R6 src lib local man bin has been installed successfully. there are too many attempts to handle these issues. d rc0.d rc1.d rc2.d ...... Linux bin lib src Linux uses a tree structure. The top layer is the root directory. All other directories are generated from the root directory. Microsoft's DOS and windows also adopt a tree structure, but in DOS and windows, the root of such a tree structure is the disk drive letter of the disk partition. There are several partitions with several tree structures, the relationship between them is parallel. However, in linux, no matter how many disk partitions are managed by the operating system, such a directory tree has only one. In terms of structure, the tree directories on each disk partition are not necessarily tied. If this is not easy to understand, I will give you an example: a hard disk is divided into four partitions:/;/boot; fat in/usr and windows is subordinate to/and/boot or/and/usr. for/boot and/usr, they are parallel. If I mount the fat partition in windows to/mnt/winc ?? Oh, don't worry, huh, just talk about it later, just talk about it later .) For/mnt/winc and/usr or/mnt/winc and/boot, they are two branches that do not have any relationship with the directory tree. Because linux is a multi-user system, developing a fixed directory plan helps to manage system files and different user files in a unified manner. However, this is a headache for many beginners who have switched from windows to linux. The functions of some main directories in linux are listed below. /Bin binary executable command/dev device Special file/etc system management and configuration file/etc/rc. d. start the configuration file and script/home user home directory base point. for example, if the user's home directory is/home/user, you can use ~ User indicates the/lib standard programming library, also known as dynamic link shared library, which works like in windows. dll file/sbin System Management Command, which stores the temporary file storage point used by the system administrator/tmp public/root system administrator's main directory (haha, privileged class) /The mnt system provides this directory for users to temporarily mount other file systems. The/lost + found directory is usually empty, and the system shuts down abnormally, leaving a "homeless" file (what is it in windows. chk) here, the/proc virtual directory is the ING of the system memory. You can directly access this directory to obtain system information. /Var the overflow of some large files. for example, the log files of various services/The largest directory of usr, almost all the applications and files to be used are in this directory. The package includes: /usr/X11R6 stores the X window directory/usr/bin numerous applications/usr/sbin hyperuser management programs/usr/doc linux documentation/usr/include development in linux and the header file/usr/lib commonly used dynamic link library and software package configuration file/usr/man help file/usr/src source code required for compiling the application, the source code of the linux kernel is stored in/usr/src/linux/usr/local/bin. the Command/usr/local/lib is added locally. physical space of the file, in linux, each partition is a file system with its own directory hierarchy. In linux, the file systems that belong to different partitions form a general directory hierarchy of the system in a certain way. The operation of an operating system is inseparable from file operations. Therefore, you must possess and maintain your own file system. The Llinux file system uses an index node to record file information, which acts 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. You can use the ln command to create a new connection to an existing file without copying the file content. There are soft connections and hard connections. soft connections are also called symbolic connections. Their respective features are hard connection: both the original file name and connection file name point to the same physical address. The directory cannot have a hard connection; the hard connection cannot span the file system (not across different partitions) and only one copy of the file on the disk saves the hard disk space; deleting a file is successful only when the same index node is a unique connection. This prevents unnecessary accidental deletion. Symbolic connection: using the ln-s command to establish a symbolic connection to a file is a special file in linux. as a file, its data is the path name of the file it connects. Similar to the shortcut in windows. You can delete the original file and save the connection file. This does not prevent accidental deletion. The content of this section is too abstract, and the node is an array. I have tried to be as popular as possible, but it is not a good example for demonstration. If you are still in the fog of the cloud, there is no way I can do it. I only need to remember that I will gradually understand and understand it in practical application in the future. This is also a learning method. 3. Mount a file system as shown in the previous section. in linux, each partition is a file system with its own directory hierarchy. In linux, the file systems that belong to different partitions form a general directory hierarchy of the system in a certain way. The "according to certain method" mentioned here refers to the Mount. Mount the top-level directories of one file system to the subdirectories of another file system to make them a whole, called mounting. This subdirectory is called a mount point. For example: root partition: /the root directory is too large. please refer to the following link for more information. d cron. d. please wait until there are too many attempts to handle these issues. d rc0.d rc1.d rc2.d ...... /Usr partition: usr has been used since then. the figure at the beginning of the article is formed after mounting linux bin lib src. Does it look like hanging up? Note: 1. the mount point must be a directory. 2. a partition is mounted to an existing directory. the directory cannot be empty, but the contents in the directory are unavailable. This is also true for mounting file systems created by other operating systems. However, you need to understand that the formats of the file systems used by CD, floppy disk, and other operating systems are different from those used by linux. The disk is ISO9660, the disk is fat16 or ext2, the windows NT is fat16 and NTFS, the windows 98 is fat16 and fat32, and the windows2000 and windows XP are fat16, fat32, and NTFS. Before mounting, check whether linux supports the file system format to be mounted. Run the mount command in the format of mount [-parameter] [device name] [mount point]. common parameters include-t, which specifies the file system type of the device. common parameters include: minix linux first used file system ext2 linux Currently commonly used file system msdos MS-DOS fat, is fat16 vfat windows98 commonly used fat32 nfs network file system iso9660 CD-ROM disc standard file system ntfs windows NT 2000 file system hpfs OS/2 file system auto automatic detection file system-o specified Mount file system options. Some of them are also available in/etc/fstab. Commonly used include codepage = XXX code page iocharset = XXX character set ro mounting rw in read-only mode mounting nouser in read/write mode so that general users cannot mount user can let general users mount devices to remind me, the mount command does not provide the mount point function. therefore, make sure that the mount point already exists when you run the mount command. (Do not understand? To put it bluntly, you must first create a directory where you want to mount the file system. So OK ?) For example, Windows 98 is installed in the hda1 partition, and the disk and disk need to be mounted on the computer. # Mk/mnt/winc # mk/mnt/floppy # mk/mnt/cdrom # mount-t vfat/dev/hda1/mnt/winc # mount-t msdos/dev/fd0 /mnt/floppy # mount-t iso9660/dev/cdrom/mnt/cdrom now you can access/mnt/winc and other directories to read and write these file systems. Make sure that the last two lines of commands are correct. make sure that the drive and the drive have disks. (If the disk on the hard disk can be changed at any time, I don't think this will happen:->) if your windows98 directory contains a Chinese file name, after mounting with the above command, a bunch of garbled characters are displayed. This requires the codepage iocharset option in the-o parameter. Codepage specifies the code page of the file system. The Chinese code in Simplified Chinese is 936. iocharset specifies the character set. cp936 or gb2312 is generally used for simplified Chinese. When the mounted file system is not supported by linux, mount must report an error, for example, Windows ntfs file system. You can re-compile the Linux kernel to obtain support for the file system. I will not recompile the Linux kernel here. 4. it is too cumbersome to run the mount command every time you access windows partitions at startup. why not use the mount command to access other linux partitions? In fact, during each boot, linux automatically mounts the linux partition to be mounted. So can we set the partitions we want to mount when linux is started, such as windows partitions, to realize automatic mounting of the file system? This is completely possible. There is a fstab file in the/etc directory, which lists the file systems automatically mounted when linux is started. My/etc/fstab file is as follows:/dev/hda2/ext3 defaults 1 1/dev/hda1/boot ext3 defaults 1 2 none/dev/pts devpts gid = 5, mode = 620 0 0 none/proc defaults 0 0 0 none/dev/shm tmpfs defaults 0 0/dev/hda3 swap defaults 0 0 0/dev/cdrom/mnt/cdrom iso9660 noauto, codepage = 936, iocharset = gb2312 0 0/dev/fd0/mnt/floppy auto noauto, owner, kudzu 0 0/dev/hdb1/mnt/winc vfat defaults, codepage = 936, iocharset = cp936 0 0/dev/hda5/mnt/wind vfat ULTS ults, codepage = 936, iocharset = cp936 0 0 in the/etc/fstab file, the first column is the device name of the mounted file system, the second column is the mount point, the third column is the mounted file system type, and the fourth column is the mount option. the options are separated by commas. The fifth and sixth columns do not know what they mean. they also look at their fingers. In the last two lines, I manually added the C; D drive in windows, and added the codepage = 936 and iocharset = cp936 parameters to support Chinese file names. The defaults parameter actually contains a set of default parameters: rw mounting suid in read/write mode enable user ID and group ID setting bit dev can interpret characters or block devices on the file system exec can execute binary files auto automatic mounting nouser so that general users cannot mount async if the file system's input and output operations are not synchronized, you can see that in this list, the optical drive and the soft drive are not automatically mounted, and the parameter is set to noauto. (If you want to set it to automatic mounting, make sure that there is a disk in your drive and drive every time you start the system .)
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.