Linux命令种类繁多,有一些语法复杂冗余,不容易记住。所以我就在平时兼顾运维时总结一些常用的 Linux命令,以便不时之需。
iptables 防火墙
https://blog.csdn.net/Jiweilai1/article/details/103339784
#查看filter表存在的规则
iptables -L
iptables -list
#简单的过滤条件
#放行条件-插入到链的头部
iptables -I INPUT -s 192.168.157.12 -p tcp --dport 8443 -j ACCEPT
#禁止条件-插入到链的尾部
iptables -I INPUT -p tcp --dport 8443 -j DROP
#临时删除iptables规则
iptables -F
iptables -flush
#永久保存iptables
service iptables save
ls 浏览文件
ls -lt #按时间排序列出文件
ls -lrt #按时间排序列出文件,升序
SCP
scp /tmp/test.log [email protected]:/tmp
SFTP 安全文件传输
##指定端口,用户
sftp -P 9999 [email protected]
HDFS Shell命令
#按时间排序
hadoop fs -ls /test/ | sort -k6,7
hadoop fs -ls /test/ | sort -r -k6,7
CP 文件复制
cp test1 /opt/dir1
#-a = -dpR 保留链接,文件属性,并递归的复制文件
cp -a /opt/test1 /opt/test2
#-r 递归复制文件,用于复制文件夹到文件夹
cp -r /opt/test1 /opt/test2
WC 统计字数
wc -lcw | --version | --help
# -l 只统计行数
# -c 只统计字节数
# -w 只统计字数
wc demo1.txt
#2 13 40 demo1.txt
#demo1.txt 2行,13单词,40字节
wc demo1.txt demo2.txt
# 2 13 40 demo1.txt
# 3 25 75 demo2.txt
# 5 38 115 总用量
Shell注释
单行注释
#这是一个单行注释
多行注释
:<<!
#多行注释
#在VIM中正常使用,博客中解析有些问题 :<<! !
!