1 postgresql基礎指令
psql -U postgres -d $database -h 127.0.0.1 -p 5432
sudo -u postgres /usr/pgsql-9.6/bin/psql -d tip -f /opt/tip/config/postgres/tip_notice.sql #shell命令行執行sql語句
https://blog.csdn.net/u010856284/article/details/70142810
2 pip 指令
pip指令
pip list 已經安裝的pip包
pip install 庫名
pip show 庫名
pip uninstall 庫名
3 正則拿ip地址
grep -oP '\d+\.\d+\.\d+\.\d+' cc.txt
sort ip_reputation.txt |uniq -dc #找重複行並去重
4 pip 國內鏡像源
pip install requests -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
5 redis查找ip格式數據
echo "scan 1 match * count 10" | redis-cli -h 127.0.0.1 -p 6379 -n 1 -a xxxxx | grep "[0-9]\{1,3\}[.][0-9]\{1,3\}[.][0-9]\{1,3\}[.][0-9]\{1,3\}"
6 查找大文件
du -h --max-depth=1 /opt/data/
du -sh *
find . -type f -size +100M
du -hm --max-depth=2 | sort -nr | head -n 5
7 修改pg數據允許鏈接的遠程ip
/var/lib/pgsql/9.6/data/pg_hba.conf
systemctl restart postgresql-9.6.service
8 ssh代理
#ssh反向代理
ssh -fCNR 8888:localhost:22 [email protected]
#ssh正向代理
ssh -fCNL *:1234:localhost:8888 localhost
9 java環境配置
(1)在/etc/profile文件末尾下加(全局)。 限制到每個用戶生效用 vim .bash_profile在文件末尾加然後重新登錄即可
export JAVA_HOME=/home/jrsj/jdk1.6.0_25
export JAVA_BIN=$JAVA_HOME/bin
export JAVA_LIB=$JAVA_HOME/lib
export CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jar
export PATH=$JAVA_BIN:$PATH12345
(2)source ~/.bashrc
(3)java -version
10 iptables配置
iptables -A INPUT -s 192.168.1.5 -j DROP 行尾追加
iptables -I INPUT 3 -s 192.168.1.3 -j DROP 插入
iptables -D INPUT -s 192.168.1.5 -j DROP 刪除
11 python搭建簡單的httpserver
1.進入要共享的目錄
2.開啓pythonhttpserver服務
python -m SimpleHTTPServer 9090
12 liunx環境作圖gnuplot
set xdata time
set timefmt "%H:%M:%S"
set xlabel 'TIME'
set ylabel 'CPU'
set term png size 1024,768
set output "./cpu.png"
plot './test.txt' using 1:3 title '%us' with lines, './test.txt' using 1:5 title '%sy' with lines, './test.txt' using 1:6 title '%wa' with lines
13 python 通過json格式查看數據
python -m json.tool testrecord.json
14 查看網卡隊列
grep eth0 /proc/interrupts |awk '{print $NF}'
15 資源消耗監控
pidstat -w -u -t 2
vmstat -w 3 3
16 seliunx ,在傳統的linux系統中,一切皆文件,有用戶,組和權限來控制訪問,在selinux中,一切皆對象,由存放在擴展屬性域的安全元素控制訪問,所有文件、端口、進程都具備安全上下文
getenforce查看當前狀態
setenforce臨時開啓或關閉selinux
setenforce 0|1,其中0代表permissive,1代表enforcing
sestatus詳細查看當前selinux狀態
17 網卡流量統計
nload -m -u M
18 linux日誌輸出控制
0,1,2 ---標準輸入、標準輸出、錯誤輸出
如 ls 2>/dev/null 1>/dev/null #不輸出任何日誌
ls >/dev/null 2>&1
ls >/dev/null 2>./log #錯誤日誌寫入log文件中,其他日誌不回顯
19 查看liunx版本
[root@tmpt01 ~]$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
20 git使用
git branch -a 查看有哪些分支
git checkout -b xxxx 查看並創建
git status
git add xx
git commit -m 'xxxxxx'
git pull
git push
git log
git diff
git config --system --unset credential.helper
21 瀏覽器中url編碼
decodeURI('%E4%B8%AD%E5%9B%BD')
"中國"
22 python異常寫文件
try:
... 1/0
... except Exception,e:
... traceback.print_exc(file=open('tb.txt','a'))
23 print寫文件
print>>open("aa.txt",'w'),"第{}條數據".format(args) #python2
wirte_hash = open('Sample_hash.txt','w') #python3
print(sha1,file=wirte_hash)
wirte_hash.close()
24 python時間格式化
import time
time.strftime("%Y%m%d%H%M%S", time.localtime())
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time() - 86400))
print time.time()
print time.localtime(time.time())
25 history命令加時間戳
echo 'export HISTTIMEFORMAT="%F %T ${USER_IP} `whoami` "' >>/etc/profile
26 hosts文件位置
host文件位置 C:\Windows\System32\drivers\etc\
27 查找殭屍進程
ps -A -o stat,ppid,pid,cmd |grep -e '^[Zz]'
28 python base64
base64.b64encode()
base64.b64decode()
29 網卡檢測
ifconfig,ip addr #地址和協商狀態
ethtool #查看協商模式
mii-tool #檢測線路的物理狀態
ethtool -s eth7 speed 100 duplex full autoneg off #配置網卡速率
ip addr add 10.44.100.155/24 dev eth7 #配置臨時地址
30 漢化burpsuite
cd C:\Program Files\BurpSuiteCommunity
java -Dfile.encoding=utf-8 -javaagent:BurpSuiteCn.jar -Xbootclasspath/p:burp-loader-keygen.jar -Xmx1024m -jar burpsuite_community.jar
31 yum源更新
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache