# 常用命令



# linux下通过内置命令生成随机字符串

```bash
# 生成数字加大小写英文字母随机字符串
tr -dc a-z0-9A-Z </dev/urandom | head -c 16 && echo ''
# 所有字母与数字
tr -dc [:alnum:] </dev/urandom | head -c 16 && echo ''
# 随机数字
tr -dc [:digit:] </dev/urandom | head -c 16 && echo ''
# 所有可打印字符，不包括空格
tr -dc [:graph:] </dev/urandom | head -c 16 && echo ''
```

##### 参考资料：

- [CSDN:linux 命令：tr 详解](https://blog.csdn.net/yspg_217/article/details/122925490)

# curl测试网站响应速度

```
curl "-w" "time_namelookup: %{time_namelookup}\ntime_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" <请求地址>
```

<table border="1" id="bkmrk-%E5%8F%98%E9%87%8F%E5%90%8D%E7%A7%B0-%E4%BD%9C%E7%94%A8-time_nameloo" style="border-collapse: collapse; width: 100%; height: 89.3907px;"><colgroup><col style="width: 26.3691%;"></col><col style="width: 73.7501%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="height: 29.7969px;">变量名称</td><td style="height: 29.7969px;">作用</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">time\_namelookup</td><td style="height: 29.7969px;">域名解析时间，用来排查是否为dns解析导致请求慢的原因</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">time\_connect</td><td style="height: 29.7969px;">建立TCP连接所花费时间</td></tr><tr><td>time\_starttransfer</td><td>从请求开始到响应开始传输的时间</td></tr><tr><td>time\_total</td><td>总的花费时间</td></tr></tbody></table>

##### 参考资料：

- [Cizixs Write Here — 使用 curl 命令分析请求的耗时情况](https://cizixs.com/2017/04/11/use-curl-to-analyze-request/)