Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

2.4 System status detection command


May 23, 2021 That's what Linux should learn



As a qualified operations personnel, to get a better understanding of Linux servers faster and better, you must have the ability to quickly see how the Linux system is running, so the next step is to explain how to use commands related to the network card network, the system core, system load, memory usage, the number of currently enabled terminals, historical login records, command execution records, and rescue diagnostics. These commands are super practical, and readers are invited to study hard and master them.

1. Ifconfig command

The ifconfig command is used to obtain information such as network card configuration and network status in the format "ifconfig (network devices) ( parameters) " .

When using the ifconfig command to view the current network card configuration and network status of the machine and other information, in fact, the main view is the network card name, inet parameters after the IP address, ether parameters after the network card physical address (also known as MAC address), as well as RX, TX receiving packets and sending packets and cumulative traffic (i.e., the following bold information content):

[root@linuxprobe ~]# ifconfig

  1. eno16777728: flags=4163 mtu 1500
  2. inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255
  3. inet6 fe80::20c:29ff:fec4:a409 prefixlen 64 scopeid 0x20
  4. ether 00:0c:29:c4:a4:09 txqueuelen 1000 (Ethernet)
  5. RX packets 36 bytes 3176 (3.1 KiB)
  6. RX errors 0 dropped 0 overruns 0 frame 0
  7. TX packets 38 bytes 4757 (4.6 KiB)
  8. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  9. lo: flags=73 mtu 65536

  1. inet 127.0.0.1 netmask 255.0.0.0
  2. inet6 ::1 prefixlen 128 scopeid 0x10
  3. loop txqueuelen 0 (Local Loopback)
  4. RX packets 386 bytes 32780 (32.0 KiB)
  5. RX errors 0 dropped 0 overruns 0 frame 0
  6. TX packets 386 bytes 32780 (32.0 KiB)
  7. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

2. uname command

The uname command is used to view information such as the system kernel and system version in the format "uname . . . .

When using the unome command, the on-a parameter is typically fixed to provide a complete view of the kernel name, host name, kernel release version, node name, system time, hardware name, hardware platform, processor type, and operating system name of the current system.

[root@linuxprobe ~]# uname -a

Linux linuxprobe.com 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

By the way, if you want to see the details of the current system version, you need to look at the redhat-release file, whose commands and the corresponding results are as follows:

[root@linuxprobe ~]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 7.0 (Maipo)

3. Uptime command

Uptime is used to view the load information of the system in the form of uptime.

The uptime command is really great, it shows information such as the current system time, the time the system is running, the number of terminals enabled, and the average load value. The average load value refers to the pressure condition of the system in the last 1 minute, 5 minutes, 15 minutes (bold information section below);

[root@linuxprobe ~]# uptime

22:49:55 up 10 min, 2 users, load average: 0.01, 0.19, 0.18

4. Free command

Free is used to display information about the amount of memory used in the current system in the format of "free s-h".

To ensure that Linux systems do not suddenly go down due to resource depletion, operations personnel need to keep an eye on memory usage. W hen using the free command, you can use the -h parameter in conjunction with to output real-time usage information for the current memory in a more user-friendly manner. T able 2-8 shows the output information after executing the free-h command on Mr. Liu's computer. It is important to note that the input comments Chinese the output information are self-added by the author and are not interpreted with the appropriate parameters when the actual output is output.

[root@linuxprobe ~]# free -h

Table 2-8 output information after executing the free -h command

Edit Total Amount of Memory Used Amount Available Amount of Memory The amount of memory shared by the process The amount of memory cached by the disk amount of memory

total used free shared buffers cached

Mem: 1.8G 1.3G 542M 9.8M 1.6M 413M

-/+ buffers/cache: 869M 957M

Swap: 2.0G 0B 2.0G

5. Who command

Who is used to view the user terminal information for the currently lying host, in the format "who "parameters".

These three simple letters quickly show the names of all the users who are logging on to the machine and the terminal information they are opening. Table 2-9 shows the results of executing the who command.

