一、find,查找某个文件的存放路径
find用来查找某个文件的存放位置。即你知道文件名字,但不知道放在哪里。
使用格式:“ find 查找路径 -name "要查找的文件名" ”
使用举例:find /etc -name "interfaces"
root@ubuntu:/# find /etc -name "interfaces" /etc/network/interfaces /etc/cups/interfaces root@ubuntu:/#
二、grep,在众多文件中查找某个符号
这个符号有可能在一个文件里出现,也可能在多个文件里出现。
使用格式:“ grep -nr “要查找的符号” 文件路径 ”,其中-n表示在结果中显示行号,-r表示递归查找。
使用举例:grep -nr "include" ./
root@ubuntu:/home/xjh/iot/embedded_basic/rootfs# ls rootfs.ext2 rootfsxjh rootfs_xjh tmp root@ubuntu:/home/xjh/iot/embedded_basic/rootfs# grep -nr "include" ./ 匹配到二进制文件 ./rootfs.ext2 匹配到二进制文件 ./rootfs_xjh/bin/busybox 匹配到二进制文件 ./rootfs_xjh/lib/libpthread-2.10.1.so 匹配到二进制文件 ./rootfs_xjh/lib/libnss_files-2.10.1.so ./tmp/app.c:1:#include<stdio.h> ./tmp/driver_test.c:3:#include <linux/module.h> // module_init module_exit ./tmp/driver_test.c:4:#include <linux/init.h> // __init __exit ./tmp/driver_test.c:5:#include <linux/fs.h> root@ubuntu:/home/xjh/iot/embedded_basic/rootfs#
三、which与whereis,查找应用程序(命令)的路径
这两个命令查找一个应用程序(二进制文件)的路径。
which只显示命令的路径,而whereis显示路径或者man手册位置。
举例:which ls,which mkdir,which which,whereis ls等等。
root@ubuntu:/home/xjh/iot/embedded_basic/rootfs# which ls /bin/ls root@ubuntu:/home/xjh/iot/embedded_basic/rootfs# whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz root@ubuntu:/home/xjh/iot/embedded_basic/rootfs#