常用Linux命令集锦

代理ip端口测试 curl

例如,代理的ip:port 是39.105.69.135:8888
测试如下:
# curl -x 39.105.69.135:8888 -v https://www.baidu.com
* About to connect() to proxy 39.105.69.135 port 8888 (#0)
*   Trying 39.105.69.135...
* Connected to 39.105.69.135 (39.105.69.135) port 8888 (#0)
> GET HTTP://icanhazip.com/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: icanhazip.com
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 OK
< Via: 1.1 tinyproxy (tinyproxy/1.8.3)
< Content-Type: text/plain; charset=UTF-8
< Server: nginx
< Access-Control-Allow-Methods: GET
< Date: Thu, 26 Jul 2018 07:47:37 GMT
< X-SECURITY: This site DOES NOT distribute malware. Get the facts. https://goo.gl/1FhVpg
< Access-Control-Allow-Origin: *
< Content-Length: 14
< X-RTFM: Learn about this site at http://bit.ly/icanhazip-faq and do not abuse the service.
< 
39.105.69.135
* Connection #0 to host 39.105.69.135 left intact

查看某个进程是否在执行

# ps aux | fgrep python
root       737  0.3  0.6 395872 53808 ?        S    Jul21  28:46 python spider_update_tags.py
root       738  0.3  0.3 395732 27788 ?        S    Jul21  28:41 python spider_update_tags.py
root       781  0.0  0.0 562412  5168 ?        Ssl  Jul06   2:52 /usr/bin/python -Es /usr/sbin/tuned -l -P
root     13279  0.0  0.0 112664   888 pts/0    R+   15:49   0:00 grep -F --color=auto python
root     15632  0.0  0.2 326840 20692 ?        Ss   01:07   0:00 /usr/bin/python /usr/bin/salt-minion
root     15683  0.0  0.4 1275308 37292 ?       Sl   01:07   0:30 /usr/bin/python /usr/bin/salt-minion
root     15689  0.0  0.2 401888 17764 ?        S    01:07   0:00 /usr/bin/python /usr/bin/salt-minion
root     18692  0.0  0.6 1256932 49440 ?       Sl   Jul21   6:58 python spider_update_tags.py

批量杀掉进程

例如我想杀掉上面的进程名称是 spider_update_tags.py
那么执行
ps -ef|grep spider_update_tags.py|grep -v grep|awk  '{print "kill -9 " $2}' |sh

安装pymysql

Cython:pip install Cython        ##python包

freetds-dev:yum install freetds-devel.x86_64 / apt-get install freetds-dev   ##linux包

最后安装pymssql: pip install pymssql

查看当前文件夹下的所有文件名称和大小

du -sh *
36K     init
408M    python-projects

安装pymssql

yum -y install freetds-devel.x86_64
pip install pymssql

常用Git命令

首先强调一点,任何工程在开发过程中,我建议就2个分支,master和develop。 当然了,持续发布项目大多数只有1个分支--原因是代码维护成本高。

#查看所有分支(本地和远程)
git branch -a  

#从远程master分支拉取并创建名称为develop的本地分支
git checkout -b develop master

#切换本地分支到develop
git checkout develop

#把本地develop推送到远程仓库,并创建名称为develop的远程分支



Crypto报错

from Crypto.Cipher import AES报错
原因:没有安装Crypto包
解决办法

pip install singledispatch    
pip install pycrypto

打压缩包和解压

zip -r qmz_upload.zip ./*
zip -r test.zip test.txt 
unzip test.zip 

查看Nginx安装目录和配置文件

1.查看Nginx安装路径
ps aux|grep nginx
root 352 0.0 0.0 2468624 924 ?? S 10:43上午 0:00.08 nginx: worker process 
root 232 0.0 0.0 2459408 532 ?? S 10:43上午 0:00.02 nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off; 
root 2345 0.0 0.0 2432772 640 s000 S+ 1:01下午 0:00.00 grep nginx

nginx的路径为:/usr/local/opt/nginx/bin/nginx

2.查看Nginx配置文件
/usr/local/opt/nginx/bin/nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
测试可知,nginx的配置文件路径为:/usr/local/etc/nginx/nginx.conf 且调用有效。

启动springboot的工程包

nohup java -jar xxx.jar  &