linux学习命令总结⑩⑦
#chkconfig命令:主要用来启动/停止和查询系统服务的运行级信息
显示所有运行级系统服务的运行状态信息:
[root@VM_168_102_centos ~]# chkconfig --listabrt-ccpp 0:off 1:off 2:off 3:on 4:off 5:on 6:off abrt-oops 0:off 1:off 2:off 3:on 4:off 5:on 6:off abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off acpid 0:off 1:off 2:off 3:off 4:off 5:off 6:off amtu 0:off 1:off 2:off 3:off 4:off 5:off 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off auditd 0:off 1:off 2:off 3:off 4:off 5:off 6:off cpuspeed 0:off 1:off 2:off 3:off 4:off 5:off 6:off
显示指定服务的运行状态:
[root@VM_168_102_centos ~]# chkconfig --list networknetwork 0:off 1:off 2:on 3:on 4:on 5:on 6:off
设置某服务开机自动启动:(系统默认只对运行级3,4,5有效)
[root@VM_168_102_centos ~]# chkconfig --list abrt-ccppabrt-ccpp 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@VM_168_102_centos ~]# chkconfig abrt-ccpp on [root@VM_168_102_centos ~]# chkconfig --list abrt-ccpp abrt-ccpp 0:off 1:off 2:on 3:on 4:on 5:on 6:off
禁止某服务开机自动启动:(系统默认只对运行级3,4,5有效)
[root@VM_168_102_centos ~]# chkconfig --list abrt-ccpp abrt-ccpp 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@VM_168_102_centos ~]# chkconfig abrt-ccpp off[root@VM_168_102_centos ~]# chkconfig --list abrt-ccpp abrt-ccpp 0:off 1:off 2:off 3:off 4:off 5:off 6:off
重启某服务:
service Script_Name restart
#ip link show:显示设备属性
[root@VM_168_102_centos ~]# ip link show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:e2:7b:d2 brd ff:ff:ff:ff:ff:ff [root@VM_168_102_centos ~]# ip link show eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:e2:7b:d2 brd ff:ff:ff:ff:ff:ff
#ip link set:改变设备属性
关闭/开启某网络接口:
[root@VM_168_102_centos ~]# ip link set dev lo down[root@VM_168_102_centos ~]# ip link show 1: lo: <LOOPBACK> mtu 16436 qdisc noqueue state DOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:e2:7b:d2 brd ff:ff:ff:ff:ff:ff [root@VM_168_102_centos ~]# ip link set dev lo up[root@VM_168_102_centos ~]# ip link show1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:e2:7b:d2 brd ff:ff:ff:ff:ff:ff
修改MTU的数值:
[root@VM_168_102_centos ~]# ip link set dev eth0 mtu 1480[root@VM_168_102_centos ~]# ip link show eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1480 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:e2:7b:d2 brd ff:ff:ff:ff:ff:ff [root@VM_168_102_centos ~]# ip link set dev eth0 mtu 1500[root@VM_168_102_centos ~]# ip link show eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:e2:7b:d2 brd ff:ff:ff:ff:ff:ff
ip addr add:添加一个新的协议地址
[root@VM_168_102_centos ~]# ip addr add dev eth0 192.168.2.6[root@VM_168_102_centos ~]# ip addr show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:e2:7b:d2 brd ff:ff:ff:ff:ff:ff inet 10.221.168.102/22 brd 10.221.171.255 scope global eth0 inet 192.168.2.6/32 scope global eth0 inet6 fe80::216:3eff:fee2:7bd2/64 scope link valid_lft forever preferred_lft forever
ip addr del:删除一个协议地址
[root@VM_168_102_centos ~]# ip addr del dev eth0 192.168.2.6Warning: Executing wildcard deletion to stay compatible with old scripts. Explicitly specify the prefix length (192.168.2.6/32) to avoid this warning. This special behaviour is likely to disappear in further releases, fix your scripts![root@VM_168_102_centos ~]# ip addr show eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:16:3e:e2:7b:d2 brd ff:ff:ff:ff:ff:ff inet 10.221.168.102/22 brd 10.221.171.255 scope global eth0 inet6 fe80::216:3eff:fee2:7bd2/64 scope link valid_lft forever preferred_lft forever
ip route add:添加新路由
ip route add DESTINATION [via NEXT_HOP] [src_SOUREC_ADDRESS]
ip route del:删除某路由
ip route del DESTINATION
ip route show:查看路由
[root@VM_168_102_centos ~]# ip route show10.221.168.0/22 dev eth0 proto kernel scope link src 10.221.168.102 169.254.0.0/16 dev eth0 scope link metric 1002 default via 10.221.168.1 dev eth0
#ping命令:它通常用来测试与目标主机的连通性
default via 10.221.168.1 dev eth0 [root@VM_168_102_centos ~]# ping www.baidu.com PING www.a.shifen.com (180.97.33.108) 56(84) bytes of data.64 bytes from 180.97.33.108: icmp_seq=1 ttl=50 time=32.6 ms64 bytes from 180.97.33.108: icmp_seq=2 ttl=50 time=32.7 ms64 bytes from 180.97.33.108: icmp_seq=3 ttl=50 time=32.7 ms64 bytes from 180.97.33.108: icmp_seq=4 ttl=50 time=32.6 ms
#netstat命令:用于显示各种网络相关信息
-a (all)显示所有选项,默认不显示LISTEN相关
-t (tcp)仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化成数字。
-l 仅列出有在 Listen (监听) 的服務状态
-p 显示建立相关链接的程序名
-r 显示路由信息,路由表
#ss:用来获取 socket统计信息
[root@VM_168_102_centos ~]# ss State Recv-Q Send-Q Local Address:Port Peer Address:Port ESTAB 0 0 10.221.168.102:ssh 60.28.41.66:59773 ESTAB 0 52 10.221.168.102:ssh 60.28.41.66:51515 ESTAB 0 0 10.221.168.102:45343 10.142.68.12:20022 ESTAB 0 0 10.221.168.102:54544 10.181.225.16:9922 ESTAB 0 0 10.221.168.102:60807 10.207.93.144:odnsp ESTAB 0 0 10.221.168.102:59371 10.142.68.11:20022
-a (all)显示所有选项,默认不显示LISTEN相关
-t (tcp)仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化成数字。
-l 仅列出有在 Listen (监听) 的服務状态
-m显示套接链接使用的内存信息
-p进程及PID
# ethtool :显示设备接口属性
#ethtool –S:显示设备接口的统计数据
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。