linux常用管理命令

申请到 三 丰 云 免 费 云 主 机 安装了CentOS操作系统,记录一下相关系统管理操作命令

重启命令

1、reboot

2、shutdown -r now 立刻重启(root用户使用)

3、shutdown -r 10 过10分钟自动重启(root用户使用)

4、shutdown -r 20:35 在时间为20:35时候重启(root用户使用)

通过shutdown命令设置重启,可以用shutdown -c命令取消重启

关机命令

1、halt 立刻关机

2、poweroff 立刻关机

3、shutdown -h now 立刻关机(root用户使用)

4、shutdown -h 10 10分钟后自动关机

通过shutdown命令设置关机,可以用shutdown -c命令取消重启

查看当前使用的网卡

watch cat /proc/net/dev

看下哪张网卡的流量变化大一般就是哪张网卡是在线使用的

新手必学!Linux重启+网卡管理+修改IP+防火墙管理

重启网卡方法

1、全部网卡重启

重启网卡使设定生效:sudo /etc/init.d/networking restart

2、单个网卡重启

关闭网卡 ifdown eth0

开启网卡 ifup eth0

禁用网卡

vi /etc/sysconfig/network-scripts/ifcfg-eth1

onboot=NO

修改IP

查看网卡信息: ifconfig

Linux重启+网卡管理+修改IP+防火墙管理

1、动态

设定一个网卡IP:ifconfig eth1 192.168.1.10 netmask 255.255.255.0

重启网卡使设定生效:sudo /etc/init.d/networking restart

2、静态

编辑文件 /etc/network/interfaces

sudo vi /etc/network/interfaces
并用下面的行来替换有关eth0的行:

The primary network interface

auto eth0
iface eth0 inet static
address 192.168.2.1
gateway 192.168.2.254
netmask 255.255.255.0
#network 192.168.2.0
#broadcast 192.168.2.255
将eth0的IP分配方式修改为静态分配(static)后,为其制定IP、网关、子网掩码等信息。

将上面的Ubuntu IP地址等信息换成你自己就可以了。

用下面的命令使网络设置生效:

sudo /etc/init.d/networking restart

操作防火墙(service方式)

查看防火墙状态: service iptables status

开启防火墙:service iptables start

关闭防火墙:service iptables stop

猜你喜欢

转载自blog.51cto.com/7704223/2397125