-
linux vi save instruction
Press ESC to jump to command mode, then:
-
:w save file without exiting vi
:w file additionally save changes to file without exiting vi
:w! force save without exiting vi
:wq save file and exit vi
:wq! force save file and exit vi
q: Do not save the file, exit vi
:q! Do not save the file, force quit vi
:e! Abandon all changes, start editing from the last time the file was savedUse the root user to log in to linux and open the terminal
-
In terminal enter: vi /etc/sysconfig/network-scripts/ifcfg-eth0
-
After returning,
Start editing, fill in the ip address, subnet mask, gateway, DNS, etc.
ONBOOT=yes Boot automaticallyBOOTPROTO=static static ipDNS1=192.168.1.1 dnsIPADDR=192.168.3.235 ip address
NETMASK=255.255.255.0 subnet maskGATEWAY=192.168..3.1 gateway
-
After editing, save and exit Note: How to exit and save: Press esc ->Shift+: ->wq
restart network service
service network restart或/etc/init.d/network restart
Then ping the gateway and ping the external network for testing. All pings indicate that the network is normal
-
Detailed summary:
---Modify ip address---
Immediately effective:
# ifconfig eth0 192.168.1.155 netmask 255.255.255.0
Restart to take effect:
修改vi /etc/sysconfig/network-scripts/ifcfg-eth0
---Modify default gateway---
Immediately effective:
# route add default gw 192.168.1.1
Restart to take effect:
修改vi /etc/sysconfig/network-scripts/ifcfg-eth0
---Modify dns---
Modify vi /etc/resolv.conf
The modification takes effect immediately, and restart is also effective
---Modify host name---
Immediately effective:
# hostname test1
Restart to take effect:
Modify vi /etc/sysconfig/network