Linux File System Preliminary

Source: Internet
Author: User

in the Linux system, if we want to know the specific information of a file, then the simplest method is naturally the LS command. As shown: When you enter the command "ls-l old" in the shell, you will see some

Information. The specific meanings that each part of the output represents are analyzed from left to right. Where the first part of the output contains 10 characters, where the first character is used to represent the type of file. So let's start by saying that the file types in the Unix/linux system are good.


File type: the

In fact, in the Linux system is mainly two kinds of files, one is a regular file (regular files), the other is the directory (directory). It may seem strange at first, how can a directory be a file? The directory is simply a special file that stores the name of the file or subdirectory under the directory and the number of the corresponding I-node (which contains essentially the structure of all information about the corresponding file). Of course, in addition to the two file types mentioned above, there are: block device files (blocks special device), character device files (character special device), FIFO (pipe), socket (socket), symbolic Link (symbolic Link) of these file types. The concrete is not unfolded here. As in the first bit is '-', it means that the file is a regular file, other types of files through the bit display characters should also be easily judged out.

File permissions:

Let's take a look at the meaning of the post 9-character representation. Say 9, in fact we divide them into 3 groups, each group represents the same meaning. We all know that the Linux system is a multi-user system, so for a file, there may be someone other than the creator who wants to manipulate the file. At this point, it is necessary to set the operation permissions of the file. These three sets of characters, from left to right, are the creator of the file (user), the same group member (group) of the creator of the file, and other users (others), except for the two. The 3 characters of each group, from left to right, are displayed in Rwx where R represents the Read permission, W represents the Write permission, and x represents the executable permission. As shown, I want to read a file named new, but all of its permissions are blocked. When I enter the command: More new, the shell will prompt for insufficient permissions. Other operations can also be obtained by analogy. But there is a god-like user in Linux, the legendary root or Superuser (Superuser). It has all the permissions on the system and can operate on any file, so the limitations mentioned earlier have no effect on it.


Number of Links:

The number 1 to the right indicates that the file has 1 links. There are two types of links, hard links and symbolic links (symbolic link). The number of hard links shown here should be. Where a hard link is directly executing the inode of the file, and the symbolic link does not, it simply contains the location information of the linked file, similar to the shortcut in Windows. It is important to note that a lot of the time you call delete a file, just delete a link to the file. To really delete the contents of a file, you must satisfy two conditions: 1. The number of links to the file is 0. 2. There is no process to open the file.

UID and GID:

As already mentioned, a file must have been created by a user. Then naturally in the file information need to save, the creator of the file, that is, User-id short uid, but also the creator of the group's Id,group-id, referred to as GID. So the monster monster shown next corresponds to the group where the creator of the file Monster and monster.

File Size:

Then the size of the corresponding file is displayed, the file size in the example is 0, the unit is byte. It is important to note that if the type of the file is linked, then its size is the number of characters of the file name that it executes.

File time:

The next show is the file time. For a file, generally saved 3 times: 1.st_mtime, the last time the file was modified (modification times), 2.st_atime, the last time the file was opened (access times) 3.st_ctime, The last time the file state changed (changed status). One of the most puzzling is certainly st_mtime and St_ctime, the document has been modified, then the state has not changed it? Change of State, that must be the file modified AH? In fact, this is not the case, the first st_mtime refers to the file content modification, and st_ctime state refers to the file corresponding to the inode stored in the information changes, such as various permissions Ah, Uid,gid and so on. So, it's totally different.

Filename:

The last natural is the file name, for the file name is to say that it is not stored in the file corresponding to the inode, but rather saved in the corresponding directory file. This leads to a very interesting phenomenon, that is, when we want to delete a file, we do not need any permissions to the file, but need to the directory where the file is written and execute permissions. Because we delete a file that is to reduce the number of links to the inode for that file, and remove the filename from the corresponding directory file.



PS: The above is the basic knowledge of Linux file system by the command ls-l filename extension. Of course there are a lot of details that are not involved, and the file system is far from being so simple. If there is any mistake, please point out in time, can let me correct. Students who want to discuss can also comment on the message. (*^__^*) hehe ...

Reference number: Advanced programming for the UNIX environment

Linux File System Preliminary

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.