Linux - 文件查找方法
2018-01-09 16:23
274 查看
文件查找方法
1.which
查找可执行文件的位置
2.whereis
查找可执行文件的位置与相关的文件
3.grep
过滤
4.find
找文件
搜索以host开头的文件
1.which
查找可执行文件的位置
[root@local /]# which passwd /usr/bin/passwd
2.whereis
查找可执行文件的位置与相关的文件
[root@local /]# whereis passwd passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
3.grep
过滤
[root@local /]# grep home /etc/passwd jiqing:x:1000:1000:jiqing:/home/jiqing:/bin/bash www:x:1001:1001::/home/www:/sbin/nologin zhubajie:x:2018:2018::/home/zhubajie:/bin/bash sunwukong:x:2019:2018::/home/sunwukong:/bin/bash niumowang:x:2020:2018::/home/niumowang:/bin/bash
[root@local /]# netstat -anpo | grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5711/sshd off (0.00/0/0) tcp 0 52 192.168.70.77:22 192.168.70.33:59072 ESTABLISHED 9414/sshd: root@pts on (0.23/0/0) tcp 0 0 192.168.70.77:22 192.168.70.33:56269 ESTABLISHED 5732/sshd: www [pri keepalive (1019.14/0/0) tcp6 0 0 :::22 :::* LISTEN 5711/sshd off (0.00/0/0)
-a (all)显示所有选项,默认不显示LISTEN相关。 -n 拒绝显示别名,能显示数字的全部转化成数字。 -p 显示建立相关链接的程序名。
4.find
找文件
.当前目
/根目录。
-type b 设备文件 d 目录 c 字符设备文件 p 管道文件 l 符号链接文件 f 普通文件
[root@local /]# find / -name passwd -type f /etc/passwd /etc/pam.d/passwd /usr/bin/passwd /usr/share/bash-completion/completions/passwd
[root@local /]# find /etc/ -name "host*" /etc/selinux/targeted/modules/active/modules/hostname.pp /etc/host.conf /etc/hosts /etc/hosts.allow /etc/hosts.deny /etc/avahi/hosts /etc/hostname
搜索以host开头的文件
相关文章推荐
- Linux系统中查找文件的方法
- linux下查找一般文件方法
- Linux查找文件内容的常用命令方法
- Linux查找文件内容的常用命令方法
- Linux查找文件内容的常用命令方法
- Linux中文件查找方法大全
- Linux 中文件查找方法大全
- linux下查找文件或字符串的方法
- Linux中文件查找方法大全
- Linux查找文件内容的常用命令方法
- linux下查找文件的方法 (网上转的。怕自己忘记了)
- Linux中文件查找方法大全
- linux下查找文件命令find使用方法
- Linux查找文件内容的常用命令方法
- Linux中文件查找方法大全
- Linux下查找含有某字符串的文件的方法
- Linux中文件查找方法大全
- linux下查找某个文件位置的方法
- 在Linux系统中查找文件的方法
- LINUX下查找文件的方法