For the first contact with Linux, the biggest difference compared to window is the file. General document everyone is very easy to understand, such as: Word document, TXT document this is a regular file it, but in the Linux environment, the device has become a file, so that the first contact with the Linux people or more confused about it, but slowly get used to it. So, in Linux, everything is a file . That is, in Linux, everything can be considered a file, all the operations can be attributed to the operation of the file, so that the Linux operating system can be used as a normal file to use everything (disk files, serial, keyboard, monitor, printer and other devices).
I. Linux file system architecture
No matter what you learn, at first you will introduce the structure of words to lead the whole, so that the entire system has a clear understanding and image. The file structure is the way that files are organized in storage devices such as disks, mainly in the organization of files and directories. Linux file systems are arranged at the level of directories and files (as is the case with Windows), where directories or files have their attributes (file type, length, owner, access rights, etc.), especially the set directory and file permissions, in order to improve the security of their access.
Its file structure presents a multi-level tree structure, through which the user can browse directories and files that already have permissions under the system. After the general Linux system is installed, there will be a fixed directory structure, and its different directories hold different categories of files in order to accomplish some specific tasks. The directories contained in the Linux root directory and their purpose are as follows:
Ii. Types of files
[Email protected] tmp]$ ls-altotal 120DRWXRWXRWT. Root root 4096 Nov 2 06:26. dr-xr-xr-x. Root root 4096 Oct 19 01:45. DRWX------. 2 root root 4096 Oct 01:31. esd-0drwx------. 2 Xcbeyond xcbeyond 4096 Nov 2 05:23. esd-500drwxrwxrwt. 2 root root 4096 Nov 2 05:23. ICE-UNIXDRWX------. 2 Xcbeyond xcbeyond 4096 Jul 07:02 keyring-b651jsdrwx------. 2 root root 4096 Oct 01:31 keyring-dkrzcbdrwx------. 2 Xcbeyond xcbeyond 4096 Oct 7 05:45 keyring-g6gje4drwx------. 2 Xcbeyond xcbeyond 4096 Nov 2 05:23 keyring-jamrno (omitted ...) )
From the above example, you can see that the file information listed contains the file type, file attributes, user name, user group, file size, modification date, file name, and so on. The first column of information (DRWXRWXRWT) is more important, which is what is highlighted next.
The first column of information contains 10 characters, divided into 4 groups:
① First group (1th bit): File type
1
Different characters represent different file types, such as: D represents a directory file.
The Linux file type symbols are shown in the following table:
② the second group (第2-4位): File owner (user) permissions
③ Third Group (第5-7位): Same group user permissions for file owners
④ Group Fourth (第8-10位): Other group Users (permissions
※ The permission is divided into: Read, write, execute three kinds
1. Common documents
Ordinary file is a computer user to store data, programs and other information files, is generally stored in the storage device (hard disk) for a long time. Ordinary files are generally divided into text files and binary files.
2. Catalog files
A catalog file is a file consisting of directory entries in a directory in a file system that allows only the system to be modified, the user process can read the catalog files, but not modify them, and only the kernel can write the directory files.
3. Equipment files
A device file is a file that provides links to the operating system and I/O devices, and is divided into character device files and block device files, which correspond to character devices and block devices. Linux takes the I/O to a device as a read/write to a normal file, and the operating kernel provides a unified interface for device processing and text processing. Each I/O device corresponds to a device file, stored in the/dev directory, such as: Line printer corresponds to file/DEV/LP. Currently in the latest Linux distributions, it is generally not necessary for users to create device files because these files are associated with the kernel.
There is a very special file in the device file is/dev/null, learning shell script, you will know, and this is called "bottomless file", is generally used to write some do not want to control the console display of the message.
(1) Character devices (Character device): This is a sequential data flow device in which read and write is performed by character, and these characters are continuously formed into a data stream. Character devices do not have buffers, so read and write to this device is real-time.
(2) block device: This is a random access device with a certain structure, the reading of this device is in accordance with the block, it uses a buffer to store the temporary data, when the time is ripe, from the cache once written to the device or from the device once read out into the buffer, such as disks and file systems.
[[email protected] dev]$ pwd/dev※/dev directory [[email protected] dev]$ L S-altotal 4drwxr-xr-x. Root root 3920 Nov 3 06:28. Dr-xr-xr-x. Root root 4096 Nov 3 06:28. CRW-RW----. 1 root video, 175 Nov 3 06:28 agpgartdrwxr-xr-x. 2 root root 640 Nov 3 06:28 block※ directory drwxr-xr-x. 2 root root 3 06:28 bsgdrwxr-xr-x. 3 root root 3 06:28 buslrwxrwxrwx. 1 root root 3 Nov 3 06:28 cdrom-sr0※link file lrwxrwxrwx. 1 root root 3 Nov 3 06:28 cdrom1-sr1lrwxrwxrwx. 1 root root 3 Nov 3 06:28 CDRW-sr0lrwxrwxrwx. 1 root root 3 Nov 3 06:28 cdrw1-sr1drwxr-xr-x. 2 root root 3020 Nov 3 06:28 CHARCRW-------. 1 root root 5, 1 Nov 3 06:28 console※ character device file lrwxrwxrwx. 1 root root 3 06:28 core-/proc/kcoredrwxr-xr-x. 3 root Root 3 06: CPUCRW-RW----. 1 root root, 3 06:28 cpu_dma_latencycrw-rw----. 1 root root, 3 06:28 crashdrwxr-xr-x. 5 root root 3 06:28 diskcrw-rw----+ 1 root audio, 9 Nov 3 06:28 dmmidilrwxrwxrwx. 1 root root 3 Nov 3 06:28 DVD-sr0lrwxrwxrwx. 1 root root 3 Nov 3 06:28 dvd1-sr1lrwxrwxrwx. 1 root root 3 Nov 3 06:28 DVDRW-sr0lrwxrwxrwx. 1 root root 3 Nov 3 06:28 dvdrw1-sr1lrwxrwxrwx. 1 root root 3 Nov 3 06:28 FB--FB0CRW-RW----. 1 root root, 0 Nov 3 06:28 fb0lrwxrwxrwx. 1 root root 3 06:28 FD--/proc/self/fdcrw-rw-rw-. 1 root root 1, 7 Nov 3 06:28 fullcrw-rw-rw-. 1 root root, 229 Nov 3 06:28 fusecrw-rw----. 1 root root, 0 Nov 3 06:28 hidraw0crw-rw----. 1 root root, 228 3 06:28 hpetdrwxr-xr-x. 2 root root 3 06:28 HUGEPAGESCRW-------. 1 root root 229, 0 Nov 3 06:28 hvc0drwxr-xr-x. 4 root root 260 Nov 3 06:28 INPUTCRW-RW----. 1 root root 1, 3 06:28 kmsgsrw-rw-rw-. 1 root root 0 Nov 3 06:28 logbrw-rw----. 1 root disk 7, 0 Nov 3 06:28 loop0※ block device file BRW-RW----. 1 root disk 7, 1 Nov 3 06:28 loop1brw-rw----. 1 root disk 7, 2 Nov 3 06:28 loop2brw-rw----. 1 root disk 7, 3 Nov 3 06:28 loop3
4. Link file
A linked file, also known as a symbolic link file, resembles a shortcut file under window, which provides a way to share a file that is not shared by file name in the linked file, but rather accesses the file through a pointer to the file contained in the linked file. A normal user can create a linked file and access the file it points to by its pointer. Depending on the linked object, the linked file can be divided into hard-link files and symbolic link files.
5. Pipeline File
Pipeline files are primarily used for inter-process data transfer, which is a communication mechanism between Linux processes. A pipeline is one end of a process that writes data to a pipe, and another process reads data from the other end of the pipeline. Pipeline files can also be divided into anonymous pipes and named Pipes two kinds.
6. Socket file
Socket (socket) files are primarily used for communication between processes on different computers. Sockets are a data structure in the operating system kernel, which is the channel in which nodes in a network communicate with each other. There are 3 types of sockets: Streaming sockets, datagram sockets, and raw sockets. Streaming sockets are also TCP sockets (connection-oriented sockets), which are UDP sockets (no connected sockets), and the original sockets are usually denoted by "sock_raw".
Third, file access rights
File access refers to the user authentication that a file system requires in order to perform security management in a file operation. Users who do not have permission to operate on their files. Because the Linux system is a typical multi-user operating system, different users are in different positions. In order to protect the security of the system, the Linux system has different access rights for different users to access the same files, that is, different users have different rights to read, write and execute for the same file.
When the user logs on to the Linux system, the system automatically assigns a UID to distinguish the different user's permission levels, the root user has the highest user rights, and the uid=0.
Linux file system and operation