650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s2.51cto.com/wyfs02/m01/7d/4f/wkiol1bmfsacw-qsaabmsrnmerq847.png "title=" Image.png "alt=" Wkiol1bmfsacw-qsaabmsrnmerq847.png "/>
One, the permission bit description
The permission bits of a Linux file or directory are controlled by 9 permission bits, each of which is a set of three bits, which are read, written, executed by the owner of the file, read, written, executed by the user group (s), and (other) read, written, and executed by other users:
File owner: Reads read, writes write, executes X
File User Group (group): Read R, write W, execute X
Other User (Other): Read R, write W, execute X
If the permission bit is unreadable, is not writable, is not executable, it is represented by |.
There will also be special permission bits in the back: T T s X +
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m00/7d/4f/wkiol1bmfd-imhvfaaarf6auf_u047.png "title=" Image1.png "alt=" Wkiol1bmfd-imhvfaaarf6auf_u047.png "/>
Linux system hard links and soft links
1. "Link Concept"
In Linux systems, there are two types of links: one for hard links and another for soft links or symbolic links (symbolic link). The ln command is the creation of a linked file, and the link created by the LN command is a hard link in the case of a default without parameters.
If you create a link using ln-s, it is a soft link.
1.1 "Hard Link"
A hard link is a link through an index node (Inode). In the Linux (ext2,ext3) file system, files saved in a disk partition, regardless of type, are assigned a number, which is called the Index node number (Inode index), or Inode, which is the number of the file in the system.
In a Linux file system, it is normal and permissible for multiple filenames to point to the same index node (Inode). Files in this case are called hard links. One of the functions of a hard link is to allow a file to have multiple valid pathname (multiple portals) so that users can establish a hard link to important files to prevent "accidental deletion" of the source data (many hardware storage, such as NetApp) in the storage of the snapshot feature applied this principle, add a snapshot more than a hard link). Why does a file create a hard link that prevents the data from being mistakenly deleted?
Because the file system (EXT2) principle is, as long as the file's index node (Inode index) has one or more hard links. Deleting only one of the links (that is, simply deleting the link to the file) does not affect the index node itself and other links (that is, the data file entity is not deleted), only if the last link to the file is deleted, if there is new data to be stored on the hard disk, or when the system passes a disk check similar to fsck. A link to a deleted file's data block and directory is freed, and the space is occupied and overwritten by new data. At this point, the data can no longer be retrieved. In other words, in a Linux system, deleting a static file (the directory is also a file) is conditional on all the hard-linked files that are associated with it being deleted. Tip: A hard link is the equivalent of another entry in a file.
Hard link schematic diagram:
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m00/7d/4f/wkiol1bmffdzds2iaacmzrt5bli221.png "title=" Image2.png "alt=" Wkiol1bmffdzds2iaacmzrt5bli221.png "/>
Hard Links:
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m01/7d/4f/wkiol1bmfgdx0e0xaafuaxontsq120.png "title=" Image3.png "alt=" Wkiol1bmfgdx0e0xaafuaxontsq120.png "/>
Hard link removal schematic:
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m00/7d/50/wkiol1bmfligtjc7aab9nqvf_ls847.png "title=" Image4.png "alt=" Wkiol1bmfligtjc7aab9nqvf_ls847.png "/>
1.2 "Soft link"
Soft links are also known as symbolic links (symbolic link). Soft-Link files in Linx are similar to shortcuts in Windows systems. It's actually a special file. The file in the soft link. In a soft link, a soft link file is actually a text file that contains the location information content of a soft link pointing to another source file, so you can quickly navigate to the source file entity that the soft link points to by accessing the shortcut.
Schematic diagram of the soft link:
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m00/7d/51/wkiom1bmfgrcbqqtaaa_cdgwddi460.png "title=" Image5.png "alt=" WKiom1bmFgrCBqQtAAA _cdgwddi460.png "/>
To view the value of a soft link:
Readlink Print value of a symbolic link or canonical file name
[Email protected] application]# Readlink Apache
/application/apache2.2.17/
[email protected] application]# LL
Total Dosage 8
lrwxrwxrwx. 1 root root 26 March 07:43 Apache-/application/apache2.2.17/
Drwxr-xr-x. 2 root root 4096 March 20:17 apache2.2.17
Drwxr-xr-x. 2 root root 4096 March 21:45 apache2.2.18
Creating a soft Link:
Execute the command "ln-s source file Soft link file" to complete the creation of the soft link.
Summary:
1) Soft links like shortcuts in Windows, soft links inside the path of the source files stored, and execute the source file.
2) Delete the source file, the soft link file still exists, but cannot access the path content pointed to.
3) Execute the command "ln-s source file Soft link file" to complete the creation of soft links.
4) Soft links and source files are different types of files and are also different files. The inode number is different.
5) Deletion of Rm-f soft link file
2.1 File Example:
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s1.51cto.com/wyfs02/m01/7d/51/wkiom1bmfiphw6qmaaaxfuod-u4679.png "title=" Image6.png "alt=" Wkiom1bmfiphw6qmaaaxfuod-u4679.png "/>
The number of connections to the hard-link file has increased.
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/7d/50/wkiol1bmfr7bvvneaaafmmvhn5a242.png "title=" Image7.png "alt=" Wkiol1bmfr7bvvneaaafmmvhn5a242.png "/>
2.2 Catalog Examples
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s4.51cto.com/wyfs02/m00/7d/51/wkiom1bmfkeqpdaqaab3i9jkuba765.png "title=" Image8.png "alt=" Wkiom1bmfkeqpdaqaab3i9jkuba765.png "/>
Summary:The ln command cannot create a hard link to a directory, but you can create a soft link to a catalog, and a soft link to a catalog is a common feature in production scenario operations.
Description:two points under Oldboydir represent the parent directory, so the parent directory Oldboy with Oldboydir has the same node number.
2.3 "Delete Example"
[Email protected] oldboy]# echo "I am Oldboy" >oldboyfile
[email protected] oldboy]# cat Oldboyfile
I am Oldboy
[email protected] oldboy]# cat Oldboy_file_hard_link
I am Oldboy
[email protected] oldboy]# cat Oldboy_file_soft_link
I am Oldboy
Conclusion: after the content is written to the source file Oldboyfile, its soft and hard link files all have the same content.
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s2.51cto.com/wyfs02/m02/7d/50/wkiol1bmfymbvaqnaaax86t4c3e449.png "title=" Image9.png "alt=" Wkiol1bmfymbvaqnaaax86t4c3e449.png "/>
Hint: The content is still in, actually because oldboyfile_hard_link hard link exists, so even if the source file Oldboyfile is deleted, but there is still a hard link to the INODE node of the file, so, at this time the file will not be released delete, when deleting the file Oldboyfile, only the link oldboyfile to the inode node of the file is removed, and there are oldboyfile_hard_link hard links pointing to the same inode node.
[email protected] oldboy]# cat Oldboyfile_hard_link
Cat:oldboyfile_hard_link: No file or directory
#由于软链接仅仅为源文件 oldboyfile shortcut, so, at this time in the Access soft link file, found unable to access the file does not exist error.
Summary: through the above test can be seen: when the original file Oldboyfile, its hard-link file oldboyfile_hard_link is not affected, the corresponding data still exists, but its corresponding soft link file Oldboyfile_soft _link invalid, unable to find the source file, at this time, you can delete the software connection file re-create, or create a oldboyfile_hard_link hard-link file oldboyfile.
3, "link Summary"
3.1 "links to related documents summary"
First, remove the soft link oldboyfile_soft_link, no impact on Oldboyfile,oldboyfile_hard_link;
Global Conclusion : Deleting a soft link file has no effect on source files and hard-linked files.
Second, delete the hard link oldboyfile_hard_link, the oldboyfile,oldboyfile_soft_link have no impact;
Global Conclusion: Deleting a hard-link file has no effect on source files and soft-linked files.
Third, delete the original file oldboyfile, the hard link oldboyfile_hard_link no impact, but will lead to soft link oldboyfile_soft_link failure;
Global Conclusion: Delete the original file, there is no effect on the hard link file, but will cause the soft link file invalidation, white and white red background flashing.
Four, delete the original file oldboyfile, Hard link oldboyfile_hard_link, the whole file will be really deleted.
The snapshot function of many hardware devices is to take advantage of the principle of hard link.
The source file and the hard link file have the same index node number, which can be considered as multiple portals of the same file or a file.
Seven, the source file and the soft Link file index node number is different, is a different file, soft link equivalent to the source file shortcut, the directory containing the source files pointing to the location.
This article is from the "Lemon Grass Flavor" blog, please be sure to keep this source http://nmcdwd.blog.51cto.com/11299841/1750761
Properties and permissions for Linux files and directories