美文网首页linux
Linux--常用命令总结(loading)

Linux--常用命令总结(loading)

作者: 李小李的路 | 来源:发表于2019-08-26 18:16 被阅读0次
    • 基于centos7

    统计文件或文件夹个数

    • 统计当前文件夹下文件个数,当前文件夹下只能是文件
    ls -l | grep "^-" | wc -l
    
    • 统计当前文件下及所有子文件下所有文件个数
    ls -lR | grep "^-" | wc -l
    
    • 统计当前文件夹下文件的个数(不包含子文件)
    ls -l | grep "^d" | wc -l
    
    • 统计当前文件夹及子文件夹的个数
    ls -lR | grep "^d" | wc -l
    #-----------------------------------------------------------------------------------------
    [liyahui@172 2_websocket_depth_step0_file]$ ls -l | grep "^d" | wc -l
    13
    [liyahui@172 2_websocket_depth_step0_file]$ ls -lR | grep "^d" | wc -l
    296
    [liyahui@172 2_websocket_depth_step0_file]$ 
    
    • 统计当前文件夹下所有文件的总行数
    wc -l *
    

    判断linux某个端口是否被占用

    • 面试被问
    netstat  -anp  |grep   端口号
    #----状态为listen,说明被占用
    [liyahui@172 00]$ netstat -tunlp | grep 22
    (No info could be read for "-p": geteuid()=4072 but you should be root.)
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
    tcp6       0      0 :::22                   :::*                    LISTEN      - 
    

    ls命令

    # ls 
    [root@localhost ~]# ls
    anaconda-ks.cfg  install.log  install.log.syslog
    
    # ls --color=never  不显示颜色的显示目录下的文件名
    [root@localhost ~]# ls --color=never
    anaconda-ks.cfg  install.log  install.log.syslog
    
    # ls -a 显示所有文件(包含隐藏文件)
    [root@localhost ~]# ls -a
    .  ..  anaconda-ks.cfg  .bash_logout  .bash_profile  .bashrc  .cshrc  install.log  install.log.syslog  .pki  .tcshrc
    
    # ls -l 以长格式显示文件
    [root@localhost ~]# ls -l
    总用量 16
    -rw-------. 1 root root 1098 6月   8 19:38 anaconda-ks.cfg
    -rw-r--r--. 1 root root 8025 6月   8 19:38 install.log
    -rw-r--r--. 1 root root 3384 6月   8 19:38 install.log.syslog
    
    # ls -d 只显示目录
    [root@localhost ~]# ls -l
    总用量 16
    -rw-------. 1 root root 1098 6月   8 19:38 anaconda-ks.cfg
    -rw-r--r--. 1 root root 8025 6月   8 19:38 install.log
    -rw-r--r--. 1 root root 3384 6月   8 19:38 install.log.syslog
    
    # ls -i 查看inode节点号
    [root@localhost ~]# ls -i
    260965 anaconda-ks.cfg  260611 install.log  260612 install.log.syslog
    

    参考博客
    Linux企业运维人员最常用150个命令汇总
    Linux运维常用命令----持续更新

    相关文章

      网友评论

        本文标题:Linux--常用命令总结(loading)

        本文链接:https://www.haomeiwen.com/subject/qsvdectx.html