Linux find 命令 - 根据 inode 和设备查找文件?

Linux find 命令 - 根据 inode 和设备查找文件?

我想找到具有给定索引节点号的文件。使用 find with-inum并不完全有帮助,因为它会列出每个文件系统/设备的索引节点号文件。如何将此搜索限制到特定设备/文件系统?

下面没有帮助 -

$ sudo find / -inum 2
/
/dev
/dev/shm
/dev/pts/ptmx
/sys/kernel/debug/acpi
/sys/fs
/sys/fs/cgroup
/sys/fs/cgroup/memory/cgroup.procs
/sys/fs/cgroup/pids/cgroup.procs
/sys/fs/cgroup/rdma/cgroup.procs
/sys/fs/cgroup/cpuset/cgroup.procs
/sys/fs/cgroup/devices/cgroup.procs
/sys/fs/cgroup/blkio/cgroup.procs
/sys/fs/cgroup/perf_event/cgroup.procs
/sys/fs/cgroup/freezer/cgroup.procs
/sys/fs/cgroup/hugetlb/cgroup.procs
/sys/fs/cgroup/cpu,cpuacct/cgroup.procs
/sys/fs/cgroup/net_cls,net_prio/cgroup.procs
/sys/fs/cgroup/systemd/cgroup.procs
/sys/fs/cgroup/unified/cgroup.procs
/run
/run/user/1000
find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied
/run/user/125
find: ‘/run/user/125/gvfs’: Permission denied
/run/lock
/snap/gtk-common-themes/1506/meta/snap.yaml
/snap/snapd/8790/bin/fc-cache-v6
/snap/snapd/8542/bin/fc-cache-v6
/snap/tusk/29/LICENSES.chromium.html
/snap/gnome-3-34-1804/36/bin/bunzip2
/snap/gnome-3-34-1804/36/bin/bzcat
/snap/gnome-3-34-1804/36/bin/bzip2
/snap/snap-store/467/autostart/setup-autostart
/snap/core18/1885/bin
/snap/core18/1880/bin
/snap/jdownloader2/10/etc/X11
/snap/jdownloader2/12/etc/X11
/snap/core/9804/bin/bash
/proc/fs/nfsd/exports
/proc/sys/fs/binfmt_misc/status 

下面确认上面列出的文件来自各种设备

/etc$ stat /dev/shm /dev /dev/pts/ptmx 
  File: /dev/shm
  Size: 80          Blocks: 0          IO Block: 4096   directory
Device: 1ah/26d Inode: 2           Links: 2
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-09-03 14:01:23.968171064 +0530
Modify: 2020-09-03 14:01:53.055049949 +0530
Change: 2020-09-03 14:01:53.055049949 +0530
 Birth: -
  File: /dev
  Size: 4920        Blocks: 0          IO Block: 4096   directory
Device: 6h/6d   Inode: 2           Links: 23
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-09-03 11:24:49.787963116 +0530
Modify: 2020-09-03 11:20:16.282767765 +0530
Change: 2020-09-03 11:20:16.282767765 +0530
 Birth: -
  File: /dev/pts/ptmx
  Size: 0           Blocks: 0          IO Block: 1024   character special file
Device: 18h/24d Inode: 2           Links: 1     Device type: 5,2
Access: (0000/c---------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-09-03 10:18:19.587999997 +0530
Modify: 2020-09-03 10:18:19.587999997 +0530
Change: 2020-09-03 10:18:19.587999997 +0530
 Birth: -

答案1

使用-xdev(如之前对您的问题的回答所示find):

find / -xdev -inum 2

替换/为您感兴趣的任何安装点。

相关内容