Skip to content
On this page

远程管理

1. shutdown命令

sh
# 命令格式
$ shutdown [-options] [time]
  • shutdown命令一般需要root权限执行
  • 远程维护服务器时,最好不要关闭系统(关闭后启动不方便),一般选择重启系统

1) options

options含义
缺省默认行为为关机
-r重新启动。shutdown -r now 等价于 reboot
-c取消代执行的关机或重启任务,必须在关机或重启之前执行

2) time

options含义
缺省默认为1分钟后执行
+mm分钟后执行
now现在立即执行
hh:mm指定时间执行,只能设置小时和分钟
sh
# 1分钟后关机
$ shutdown

# 立即重启
$ shutdown -r now

# 10分钟后关机
$ shutdown +10

# 今天20:30 重启
$ shutdown -r 20:30

# 取消关机或重启任务
$ shutdown -c

2. ifconfig命令

sh
# 命令格式
$ ifconfig [-options]
  • 如果命令不存在,需要先进行安装sudo apt install net-tools
  • 一台计算机可能有一个物理网卡和多个虚拟网卡,在Linux中物理网卡名字通常为ensXX
sh
# 查看网卡配置信息
$ ifconfig

# 过滤查看IP地址
$ ifconfig | grep inet

除了ifconfig命令,也常用ip addr来查看网路配置。

3. 网络

3.1 ping命令

sh
# 命令格式
$ ping [-options] destination
  • ping一般用于检测当前计算机到目标计算机之间的网络是否通畅。我们给目标IP发送一个数据包,对方返回一个包,根据返回包的时间我们可以确定目标计算机是否存在并且工作正常以及网络链接速度。
  • Linux中ping命令不会自动停止,可以使用Ctrl + C退出。
  • ping 127.0.0.1 可以测试本机网卡是否正常工作

3.2 curl命令

sh
# 命令格式
$ curl [options...] url
  • curl一般用于发送网路请求到指定URL,也可以用于检测网路连通性。如果很多人使用浏览器访问百度以检测网络可用性。
  • 常用配合-o用于下载网路资源。Ubuntu下也可以使用其wget命令。
sh
# 请求 https://a-nomad.com
$ curl https://a-nomad.com

# 下载
$ curl -o index.html https://a-nomad.com
$ wget https://a-nomad.com # Linux only

4. ssh命令

ssh小白入门教程一次弄懂ssh入门到精通

5. scp命令

scp远程拷贝命令详解

Released under the MIT License.