当前位置: 首页 > news >正文

Linux学习笔记4 重点!网络排障命令

网络排障命令

命令行下载工具wget

wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.gz

wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.gz

限速下载

wget --limit-rate=1M https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.gz

使用wget -c进行断点续传

wget -c https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.gz

测试服务器是否支持断点续传

wget -S http://mirrors.163.com 2>&1 |grep "Accept-Range"

 说明支持断点续传:按字节。

让下载的文件按指定文件名保存。

wget -o filename

wget -o 1.tar.gz https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.20.17.tar.gz

-o 后面跟-可以代表输出到标准输出,也就是命令行上。

curl工具

官方文档:

curl - 如何使用

探测一个网站的header

curl -I https://www.baidu.com

 类似于wget中的-S选项

显示网站的http状态码

curl -s -o /dev/null -w %{http_code}"\n" https://www.baidu.com

-s表示安静模式

-o表示输出到哪里,这里指的是输出到空设备中

-w表示输出定义的元数据也就是会给后面的httpcode赋值、

注意这里我们“\n”紧跟在%{http_code}后面。中间如果有空格会导致输出和我们预料的不同。

关于http状态码:

常见的有404等

HTTP 响应状态码 - HTTP | MDN (mozilla.org)

curl -s -o \dev\null -w %{http_code}"\n"%{time_total}"\n"%{redirect_url}"\n" http://blog.csdn.net

 输出的三个结果分别是:

301定向操作状态码,解析网站总时间,跳转后的url。

curl实现重定向

下面是两个例子:代表用户使用curl请求某个网址时,当出现了301,或者302重定向操作,就会按照我们的-L参数去到新的url。然后就有了第二段输出状态码200的成功连接。

curl -L -I http://blog.csdn.net
HTTP/1.1 301 Moved Permanently
Date: Wed, 28 Aug 2024 05:06:51 GMT
Content-Type: text/html
Content-Length: 160
Connection: close
Set-Cookie: ...;Expires=...; Path=/; HttpOnly
Location: https://blog.csdn.net:443/
X-Request-Id: ...
Server: WAFHTTP/1.1 200 OK
Date: Wed, 28 Aug 2024 05:06:51 GMT
Content-Type: text/html; charset=utf-8
Connection: close
Set-Cookie: https_waf_cookie=...; Expires=...; Path=/; Secure; HttpOnly
Server: WAF
Vary: Accept-Encoding
Vary: Origin
X-Response-Time: 197
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-download-options: noopen
x-readtime: 198
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: ...
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Strict-Transport-Security: max-age=0; preload
X-Request-Id: ...
Set-Cookie: ...
curl -L -I http://www.bilibili.com/
HTTP/1.1 301 Moved Permanently
Server: Tengine
Date: Wed, 28 Aug 2024 05:30:47 GMT
Content-Type: text/html
Content-Length: 239
Connection: keep-alive
Location: https://www.bilibili.com/HTTP/2 200 
date: Wed, 28 Aug 2024 05:30:48 GMT
content-type: text/html; charset=utf-8
support: nantianmen
cache-control: no-cache
expires: Wed, 28 Aug 2024 05:30:47 GMT
pragma: no-cache
vary: Origin,Accept-Encoding
x-cache-webcdn: MISS from blzone11
x-cache-time: 0
x-origin-time: no-store, no-cache, must-revalidate, private
x-save-date: Wed, 28 Aug 2024 05:30:48 GMT

curl抓取网页保存

下面是

 curl -O https://www.baidu.com/index.html

 还可以指定保存的名称:

curl -o myhtml.html -O https://www.baidu.com/index.html

 

 curl下载文件并且实现断点续传

还是curl -O而且比wget似乎更好用,能看到数据大小,已下载大小,总下载用时,已经用时,下载速度等等。中间可以按ctrl+c中断下载,接着继续执行该程序,会实现断点续传。注意使用参数-C。

curl -o myiso.iso https://mirrors.iu13.net/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-dvd1.iso

下面是我在window本地尝试的结果,但是似乎和我想的不同,测试过服务器支持断点续传,不知道为什么总是从头开始,也许是我用ctrl+C有问题,我尝试断开网络。 

使用官方用例仍然失败,只好暂且放弃。 

curl限速2M下载

curl --limit-rate 2M -O https://mirrors.cloud.tencent.com/tencentos/4.0/isos/x86_64/TencentOS-Server-4.0-everything-x86_64.iso

 可以更改为对应速率,防止占满带宽。

scp命令

securecopy 用于将文件或者目录从一个linux系统复制到另外一个linux系统,使用的协议是ssh协议,保证了数据传输的安全性。格式为:

scp remotename@remoteip:/etc/hisfile /var/myfile
scp /var/myupoadfile myfriend@hisip:/var/hisfile

分别是从远程下载和传送文件给远方服务器的命令例子注意文件路径是绝对路径。

这里我就不贴截图了,我经过尝试确实是可以的。

本地的a.txt上传到我们的服务器上啦! 

 如果要复制目录的话就要加上-r选项啦

scp -r /mydir ubuntu@ip:/hisdir
scp -r ubuntu@ip:/hisdir /mydir 

ssh服务使用22端口,所以scp都是使用22端口,-P选项允许我们指定端口

scp -P 2222 remotename@remoteip:/etc/hisfile /var/myfile

限速scp -l

scp -l 10000 remotename@remoteip:/etc/hisfile /var/myfile

这里限速的单位是kbit,换算为KB要除以8.

动态路由追中及网络排障工具mtr命令

下载安装

yum install mtr

ubuntu:

apt-get install mtr

使用方法:mtr url(ip)


http://www.mrgr.cn/news/13697.html

相关文章:

  • Go 中间件学习
  • Spark MLlib 特征工程系列—特征转换VectorSizeHint
  • 扑捉一只耿鬼(HTML文件)
  • 在Ubuntu 18.04上如何从默认的APT仓库安装MongoDB
  • 【Yarn】Yarn的基本执行流程(二)AM Container的启动
  • OpenCV绘图函数(4)绘制轮廓线的函数drawContours()的使用
  • MySQL数据库MVCC机制底层原理详解
  • 软件测试 | 测试用例Ⅱ
  • idea便捷操作
  • 创建型设计模式-构建器(builder)模式-python实现
  • 【国外比较权威的免费的卫星数据网站——NASA Worldview】
  • 未来十年美业发展方向:健康与美容的结合|美业SaaS系统收银系统源码
  • 数据结构-顺序表-详解
  • [Arxiv 2024] Self-Rewarding Language Models
  • 一步步理解 Python 异步生成器(AsyncGenerator)——从入门到实践
  • CMake Error at CMakeLists.txt (find_package)幕后真凶
  • Git 常用命令总结
  • zsh: command not found: ohpm - mac安装ohpm工具 - 鸿蒙开发
  • Aiseesoft Data Recovery for Mac:专业级数据恢复解决方案
  • Semantic Kernel/C#:一种通用的Function Calling方法,文末附经测试可用的大模型