关机、重启:
立即关机:halt、poweroff、shutdown -h now
延迟关机:shutdown -h 10 十分钟后关机
立即重启:reboot、shutdown -r now
延迟重启:shutdown -r 10 十分钟后重启、shutdown -r 20:35 定点重启
取消:shutdown -c
Ubuntu14 版本查询
xzx@git:~$ lsb_release -a LSB是Linux Standard Base的缩写,lsb_release命令用来显示LSB和特定版本的相关信息
No LSB modules are available.
Distributor ID: Ubuntu 类别是ubuntu
Description: Ubuntu 14.04. LTS 16年3月发布的稳定版本,LTS是Long Term Support:长时间支持版本,支持周期长达三至五年
Release: 14.04 发行版本号
Codename: trusty ubuntu的代号名称
xzx@git:~$ uname -a 查看系统相关信息
Linux 内核名称
git 主机名
4.4.--generic 内核发行号
#~14.04.-Ubuntu SMP Sat Jan :: UTC 内核版本号
x86_64 机器硬件名称,即操作系统位数
x86_64 处理器类型
x86_64 硬件平台
GNU/Linux 操作系统
xzx@git:~$ cat /proc/version
Linux version 4.4.--generic (buildd@lcy01-amd64-) linux内核版本号
(gcc version 4.8. (Ubuntu 4.8.-2ubuntu1~14.04.) ) gcc编译器版本号、Ubuntu版本号
#~14.04.-Ubuntu SMP Sat Jan :: UTC 2019 内核版本号
系统时间查看修改
xzx@test:/test$ date -R
Mon, Dec :: -
xzx@test:/test$ tzselect
) Asia
) China
) Beijing Time
) Yes
xzx@test:/test$ sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
xzx@test:/test$ date -R
Tue, Dec :: +
Ubuntu14 重启
执行service networking restart 报错!(需要root权限才可以正常运行) xzx@git:~$ service networking restart
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.14" (uid=1000 pid=1576 comm="stop networking ") interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init ")
切换到root用户下,执行service networking restart,依然报错!
Ubuntu14版已经不支持使用service对网络进行停止重启。
xzx@git:~$ su root
Password:
root@git:/home/xzx# service networking restart
stop: Job failed while stopping
start: Job is already running: networking
正确的使用方法:ifdown eth0 && ifup eth0
root@git:/home/xzx# ifdown eth0 && ifup eth0
Internet Systems Consortium DHCP Client 4.2.
Copyright - Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/eth0/:::ef::ec
Sending on LPF/eth0/:::ef::ec
Sending on Socket/fallback
DHCPRELEASE on eth0 to 10.20.6.254 port (xid=0x1e6a46a7)
Internet Systems Consortium DHCP Client 4.2.
Copyright - Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/eth0/:::ef::ec
Sending on LPF/eth0/:::ef::ec
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port interval (xid=0x828e5509)
DHCPDISCOVER on eth0 to 255.255.255.255 port interval (xid=0x828e5509)
DHCPREQUEST of 10.20.6.185 on eth0 to 255.255.255.255 port (xid=0x9558e82)
DHCPOFFER of 10.20.6.185 from 10.20.6.254
DHCPACK of 10.20.6.185 from 10.20.6.254
bound to 10.20.6.185 -- renewal in seconds.
需要root权限。
查看防火墙当前状态
ufw status 开启防火墙
ufw enable 关闭防火墙
ufw disable 拒绝外部访问53端口
ufw deny 允许某个IP地址访问本机所有端口
ufw allow from 192.168.0.1
修改网卡IP
vim /etc/network/interfaces
auto eth0
iface eth0 inet static
address 10.20.1.125
netmask 255.255.255.0
gateway 10.20.1.254
dns-nameservers 202.96.134.133