运维常用命令(二)

curl POST请求

  • POST application/x-www-form-urlencoded
    curl -d "param1=value1&param2=value2" -X POST http://localhost:3000/data
    相当于明确的
    curl -d "param1=value1&param2=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.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,845评论 18 139
  • 大家好,我是IT修真院深圳分院第01期学员,一枚正直纯洁善良的web程序员。今天给大家分享一下,修真院官网JAVA...
    老菜菜阅读 27,926评论 0 3
  • cURL是一个利用URL语法规定来传输文件和数据的工具,支持很多协议和选项,如HTTP、FTP、TELNET等,能...
    司马东阳阅读 1,449评论 0 6
  • 花重锦官城。
    eda9bfbccad2阅读 215评论 0 0
  • 我走在人头攒动的机场 突然想起些年少时的记忆 拥抱和笑容都那么肆无忌惮 一回头,我在这满是生人的人生里有些落寞 很...
    蓝胖子jxb阅读 150评论 0 0