Linux 常用命令
查找
find -name ‘xxx’ 查找 xxx 所在目录
看日志
tail -100f server.log 实时输出 server.log 后一百行内容
tail -50 /usr/local/mysql/data/sql-slow.log |grep -3 ‘192.168.0.10’ ,查看mysql慢日志中ip地址为192.168.0.10发送过来的SQL语句的后面三行
grep -C 5 ‘abc’ catalina.out 显示匹配abc那行以及上下5行
grep -B 5 ‘abc’ catalina.out 显示abc及前5行
grep -A 5 ‘abc’ catalina.out 显示abc及后5行
grep -C0 ‘all’ pg_hba.conf > out.log 将 pg_hba.conf 文件中匹配 ‘all’ 对应的一行内容输出到 out.log 文件
sed -n ‘5,10p’ filename 这样你就可以只查看文件的第5行到第10行
zcat filename*.zip | grep ‘xxx’ 从当前目录的 filename 开头 zip 结尾的文件中查找 xxx
上传文件
yum install lrzsz 安装支持命令行工具
rz -b 上传二进制文件
sz -b 下载二进制文件到本地机器
vim
gg 跳到首行
G 跳到行尾
ctrl + b 向上翻页
ctrl + f 向下翻页
/xxx 向后搜索关键字 xxx
?xxx 向前搜索关键字 xxx
防火墙
为某个端口开墙
firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload
启动: systemctl start firewalld
查看状态: systemctl status firewalld
停止: systemctl disable firewalld
禁用: systemctl stop firewalld