zhaoyu@home:~$

linux命令-其他命令

Curl

获取http请求的时间

将获取时间格式化的脚本保存为一个txt文件。因为命令很长,在命令中书写不方便。如下:

  time_namelookup:  %{time_namelookup}\n
  time_connect:  %{time_connect}\n
  time_appconnect:  %{time_appconnect}\n
  time_redirect:  %{time_redirect}\n
  time_pretransfer:  %{time_pretransfer}\n
  time_starttransfer:  %{time_starttransfer}\n
                ----------\n
  time_total:  %{time_total}\n

执行curl命令如下: ```shell script curl -o /dev/null -s -w “@curl_format.txt” http://localhost:8080/api/currency

`-o /dev/null` 表示不输出。 `-s` 不输出错误信息和进度。

### post请求
```shell script
curl localhost:3000/api/basic -X POST -d 'hello=world&xxx=yyy&a[]=ooo&a[]=mmm'

或者将请求保存在文件中,如data.txt。 ```shell script curl localhost:3000/api/basic -X POST -d @data.txt


json的请求需要设定请求内容:
```shell script
curl localhost:3000/api/json -X POST -d @data.json --header "Content-Type: application/json"

当请求格式是multipart/form-data时,通常会有文件上传。 ```shell script curl localhost:3000/api/multipart -F raw=@test.img -F hello=world

加cookie,使用--cookie选项,多个值用分号隔开。
```shell script
curl http://localhost:62439/admin/system/coin/page-query -X POST 
--cookie "JSESSIONID=B7C82EC4E8D962FA887891D8109B62E4;Domain=localhost;HttpOnly;"

查看进程的完整路径

ps或top命令查看进程的信息,只能看到相对路径,查不到的进程的详细信息,如绝对路径等。

Linux在启动一个进程时,系统会在/proc下创建一个以PID命名的文件夹,在该文件夹下会有我们的进程的信息,其中包括一个名为exe的文件即记录了绝对 路径,通过ll命令即可查看。

ll /proc/PID

其中cwd符号链接是进程运行目录。exe符号连接就是执行程序的绝对路径。