Linux 常用命令彙總(持續更新)


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中正常使用,博客中解析有些問題 :<<! !
!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章