测试常用备忘命令

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章