符号链接和硬链接有什么区别? [英] What is the difference between a symbolic link and a hard link?

查看:204
本文介绍了符号链接和硬链接有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我在求职面试中被问到这一点.我很诚实,说我知道符号链接的行为以及如何创建符号链接,但不了解硬链接的用法以及它与符号链接的区别.

Recently I was asked this during a job interview. I was honest and said I knew how a symbolic link behaves and how to create one, but do not understand the use of a hard link and how it differs from a symbolic one.

推荐答案

在文件系统下,文件由inode表示. (或者是多个inode?不确定.)

Underneath the file system, files are represented by inodes. (Or is it multiple inodes? Not sure.)

文件系统中的文件基本上是指向inode的链接.
然后,硬链接只会创建另一个文件,并带有指向相同基础inode的链接.

A file in the file system is basically a link to an inode.
A hard link, then, just creates another file with a link to the same underlying inode.

删除文件时,它会删除一个指向基础索引节点的链接.仅在删除到该索引节点的所有链接后,该索引节点才会被删除(或可删除/可重写).

When you delete a file, it removes one link to the underlying inode. The inode is only deleted (or deletable/over-writable) when all links to the inode have been deleted.

符号链接是指向文件系统中另一个名称的链接.

A symbolic link is a link to another name in the file system.

一旦建立了硬链接,链接即指向inode.删除,重命名或移动原始文件不会影响硬链接,因为它链接到基础索引节点.索引节点上数据的任何更改都会反映在引用该索引节点的所有文件中.

Once a hard link has been made the link is to the inode. Deleting, renaming, or moving the original file will not affect the hard link as it links to the underlying inode. Any changes to the data on the inode is reflected in all files that refer to that inode.

注意:硬链接仅在同一文件系统内有效.符号链接可以跨越文件系统,因为它们只是另一个文件的名称.

Note: Hard links are only valid within the same File System. Symbolic links can span file systems as they are simply the name of another file.

这篇关于符号链接和硬链接有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