zoukankan      html  css  js  c++  java
  • Linux

    文件查找方法

    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开头的文件

  • 相关阅读:
    在C#中子线程如何操作主窗口线程上的控件
    创建数据透视表数据包含合并单元格
    sql,nosql
    Enthought科学计算,数据分析
    程序员常去的14个顶级开发社区
    Windows查看进程taskList,终止进程tskill
    Pandas库之DataFrame
    centos下chm阅读器
    c++回调函数
    __NSAutoreleaseNoPool(): ... utoreleased with no pool in place
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/8252057.html
Copyright © 2011-2022 走看看