运维常用命令(二)

curl POST请求

  • POST application/x-www-form-urlencoded
    curl -d "param1=value1¶m2=value2" -X POST http://localhost:3000/data
    相当于明确的
    curl -d "param1=value1¶m2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:3000/data
    用文件提交
    curl -d "@data.txt" -X POST http://localhost:3000/data

  • POST application/json
    curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:3000/data

  • HEADER 设置

-H "Content-Type: application/x-www-form-urlencoded"
-H "Content-Type: application/json"
-H "Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryrGKCBY7qhFd3TrwA"
  • form-data 方式提交
    curl -v -F key1=value1 -F upload=@localfilename URL
    curl -X POST -F 'image=@/path/to/pictures/picture.jpg' http://domain.tld/upload

  • 查看curl请求时间
    curl -X GET -I http://54.223.142.179:8080/img/upload/www/2017/11/08/1510107926_9f857002d4f0.jpg -H 'Host: owan-img.ymapp.com' -w %{time_total}--%{http_connect}--%{time_connect}--%{time_pretransfer}

refer: http://blog.csdn.net/hqzxsc2006/article/details/50547684

DNS查询

dig +trace @8.8.8.8 math.stackexchange.com 详细查询

  • 查询其他类型解析
dig notifier.ouwan.com  txt 
# notifier.ouwan.com.   599 IN  TXT "v=spf1 ip4:106.75.166.110 ~all" 
dig notifier.ouwan.com  mx 
# notifier.ouwan.com.   484 IN  MX  5 106.75.166.110.

nslookup
nslookup -q=txt notifier.ouwan.com 8.8.8.8

git 查看拉下来的文件有那些具体的修改

git diff HEAD^

Screen 常用用法

  • 常用参数
    screen -S yourname -> 新建一个叫yourname的session
    screen -ls -> 列出当前所有的session
    screen -r yourname -> 回到yourname这个session
    screen -d yourname -> 远程detach某个session
    screen -d -r yourname -> 结束当前session并回到yourname这个session
    screen -X -S 21417.scrapy_2 quit 删除一个session 21417.scrapy_2 是session的名字
  • 在screen session 里面的操作 C (即control键)
    C-a c -> 创建一个新的运行shell的窗口并切换到该窗口
    C-a d -> detach,暂时离开当前session,将目前的 screen session (可能含有多个 windows) 丢到后台执行,并会回到还没进 screen 时的状态,此时在 screen session 里,每个 window 内运行的 process (无论是前台/后台)都在继续执行,即使 logout 也不影响。
    C-a z -> 把当前session放到后台执行,用 shell 的 fg 命令则可回去。
    C-a w -> 显示所有窗口列表
    Ctrl+a [Space] -> 由视窗0循序切换到视窗9

pip 强制更新

sudo pip install awscli --force-reinstall --upgrade

lsof

#  列出某个程序进程所打开的文件信息
lsof -c mysql  或者
lsof | grep mysql 

# 通过某个进程号显示该进行打开的文件
lsof -p 1,2,3

# 列出谁在使用某个端口
lsof -i :3306
lsof -i tcp:80
lsof -i udp:55

# 列出所有tcp 网络连接信息
lsof -i tcp
lsof -i udp

# 列出进程某个TCP状态
lsof -a -i -s TCP:CLOSE_WAIT -p 11966

lsof lists all open file handlers for a process. Since everything in Linux is a file, you effectively get to see all open sockets, input/output streams, etc. that a process has open.
-p lists all the entries for a specific process ID
-i lists only network files open
-s lists the TCP or UDP state
-a requires all other parameters passed in to hold as true for a record to be displayed. Basically, it lets you filter based on the above properties.

你可能感兴趣的:(运维常用命令(二))