Linux-Network Configuration and Process Management

Keywords: Linux Windows CentOS

Network Configuration for Linux

Linux Gets Network Configuration Automatically

  1. It is easy to get the network configuration automatically, but each time you start Linux, the ip addresses may be assigned differently. All of them, getting the network configuration automatically is not suitable as a server

The first step is to configure a fixed ip address

  1. Query the network configuration of the virtual machine: vim/etc/sysconfig/network-scripts/ifcfg-eth0
  2. This is the network file for my virtual machine
EVICE=eth0
HWADDR=00:0C:29:2A:D4:D1
TYPE=Ethernet
UUID=7a31255a-e65d-4e63-988e-7736d02d22cf
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.91.1
NETMASK=255.255.255.0
GATEWAY=192.168.91.2
DNS1=192.168.91.1
  1. ONBOOT=yes, which defaults to no, is the switch on network configuration and needs to be set to yes
  2. BOOTPROTO=static.Setting static to static indicates that custom network configuration information will be used.
  3. IPADDR=192.168.91.0: This is the virtual machine network ip information that I configure myself. When I configure the network information, I will configure the virtual machine network according to this ip information, which I can configure myself
  4. GATEWAY=192.168.91.2 indicates the configured network gateway address, which is then set by itself
  5. DNS1=192.168.91.1 stands for Domain Name Resolver, which is set up by you. The information you need to configure is consistent with the gateway.

If you want the configuration to take effect after restarting the virtual machine using the reboot directive, use service network restart //restart the network service in the terminal

Step 2: Modify the host name

  1. View the current hostname: hostname
  2. Modify the host mapping file for linux: vim/etc/sysconfig/network
    Contents in the file
    NETWORKING=yes
    HOSTNAME=CentOS //This is my hostname and can be set by myself, but do not underline it with''
  3. Modify/etc/hosts to increase ip and host mapping
    192.168.91.1 CentOS
  4. Then restart the virtual machine and the configuration takes effect
  5. If you want windows to also connect to CentOS by hostname, go to C:\windows\System32\driversetc\hosts
  6. Last ping in Windows
C:\Users\asus>ping 192.168.91.1
 Now Ping 192.168.91.1 Data with 32 bytes:
From 192.168.91.1 Reply: byte=32 time<1ms TTL=64
 From 192.168.91.1 Reply: byte=32 time<1ms TTL=64
 From 192.168.91.1 Reply: byte=32 time<1ms TTL=64
 From 192.168.91.1 Reply: byte=32 time<1ms TTL=64

192.168.91.1 Of Ping statistical information:
    data packet: has been sent = 4,Received = 4,Lose = 0 (0% Lose),
Estimated time of round trip(In Milliseconds):
    minimum = 0ms,Longest = 0ms,Average = 0ms

Linux Process Management

  1. On Linux, each executed program (code) is called a process, and each process is assigned an ID number
  2. Each process corresponds to a parent process that can replicate multiple child processes
  3. Each process can exist in two ways, foreground and background.
  4. The foreground process is what users can do on their current screen
  5. Background processes are actually working, but because they are not visible on the screen
  6. Servers of a normal system exist as background processes and reside in the system until shutdown ends.

Show processes executed by the system

  1. Ps-aux: Show all processes
[ryx@CentOS desktop]$ ps -aux
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.0  19356  1560 ?        Ss   02:50   0:01 /sbin/init
root          2  0.0  0.0      0     0 ?        S    02:50   0:00 [kthreadd]
root          3  0.0  0.0      0     0 ?        S    02:50   0:00 [migration/0]
root          4  0.0  0.0      0     0 ?        S    02:50   0:00 [ksoftirqd/0]
root          5  0.0  0.0      0     0 ?        S    02:50   0:00 [stopper/0]
root          6  0.0  0.0      0     0 ?        S    02:50   0:00 [watchdog/0]
root          7  0.0  0.0      0     0 ?        S    02:50   0:00 [migration/1]
root          8  0.0  0.0      0     0 ?        S    02:50   0:00 [stopper/1]
root          9  0.0  0.0      0     0 ?        S    02:50   0:00 [ksoftirqd/1]
root         10  0.0  0.0      0     0 ?        S    02:50   0:00 [watchdog/1]
  1. Ps-aux | grep sshd //View sshd process, sshd is the server daemon
[ryx@CentOS desktop]$ ps -aux |grep sshd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root       2344  0.0  0.0  66236  1168 ?        Ss   02:51   0:00 /usr/sbin/sshd
[ryx@CentOS desktop]$ 0  0.0 103332   856 pts/0    S+   21:53   0:00 grep sshd
[ryx@CentO
  1. Ps-aux | grep xxx: Check to see if the virtual machine has XXX services

Instruction Description

  1. System V: Show Style
  2. USER:User name
  3. PID: Process number
  4. %CPU: Percentage of process CPU occupied
  5. %MEM: Percentage of physical memory used by processes
  6. VSZ: The size of virtual memory occupied by the process (in KB)
  7. RSS: Size of physical memory occupied by the process (in KB)
  8. TTY: Terminal name, abbreviation
  9. STAT: Process state,
    1. Common process states
    2. S: indicates that the process is asleep,
    3. s-Indicates that the process is the leader of the session
    4. N-Indicates that the process has a lower priority than normal
    5. R-Running
    6. D-Short Wait
    7. Z-Dead Process
    8. T-Tracked or Stopped, etc.
  10. STARTED: Start time of process
  11. TIME: CPU time, which is the total time a process uses the CPU
  12. COMMAND: Commands and parameters used to start a process that will be truncated if they are too long

Terminate processes kill and kill all

  1. Terminating a process Description: If a process needs to be stopped in half or has consumed a lot of system resources, you can test to stop the process and use the kill command to complete the task of stopping the process.
  2. Kill and kill all syntax:
    1. Kill [option] process number (function description: kill process-9 by process number means forced termination)
    2. Killall process name (meaning: killing a process by its name, wildcards are also supported, and killall is useful to end a process system because of heavy load)
  3. Common options: -9 means the forced process stops immediately

Posted by serbestgezer on Sat, 02 Oct 2021 12:41:12 -0700