Think before you speak, read before you think.

linux使用inode笔记

今天使用ansible生成文件时,提示目标文件有 hard 硬链接,执行失败。

想要查到到底有哪些硬链,那么可以找到这些文件

find . -type f -links +1

要找到文件的inode, 使用 ls -li, 显示如下,第一列为inode number

6160399 -rw-r--r--. 3 root root 72 5月 6 2014 ifcfg-eth0

再找到都有哪些文件硬链到这个文件,使用find命令

find / -follow -inum 6160399

另一个例子,有时候shell下会生成一些乱码或touch ‘~’,这样删除挺麻烦的,即然是文件就有inode number,结合上面的命令,先找到inode number

rm `find . -follow -inum 1192387`

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *