统计文件或文件夹个数
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运维常用命令----持续更新
网友评论