linux中什么命令可以判断硬链接和软链接?
天蓬老师
天蓬老师 2017-04-17 15:18:12
0
6
573

linux中什么命令可以判断硬链接和软链接?
比如,在centos7.2的/etc/systemd/system目录,有一个mysqld.service,图标上有个箭头,但怎么区分这是软链接还是硬链接呢?以及它指向文件的位置怎么查看?
百度了一下,没找到相关答案。

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(6)
PHPzhong


As shown in the picture above: ls -al shows that the soft link starts with l, and there is a "->" pointer when the file name is displayed.

小葫芦

ls -al You can view the direction of the soft link
A hard link is equivalent to creating a copy of the file information. It is exactly the same as the original file. There is no difference except the file name. It is just two files. Only one copy of the file pointed to by the name exists on the hard disk. .
You can refer to soft links and hard links

左手右手慢动作

file is enough, for example:

eechen@ubuntu:~$ file /usr/bin/vi
/usr/bin/vi: symbolic link to `/etc/alternatives/vi' 
阿神

Hard links cannot be judged. The status of the two files before and after them is equal. There is no saying who has the hard link.
Soft links can be judged using anything,

巴扎黑

Soft link As mentioned above, just use ls to view it

ls -l

Hard links can be understood like this: copy a file, and this file has a synchronization function. If one of them is deleted, the other one will still exist.

The i-node number of the hard link and the source file is the same. You can use the following command to view it. However, you cannot distinguish which is the source file and which is the hard link because their status is equal. You can only see This file creates a hard link

ls -li
黄舟

Hard links cannot cross file systems and cannot operate on directories. Multiple files point to the same inode number at the same time.
Soft links can span file systems and work on directories and files.

ln a c creates a hard link
Add data in file a, and the same data will be in file c.

The a file is deleted, but the c file still exists. Think of hard links as a kind of backup.
The soft link can be regarded as a reference method and a calling method. The link file itself only stores the path and does not save the data.
So when the source file is deleted, the soft link file will also become invalid.

Generally, you can only view soft links through ls -l. At present, it is not possible to check the hard link pointing method, and there is no need to check it, because they can be regarded as mirror images of each other, exactly the same. For related information, you can only see the number of hard links after ls -l.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!