ifconfig命令:查看及临时修改网卡配置信息
查看的用法:ifconfig [-v] [-a] [-s] [INTERFACE]
OPTIONS
-v:详细显示接口报错信息
-a:显示所有接口信息,包括处于down状态
-s:简单显示接口状态信息
注:ifconfig不带-a参数默认只显示所有up状态的接口
临时更改网卡配置的用法:ifconfig [-v] INTERFACE [aftype] OPTIONS | ADDRESS …
OPTIONS
up:将接口状态置为up状态
down:将接口状态置为down状态
mtu N:将接口mtu值改为N(数值,0-65536)
netmask x.x.x.x:将接口ip地址改为x.x.x.x
hw ether x.x.x.x.x.x:将接口硬件地址改为x.x.x.x.x.x.x,hw后必须跟上接口类型,目前支持修改的类型为ether、ax25、ARCnet、netrom
ADDRESS
x.x.x.x:将接口ip地址改为x.x.x.x
注:ifconfig对网卡所做的所有更改都是临时的,重启网卡所有更改消失。
实例1:ifconfig查看时-a和-s参数
~]# ifconfig -s
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eno16777 1500 7370 0 0 0 4731 0 0 0 BMRU
lo 1500 0 0 0 0 0 0 0 0 LRU
~]#
~]# ifconfig lo down
~]#
~]# ifconfig -s
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eno16777 1500 7426 0 0 0 4778 0 0 0 BMRU
~]#
~]# ifconfig -s -a
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eno16777 1500 7448 0 0 0 4796 0 0 0 BMRU
lo 1500 0 0 0 0 0 0 0 0 L
~]#
~]# ifconfig -sa
ifconfig: option `-sa' not recognised.
ifconfig: `–help' gives usage information.
实例2:网卡更改IP地址、子网掩码、MTU值和硬件地址
~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.110.128 netmask 255.255.255.0 broadcast 192.168.110.255
inet6 fe80::20c:29ff:feb2:ed9b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:b2:ed:9b txqueuelen 1000 (Ethernet)
RX packets 6810 bytes 617290 (602.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4317 bytes 621776 (607.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.255.255.255
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
~]# ifconfig lo 1.1.1.1 netmask 255.255.255.0 mtu 1500
~]#
~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.110.128 netmask 255.255.255.0 broadcast 192.168.110.255
inet6 fe80::20c:29ff:feb2:ed9b prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:b2:ed:9b txqueuelen 1000 (Ethernet)
RX packets 7044 bytes 638635 (623.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4482 bytes 641804 (626.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 1500
inet 1.1.1.1 netmask 255.255.255.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
~]# ifconfig eno16777736 hw ether 00:00:00:00:00:01
~]#
~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.110.128 netmask 255.255.255.0 broadcast 192.168.110.255
inet6 fe80::20c:29ff:feb2:ed9b prefixlen 64 scopeid 0x20<link>
ether 00:00:00:00:00:01 txqueuelen 1000 (Ethernet)
RX packets 7154 bytes 648409 (633.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4549 bytes 649746 (634.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 1500
inet 1.1.1.1 netmask 255.255.255.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
日期相关命令:
时钟分类:Linux系统启动时从硬件读取日期和时间信息;读取完成以后,就不再与硬件相关联;
系统时钟:操作系统自己计时的时钟
硬件时钟:计算机硬件自己计时的时钟
1) date命令:显示或设置系统时钟的时间
显示用法:date [OPTION]… [+FORMAT]
FORMAT
%F:显示年月日
%T:显示时分秒
%Y:显示年
%m:显示月
%d:显示日
%H:显示时
%M:显示分
%S:显示秒
%s: 从1970年1月1号(unix元年)0点0分0秒到命令执行那一刻经过的秒数;
设置用法:date [MMDDhhmm[[CC]YY][.ss]]
2) hwclock, clock::显示或设置硬件时钟
用法:hwclock [function]
function
-s, –hctosys:以硬件为准,把系统调整为与硬件时间相同;
-w, –systohc:以系统为准,把硬件时间调整为与系统时钟相同;
实例:
~]# date +%F~%T
2016-09-07~04:54:04
~]#
~]# date +%Y~%m~%d/%H:%M:%S
2016~09~07/04:54:44
~]#
~]# date 111111112011.11
Fri Nov 11 11:11:11 EST 2011
~]#
~]# date
Fri Nov 11 11:11:15 EST 2011
~]#
~]# clock
Wed 07 Sep 2016 04:56:18 AM EDT -0.209054 seconds
~]#
~]# hwclock –systohc
~]#
~]# clock
Fri 11 Nov 2011 11:12:19 AM EST -0.833851 seconds
cal命令:查看日历
用法:cal [[month] year]
实例:
~]# cal 12 2012
December 2012
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
poweroff命令:关机
用法:poweroff
halt命令:关机
用法:halt
reboot命令:重启
用法:reboot
原创文章,作者:Yurnero,如若转载,请注明出处:http://www.178linux.com/44983