Inode and soft links, hard links

Source: Internet
Author: User

Inode:

The index node used to store meta information for the file. Includes the creator of the file, the date created, the size of the file, and so on. Linux under All files, each file has its corresponding inode.

Inode content:

The number of bytes in the file

UserID of the owner of the article I

GroupID of the file

File read, write, execute permissions

Timestamp of File: CTime (Inode last Change time)

Mtime (the time the file content was last changed)

Atime (file last Open time)

Number of links, that is, how many file names point to this inode

Location of file data block

Inode Size:

The size of each inode node, typically 128 bytes or 256 bytes, the total number of inode nodes, given at the time of formatting, is typically 1kb or 2kb to set an inode.


Hard Links:

A pointer to the inode. The system does not redistribute the inode (a common inode), multiple file names point to the same inode, modify one, and the files linked to it are modified at the same time. When you delete a hard-linked source file, the hard-link file still exists, and the original content is preserved, and it is treated as a normal file.

restrictions on hard links : ① does not allow hard links to be created for directories

② You can create a hard link only between files in the same file system

Command format

LS Source_path Target_path

↓↓

Source File Destination File

Soft links (Symbolic links):

Equivalent to a reference to the source file, the path to another file, can be any file or directory, you can also link files of different file systems, you can even link a nonexistent file, you can also loop link yourself.

Soft links do not have any file system restrictions, and any user can create a soft link to the directory. It has greater flexibility and can even span different machines, different networks.

Command format:

In-s Source_path Target_path


The difference between a soft link and a hard link:

1, hard link source files and linked files share an inode, indicating that they are the same file

Soft link source files and linked files have different inode, indicating that they are two different files

2, in the file properties of the soft link explicitly written out is a link file, and hard links are not written out, because in essence, hard-link files and source files are completely equal relations

3, the number of links to soft links will not increase, the file size is different.

The number of links to a hard link increases, and the file size is the same as the source file.

4, soft links can cross the file system, you can link to a nonexistent file can also be linked to the directory, hard links can not

5, Hard link when you modify the source file or any of the linked files, the other files are modified. The linked file still exists when the source file is deleted

Soft links have no effect on the source file when deleting or modifying the linked file, and the linked file cannot find the file to point to when the source file is deleted.




Inode and soft links, hard links

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.