Linux-如何快速定位一个文件的位置?

命令 作用
which 查看可执行文件的位置
whereis 查看可执行文件的位置及相关文件
locate 搜索数据库缓存,快速查看文件位置
grep 过滤,关键字搜索文件
find 按条件查询相关文件
[root@master ~]# which find
/usr/bin/find
[root@master ~]# whereis find
find: /usr/bin/find /usr/share/man/man1/find.1.gz /usr/share/man/man1p/find.1p.gz

[root@master ~]# touch student.txt
[root@master ~]# locate student.txt
# 新添加的文件,要更新下数据库缓存。
[root@master ~]# updatedb
[root@master ~]# locate student.txt
/root/student.txt

[root@master ~]# cat /etc/passwd | grep /sbin/nologin

[root@master ~]# find / -user abong

具体的使用可以查看Linux常用命令

Logo

更多推荐