Two instructions on the network:
ifconfig: configure and display the network parameters of the network card of the Linux system
pingDestination host: test the network connectivity between hosts
Detect host connections
When the ping command is executed, the ICMP transmission protocol will be used to send the message requesting response. If the network function of the remote host is OK, the message will be returned, so it is known that the host is operating normally.
The following explains how to modify the configuration file, specify the IP, and connect to the public network
- Modify profile
The ifcfg-ens33 file under / etc / sysconfig / network scripts / is modified here (different network cards correspond to different files, and the format is
ifcfg-+Network card name,)
The specific configuration depends on the individual,
BOOTPROTO="static" # Whether to use static address and "DHCP" for dynamic address ###############If it is DHCP, you don't need to write the following################### IPADDR=xxx. xxx. xxx. xxx # IP address GATEWAY=xxx. xxx. xxx. XXX # gateway DNS1=xx. xxx. xxx. xxx # Domain name system
- service network restart
service network restartRestart the network service or use the command
Set host name and hosts mapping
Host name: modifying
/etc/hostname, this is a file as long as the host name is changed to what you want, save and exit.
Note: restart is required to take effect.
/etc/hosts, the format is: IP host, such as
DNS query process
Browser cache — > DNS cache — > hosts — > DNS
Windows display and clean DNS
ipconfig /flushdns#Clean up
Monitor network status
netstatIs an instruction used to monitor network status. Commonly used options are:
-an: output in a certain order
-p: displays which process is called.
netstat -anpThis command.
Processes can be divided into foreground and background. Use PS command to view processes in Linux.
PS view process command- A display all processes of the current terminal- U display in user format- X displays the running parameters of the background process.
ps -auxCommand whose output format:
|Process owner||Process ID||CPU usage||Occupied memory usage||Size of virtual memory occupied||Occupied memory size||Secondary device number of the terminal||Process status (s: sleep R: running Z: Dead T: tracked / stopped)||Time to start the process||CPU time consumed by the process||Name and parameters of the command|
View parent process
ps -ef(- e shows all processes, – f full format)
The PID in the result refers to the ID of the process; PPID refers to the ID of the parent process
View process tree
pstreeView process tree
-pDisplay process ID
-uDisplays the user to which the process belongs
Kill process number, such as:
-9: means to force the process to stop immediately
Kill process nameYou can kill multiple processes and support wildcards. For example:
A service itself is a process. It usually runs in the background, listens to a port and waits for requests from other programs. Therefore, it can also be called a daemon.
The service instruction is a tool for controlling system services.
Service service name [start | stop | restart | reload | status], such as
service network status
Note: services after CentOS 7 are generally provided by
serviceContinue to manage services in
/etc/init.d/You can see below
Set service startup
See what self starting services are available
setupCommand, and then select system services. Where, * indicates self start
Boot process: boot – > BIOS – > boot – > SYSTEMd process 1 – > run level – > run corresponding services
setupIt has the function of setting self startup. Linux also has a command to configure whether a service is self started according to the system operation level.
In order to manage self starting services at different operating levels, red hat developed
chkconfigCommand, which is used to check or set various services of the system.
Set up service:
Chkconfig -- level service level service name on / off
chkconfig --level 5 network on, which means that the network service is opened at the 5 running level
- Like the service, after CentOS 7, the system CTL is used for management, and chkconfig continues to manage the service
/etc/init.d/You can see below
- After setting, you need to restart before it takes effect.
The systemctl command is a system service manager instruction that actually combines the service and chkconfig commands.
Systemctl can manage services in
- query state
Systemctl status service name, such as:
systemctl status firewalld
- Shut down service
Systemctl stop service name, such as:
systemctl stop firewalld
- Open service
Systemctl start service name, such as:
systemctl start firewalld
Note: starting or closing the service is only temporary. To save it, you need to set the startup status (enable / disable), as shown below
Self start Management (levels 3 and 5)
- View service startup status
systemctl list-unit-files, to query a specific service, use
- Set startup
Systemctl enable / disable service name
- Query whether the service is started
Systemctl is enabled service name
Firewall firewall management
Firewall CMD -- Query port = port / protocol
Firewall CMD -- permanent -- add port = port / protocol
Firewall CMD -- permanent -- remove port = port / protocol
Note: after opening or closing the port, it needs to be reloaded to take effect:
Dynamic monitoring process
The top command is similar to the PS command, except that the top command is updated every other period of time and is dynamic.
-D seconds: update every few seconds, 3 seconds by default
-i: do not show restricted / dead processes
-p: process ID monitors the status of a process
Press the key after entering top
P is sorted by CPU. This is the default
M sort in memory
N sorted by PID
K to end a process, enter the process number and semaphore (the semaphore for forced exit is 9)
Q exit top