[root@linuxprobe ~]# who

Table 2-9 The result of executing the who command

Edit the time when the username of the log-in terminal device logs on to the system

root :0 2017-08-24 17:52 (:0)

root pts/0 2017-08-24 17:52 (:0)

6. Last command

The last command is used to view login records for all systems in the format "last parameter".

Use the last command to view your country's login history. H owever, because this information is stored in a log file in the system, it is easy for hackers to tamper with the content. Don't judge the system by the output information of this command alone!

[root@linuxprobe ~]# last root pts/0 :0 Mon Aug 24 17:52 still logged in

root :0 :0 Mon Aug 24 17:52 still logged in

(unknown :0 :0 Mon Aug 24 17:50 - 17:52 (00:02)

reboot system boot 3.10.0-123.el7.x Tue Aug 25 01:49 - 18:17 (-7:-32)

root pts/0 :0 Mon Aug 24 15:40 - 08:54 (7+17:14)

root pts/0 :0 Fri Jul 10 10:49 - 15:37 (45+04:47)

.................. Omit some login information...

7. The history command

The history command is used to display commands that have been executed in the form of "history .-c".

The history command should be the author's favorite command. E xecuting ahistory command shows the last 1000 command records that the current user has executed on the local computer. I f you don't think 1000 is enough, you can also customize the HISTSIZE variable value in the /etc/profile file. W hen using thehistory command, if you use the -c parameter, all command history is emptied. Y ou can also use the "! encode the number" method to repeat a command. In short, the history command has a lot of interesting playplay to develop.

[root@linuxprobe ~]# history

1 tar xzvf VMwareTools-9.9.0-2304977.tar.gz

2 cd vmware-tools-distrib/

3 ls

4 ./vmware-install.pl -d

5 reboot

6 df -h

7 cd /run/media/

8 ls

9 cd root/

10 ls

11 cd VMware\ Tools/

12 ls

13 cp VMwareTools-9.9.0-2304977.tar.gz /home

14 cd /home

15 ls

16 tar xzvf VMwareTools-9.9.0-2304977.tar.gz

17 cd vmware-tools-distrib/

18 ls

19 ./vmware-install.pl -d

20 reboot

21 history

[root@linuxprobe ~]# !15

anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures Templates

Desktop Downloads Music Public Videos

The history command is saved to a file in the user'.bash_history directory. Files that start with a point (.) in a Linux system represent hidden files, most of which are system service files that can be viewed using the cat command.

[root@linuxprobe ~]# cat ~/.bash_history

To empty the Linux command history information that the current user is performing on this machine, you can perform the following command:

[root@linuxprobe ~]# history -c

8. Sosreport command

The sosreport command is used to collect system configuration and schema information and output diagnostic documents in sosreport format.

When a Linux system failure requires contacting technical support, this command is used most of the time to simply collect information about the system's operational status and service configuration so that technical support personnel can resolve minor issues remotely or to keep them relevant to some complex issues in advance. In the following output information, the bold part is the collected data compression file and check code, which can be sent to the technical support staff:

[root@linuxprobe ~]# sosreport sosreport (version 3.0) This command will collect diagnostic and configuration information from this Red Hat Enterprise Linux system and installed applications.

An archive containing the collected information will be generated in /var/tmp and may be provided to a Red Hat support representative. Any information provided to Red Hat will be treated in accordance with the published support policies at:

https://access.redhat.com/support/

The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party.

No changes will be made to system configuration. P ress ENTER to continue, or CTRL-C to quit. Click back here to confirm the collection of information

Please enter your first initial and last name (linuxprobe.com): Tap back here to confirm the host number Please enter the case number that you are generating this report for: here tap the carriageback to confirm the host number Running plugins. P lease wait ... R unning 70/70: yum... C reating compressed archive... Your sosreport has been generated and saved in:

/var/tmp/sosreport-linuxprobe.com-20170905230631.tar.xz The checksum is: 79436cdf791327040efde48c452c6322 Please send this file to your support representative.