linux 常用命令
查看文件
bash
# 查看文件
cat /etc/hosts查看打开的应用占用的端口
bash
# 查看打开的端口
lsof -i -P -n |grep docker查看端口
bash
# 查看端口
netstat -anp | grep 8080查看进程
bash
# 查看进程
ps -ef | grep java查看内存
bash
# 查看内存
free -m查看磁盘
bash
# 查看磁盘
df -h查看 cpu
bash
# 查看cpu
cat /proc/cpuinfo查看系统版本
bash
# 查看系统版本
cat /etc/redhat-release查看当前路径
bash
pwdtar 压缩解压
bash
# 压缩
tar -zcvf test.tar.gz test
# 解压
tar -zxvf test.tar.gz查看文件夹大小
bash
du -sh查看文件大小
bash
ls -lh查看文件夹下文件
bash
ls -l修改权限
bash
chmod 777 test.sh查看目录下每个文件及文件夹大小
bash
du -sh *删除 指定目录下 30天之前的 log 文件
bash
#!/bin/bash
find /home/logs -mtime +30 -name "*.log" -exec rm -rf {} \;定时任务
bash
#添加定时任务
crontab -e
# 每天凌晨 1 点执行
0 1 * * * /root/log-dellogs.sh系统流量监测
bash
yum install -y bmon
# 监测网卡流量
bmon防火墙
bash
# 查看防火墙状态
systemctl status firewalld
service iptables status
# 关闭防火墙
systemctl stop firewalld
service iptables stop
# 禁止开机启动
systemctl disable firewalld
chkconfig iptables off
# 开启防火墙
systemctl start firewalld
service iptables start
# 开机启动
chkconfig iptables on
systemctl enable firewalldyum找不到包
bash
# 安装epel-release 三方源
yum -y install epel-release
yum install htop