09.系统管理常用命令

2018-12-24  本文已影响0人  __深蓝__

目标

shutdown
ifconfig
ping

01. 关机/重启

1.1 shutdown

  • 不指定选项和参数,默认表示 1 分钟之后 关闭电脑
  • 远程维护服务器时,最好不要关闭系统,而应该重新启动系统
# 重新启动操作系统,其中 now 表示现在
$ shutdown -r now

# 立刻关机,其中 now 表示现在
$ shutdown now

# 系统在今天的 20:25 会关机
$ shutdown 20:25

# 系统再过十分钟后自动关机
$ shutdown +10

# 取消之前指定的关机计划
$ shutdown -c

02. 查看或配置网卡信息

2.1 网卡 和 IP 地址

网卡

IP 地址

2.2 ifconfig

# 查看网卡配置信息
ifconfig

# 查看网卡对应的 IP 地址
ifconfig | grep inet
//

提示:一台计算机中有可能会有一个 物理网卡多个虚拟网卡,在 Linux 中物理网卡的名字通常以 ensXX 表示

2.2.1 显示网络设备信息
[neusoft@localhost ~]# ifconfig        
eth0   Link encap:Ethernet HWaddr 00:50:56:0A:0B:0C 
     inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0
     inet6 addr: fe80::250:56ff:fe0a:b0c/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
     RX packets:172220 errors:0 dropped:0 overruns:0 frame:0
     TX packets:132379 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000 
     RX bytes:87101880 (83.0 MiB) TX bytes:41576123 (39.6 MiB)
     Interrupt:185 Base address:0x2024 

lo    Link encap:Local Loopback 
     inet addr:127.0.0.1 Mask:255.0.0.0
     inet6 addr: ::1/128 Scope:Host
     UP LOOPBACK RUNNING MTU:16436 Metric:1
     RX packets:2022 errors:0 dropped:0 overruns:0 frame:0
     TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:0 
     RX bytes:2459063 (2.3 MiB) TX bytes:2459063 (2.3 MiB)
2.2.2 启动关闭指定网卡
[neusoft@localhost ~]# ifconfig eth0 down
[neusoft@localhost ~]# ifconfig eth0 up
2.2.3 配置IP地址
# 给eth0网卡配置IP地址
[neusoft@localhost ~]# ifconfig eth0 192.168.1.56 

# 给eth0网卡配置IP地址,并加上子掩码
[neusoft@localhost ~]# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 
 
# 给eth0网卡配置IP地址,加上子掩码,加上个广播地址
[neusoft@localhost ~]# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255

2.3 ping

检测到目标主机是否连接正常
格式:ping IP地址

# 检测本地网卡是否工作正常
[neusoft@localhost ~]$ ping 127.0.0.1

# 检测能否访问外网
[neusoft@localhost ~]$ ping www.baidu.com
PING www.a.shifen.com (220.181.111.37) 56(84) bytes of data.
64 bytes from 220.181.111.37 (220.181.111.37): icmp_seq=1 ttl=128 time=31.6 ms

提示:在 Linux 中,想要终止一个终端程序的执行,绝大多数都可以使用 CTRL + C




- end -

上一篇 下一篇

猜你喜欢

热点阅读