Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Kernel parameters, top commands, script exercises, introduction to initrd

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Kernel parameters, top commands, script exercises, and introduction to initrd list common kernel parameters and their significance (1) net.ipv4.ip_forward: the routing and forwarding switch of the packet. Set to 1 means to turn on, 0 means to turn off (2) net.ipv4.conf.default.rp_filter checks the reverse path of packets coming in from the default network card. Set to 1 means enabled. 0: disable (3) whether net.ipv4.conf.default.accept_source_route accepts ip packets containing source routing information. Set to 1: enable. 0: disable (4) net.ipv4.icmp_echo_ignore_all: ignore all external ping requests, but do not affect your external ping operations. A setting of 1 means to disable the ICMP response feature, and a setting of 0 means to enable the ICMP response feature. (5) kernel.hostname: kernel parameter of the hostname (6) net.ipv4.tcp_max_tw_buckets: sets the maximum number of timewait for TCP. The default is 180000 (7) net.ipv4.ip_local_port_range: the range of ports that the system is allowed to open, with two numbers separated by spaces, representing the lowest port number and the largest port number, respectively. (8) net.ipv4.tcp_tw_recycle: enable timewait fast recycling. A setting of 1 means the feature is enabled.

Add:

(1) all the above parameters are under each corresponding directory of / proc/sys/#/*:

For example: net.ipv4.ip_forward = / proc/sys/net/ipv4/ip_forward

(2) modify the value of the parameter, use the special command sysctl, or you can use echo redirection.

For example: ~] # echo "test.localhost" > / proc/sys/kernel/hostname ~] # sysctl-w net.ipv4.ip_forward=1

Note: the above modification methods are only valid for the current. If you want to be permanently valid, you need to modify the configuration file:

How to use / etc/sysctl.conf or / etc/sysctl.d/*.conf to take effect immediately: sysctl-p / PATH/TO/CONFIG.FILE check the process status shown in top through / proc

Top command parameters and meaning: parameter name corresponds to / proc path description PID column / proc directory under the digital directory process ID The PID number of each process is used as the directory name USER / the user of the first column of the numeric process beginning with Uid in the / proc/PID/status file PR in the / proc/PID/stat file the scheduling priority of the numeric task in the 18th column NI in the / proc/PID/stat file represents the task's NICE value VIRT in the / proc/PID/statm file column 1 numeric (in page) virtual memory size (KiB) The total amount of virtual memory used by the task. It includes all code, data and shared libraries, as well as swapped pages and mapped but unused pages RES in the / proc/PID/statm file, the second column value (in pages) represents the resident memory size (KiB), and the non-swapping physical memory SHR being used by the task represents the shared memory size (KiB) in the / proc/PID/statm file. Memory S that may be shared with other processes this line shows the process status as the State%CPUCPU utilization in the / proc/PID/status file, the percentage of CPU time elapsed to total CPU time since the last screen refresh. (calculated) the share of available physical memory currently used by the% MEM memory usage (RES) task. (obtained by calculating the ratio of RES to total memory) TIME+ is reflected in the / proc/PID/stat file as the sum of two times: column 14, the time the task runs in user mode, and column 15, the time the task runs in the kernel mindset. The total CPU time used by the task since its startup shows the line name that begins with Name in the COMMAND/proc/#/status file with an accuracy of 1% seconds.

3. Use while and for loops to detect the surviving IP addresses of the 10.0.0.1 Universe 24 network segment:

(1) for:

#! / bin/bash#declare-I uphosts=0declare-I downhosts=0for I in {1.. 254}; do if ping-W 1-c 1 10.0.0.$ {I}% > / dev/null; then echo "10.0.0.Secreti is ip." Let uphosts+=1 else echo "10.0.0.Secreti is down." Let downhosts+=1 fidoneecho "Up hosts: $uphosts, Down hosts: $downhosts."

(2) while

#! / bin/bashdeclare-I uphosts=0declare-I downhosts=0declare-I i=1hostping () {if ping-W 1-c 1 $1 & > / dev/null;then echo "$1 is up." Return 0 else echo "$1 is down." Return 1 fi} while [$I-le 254]; do hostping 10.0.0.Secreti [$?-eq 0] & & let uphosts++ | | let downhosts++ let i++doneecho "Up hosts:$ uphosts, Down hosts:$downhosts"

4. Explain the role of initrd:

Initrd is an acronym for boot loader initialized RAM disk and represents a memory disk initialized by boot loader. Before the linux kernel starts, boot loader loads initrd files from disks and other storage media into memory. When the kernel starts, it accesses the initrd file system in that memory before accessing the real root file system. The startup process is divided into two processes. The first process is to execute the initialization file in the in-memory initrd file system (/ linuxrc file in the Linux2.4 kernel, which is generated by the file system image; in the Linux2.6 kernel, the / init file is generated using the cpio tool), which is responsible for loading the kernel driver module that accesses the root file system storage medium, and loading the root file system. The second process is to execute the / sbin/init process in the real root file system, the main role of initrd: 1. When the kernel starts, load initrd img and mount the root / 2. Execute with the instruction of / linuxrc, generally scan the system hardware and find the driver installation from the current file system. 3. The real root / in the mount system

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report