Linux重啓命令 / 查看、重啓、禁用網卡命令 / 修改IP / 操作防火牆命令

重啓命令

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

看下哪張網卡的流量變化大一般就是哪張網卡是在線使用的

重啓網卡方法

(1)全部重啓

重啓網卡使設定生效:sudo /etc/init.d/networking restart

(2)單個網卡重啓

關閉網卡 ifdown eth0

開啓網卡 ifup eth0

禁用網卡

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

onboot=NO

修改IP

查看網卡信息: ifconfig

(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 

(3)其它

用ubuntu的系統——>系統管理——>網絡的網絡設置

操作防火牆(service方式)

查看防火牆狀態: service iptables status

開啓防火牆:service iptables start

關閉防火牆:service iptables stop

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章