[Fun with Linux common basic commands]

Modifying the IP address and gateway is a very common operation. When doing related experiments, if it is not set well, it will bring a lot of unnecessary troubles..

1. Check the IP address : ifconfig, modify the IP to take effect temporarily, no need to restart, restart fails: ifcfg eth0 1.1.1X

 

2. Modify the IP address
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
BROADCAST=192.168.1.255
IPADDR=192.168.1.33
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
USERCTL=no
PEERDNS=no
TYPE=Ethernet
If there are 2 network cards, the relevant information of the second one is stored in the ifcfg-eth1 file.
vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.2.34
NETMASK=255.255.255.0
USERCTL=no
PEERDNS=no
TYPE=Ethernet
NETWORK=192.168.2.0
BROADCAST=192.168. 2.255

3. Modify gateway
vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=Aaron
GATEWAY=192.168.1.1

4. Restart the network configuration: After modifying the IP and gateway, the network service must be restarted to take effect.
/etc/init.d/network restart

 

5. View the host name hastname -a

 

6. Modify the host name (temporary effect, restart invalid)

hostname new hostname

 

7. Modify the host name through the configuration file /etc/sysconfig/network .

# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=localhost.localdomai

 

8. View memory free -m

9. View the hard disk df -h

 

10. Other commands

View process ps

directory switch cd

file move/rename mv

delete file rm

empty file echo > file

file copy

Create file touch

View system time date hwclock

file authorization chmod

Modify file attribute group chown

View text content: cat , more , tail , head

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326683874&siteId=291194637