Server details in linux

Linux Administration

Here i am showing some basic commands using them you can gather the system/server information.

To check what version of Operating System is installed on the server you can use the following commands:-
=================================================================
1.cat /etc/issue
[root@localhost ~]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Kernel \r on an \m

2.cat /etc/redhat-release
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.5 (Tikanga)

3.lsb_release -a
[root@localhost ~]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Release: 5.5
Codename: Tikanga

To check whether the operating system is 32 or 64bit:-
================================
# uname -i
[root@localhost ~]# uname -i
i386
(i386 represents that server is having 32bit operating system)

[root@localhost ~]# uname -i
x86_64
(x86_64 represents that server is having 64bit operating system)

To see the processor/CPU information:-
=============================
# cat /proc/cpuinfo
[root@localhost ~] cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
stepping : 6
cpu MHz : 1995.087
cache size : 4096 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx tm2 ssse3 cx16 xtpr lahf_lm
bogomips : 3990.17
(Here processor number 0 indicates that the system is having one process(processor number starts with zero))

To check memory information:-
===========================
# free -m
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 5066 3513 1552 0 612 2319
-/+ buffers/cache: 582 4484
Swap: 1983 0 1983

# cat /proc/meminfo
[root@localhost ~]# cat /proc/meminfo
MemTotal: 5187752 kB
MemFree: 1639300 kB
Buffers: 627024 kB
Cached: 2374944 kB
SwapCached: 0 kB
Active: 2458788 kB
Inactive: 920964 kB
HighTotal: 4325164 kB
HighFree: 1561936 kB
LowTotal: 862588 kB
LowFree: 77364 kB
SwapTotal: 2031608 kB
SwapFree: 2031608 kB
Dirty: 704 kB
Writeback: 0 kB
AnonPages: 377892 kB
Mapped: 35328 kB
Slab: 153036 kB
PageTables: 6316 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
CommitLimit: 4625484 kB
Committed_AS: 977132 kB
VmallocTotal: 116728 kB
VmallocUsed: 4492 kB
VmallocChunk: 112124 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
Hugepagesize: 2048 kB

To check the model and serial name of the server:-
=======================================
[root@localhost ~]# dmidecode | egrep -i «product name|Serial number»
Product Name: PowerEdge R710
Serial Number: AB8CDE1

To check the host name:-
=====================
[root@localhost ~]# uname -n
localhost

[root@localhost ~]# hostname
localhost

To check the kernel version:-
========================
[root@localhost ~]# uname -r
2.6.18-238.9.1.el5PAE

Читайте также:  Выключение linux через ssh

Источник

Checking Linux Server Details with Shell Commands

The device tree is used by various architectures, including RISC-V, to describe hardware. Additionally, there are several «small» tools available for gathering hardware information such as lspci for PCI hardware and lsusb for USB hardware. Depending on the distribution, users may have access to one of two tools for obtaining a comprehensive overview of their hardware configuration.

Getting information on a machine’s hardware in Linux

If your system has the procfs feature, it provides abundant information about your system’s operation. This interface is linked to the kernels data structures and includes data on your hardware. To obtain specific information on the CPU in use, execute cat /proc/cpuinfo . To learn more, consult the proc manual page using the command «man proc».

By accessing the kernel ring buffer log messages using dmesg , you can gather additional details about the hardware. This includes a brief overview of newly connected hardware and its integration within the system.

On every distribution, you will find a set of fundamental «interfaces» that allow you to gather information about your hardware.

Additional tools for collecting hardware information are those considered «small.

You might have access to one of the two tools to collect a comprehensive summary of your hardware configuration, based on the distribution you are using.

  • lshw
  • This tool called hwinfo is available not only under SuSE but also other distributions.

To gain access to your hardware, you must use the Desktop Management Interface (DMI), which is utilized by software such as lshw. The DMI framework reveals your system’s details and can be accessed directly via dmidecode — a tool that is present in most distributions as a package. The package also includes biosdecode , which displays all available BIOS information.

To present a comprehensive view of my hardware, I utilize lshw -short , which is most effective when operated as a root user. Although it is possible to execute lshw in its basic form, I personally favor the succinctness provided by the -short alternative.

For monitoring my HDD usage, I rely on the readily available df —human-readable rather than lshw .

Additionally, consider inspecting the hardware when using Linux.

To obtain system hardware information on Debian and its derivatives, one can utilize ‘lshw’ by running ‘sudo apt-get install lshw’. Additionally, a graphical interface for ‘lshw’ known as ‘lshw-gtk’ is also available.

Linux List Processes – How to Check Running Processes, How to List Running Processes in Linux using the ps Command · ps : is the process status command. · a : displays information about other users’

How to check Linux System Info

LINUX SYSTEM INFO COMMANDSid =Current usernamew = Logged on userswho/who -a
Duration: 2:19

Get the hardware model name in linux

Upon examining the source code of Neofetch, the ambiguity was resolved upon reaching Line 1174 in version 7.0.0, where a conditional statement was present.

if [[ -d /system/app/ && -d /system/priv-app ]]; then model="$(getprop ro.product.brand) $(getprop ro.product.model)" elif [[ -f /sys/devices/virtual/dmi/id/product_name || -f /sys/devices/virtual/dmi/id/product_version ]]; then model=$(< /sys/devices/virtual/dmi/id/product_name) model+=" $(< /sys/devices/virtual/dmi/id/product_version)" elif [[ -f /sys/firmware/devicetree/base/model ]]; then model=$(< /sys/firmware/devicetree/base/model) elif [[ -f /tmp/sysinfo/model ]]; then model=$(< /tmp/sysinfo/model) fi 

The check doesn't rely on a single path, but instead looks for multiple paths to obtain the details. Therefore, it may not be a comprehensive check that is effective for all GNU/Linux distributions. For instance, the initial if statement examines a particular path that is present in Android.

Читайте также:  Установка wifite2 kali linux

I have conducted tests on different hardware and distributions for the files.

PCs and Laptops

The model information is included in the /sys/devices/virtual/dmi/id/product_name for each of my systems.

Raspberry Pi 3 Model B and Android (7.0 tested)

The model information for Android smart phone is contained in the file called /sys/firmware/devicetree/base/model , which can be found on my Raspberry Pi 3 Model B.

VirtualBox

Neofetch displays Virtualbox 1.2 as the host while running Debian on Virtualbox, which can be identified through cat /sys/devices/virtual/dmi/id/product_name /sys/devices/virtual/dmi/id/product_version .

It should be noted that the value attributed to product_version may only consist of a newline character. Therefore, it is advisable to remove any trailing newline characters by using the strip function after combining the strings obtained from reading the files.

It could be a logical step to gather all the requirements, verify the presence of files, and extract the model information from them.

A universal and dependable approach to obtaining hardware model name on Linux that is also portable is currently unavailable. To illustrate, consider two distinct scenarios: the first involves a Raspberry Pi that runs on ARM and has Raspbian as its operating system, while the second involves a TP-LINK router that runs on MIPS and has OpenWRT as its operating system.

The Raspberry Pi is equipped with an ARM CPU, and ARM devices typically utilize device-tree to describe their hardware. According to a Wikipedia article, it has been mandatory to use device-tree since 2012. The device-tree structure is available to userspace and can be utilized to retrieve a model name by executing cat along with /proc/device-tree/model . /proc/device-tree is a symlink to /sys/firmware/devicetree/base , and since there is no newline at the end of the device-tree files, a helper function named catn is created to concatenate the file and append a newline.

pi@raspberrypi:~$ catn () < cat $1 && echo; >pi@raspberrypi:~$ catn /proc/device-tree/model Raspberry Pi 3 Model B Rev 1.2 pi@raspberrypi:~$ catn /sys/firmware/devicetree/base/model Raspberry Pi 3 Model B Rev 1.2 

Either by manual dumping or by using dtc, the flattened device-tree blob /sys/firmware/fdt can be obtained.

pi@raspberrypi:~$ sudo dtc /sys/firmware/fdt 2>/dev/null | grep model compatible = "raspberrypi,3-model-b\0brcm,bcm2837"; model = "Raspberry Pi 3 Model B Rev 1.2"; 

When a Raspberry Pi Linux fork is utilized, the model information is also recorded in the /proc/cpuinfo file.

pi@raspberrypi:~$ grep "^Model" /proc/cpuinfo Model : Raspberry Pi 3 Model B Rev 1.2 

It should be noted that the complete name of the board, known as Raspberry Pi 3 Model B Rev 1.2 , is generated by the low-level firmware. However, it is important to mention that the Linux kernel code does not contain a complete string like this.

pi@raspberrypi:~$ strings /boot/start.elf | grep 'Raspberry Pi ' Raspberry Pi %s Rev %s Raspberry Pi Bootcode 

The DTSpec defines model as a typical property of the device tree.

Читайте также:  Open file linux server

Although device tree is utilized by other architectures like RISC-V to depict hardware, I am unable to verify this as I do not possess a RISC-V board.

The absence of /proc/device-tree, /sys/firmware/devicetree/base, and /sys/firmware/fdt on my TP-LINK router indicates that device-tree is either not included or that certain Linux kernel configuration options have disabled it, preventing its exposure to userspace. It is more probable that the former is the case, given that /tmp/sysinfo is present.

~ $ cat /tmp/sysinfo/board_name tl-wdr4300 ~ $ cat /tmp/sysinfo/model TP-Link TL-WDR3600 v1 

The lengthy ar71xx.sh script produces these values. Specifically, name is allocated on line 1313.

*"TL-WDR3600/4300/4310") name="tl-wdr4300" ;; 

The field in /proc/cpuinfo relies on TL-WDR4900 v2 , which is derived from machine .

machine=$(awk 'BEGIN /machine/ ' /proc/cpuinfo) 

At the end of the script, the assigned value is written to /tmp/sysinfo/board_name after being assigned to AR71XX_BOARD_NAME .

The complete numerical worth of machine as displayed in the /proc/cpuinfo of this router is:

~ $ grep "^machine" /proc/cpuinfo machine : TP-LINK TL-WDR3600/4300/4310 

Neofetch searches for /tmp/sysinfo/model instead of /tmp/sysinfo/board_name. The information is not retrieved from /proc/cpuinfo, but rather obtained from the firmware flash partition.

~ $ cat /proc/mtd dev: size erasesize name mtd0: 00020000 00010000 "u-boot" mtd1: 0010c5a4 00010000 "kernel" mtd2: 006c3a5c 00010000 "rootfs" mtd3: 00490000 00010000 "rootfs_data" mtd4: 00010000 00010000 "art" mtd5: 007d0000 00010000 "firmware" ~ $ dd if=/dev/mtdblock5 bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' && echo 36000001 

Model is assigned in line 321:

"360000"*) model="TP-Link TL-WDR3600" ;; 

It may seem unlikely that Neofetch, a generic program, possesses comprehensive information about every firmware, including their flash layout. Nonetheless, a MIPS-based version that lacks device-tree support and fails to provide valuable hardware model details in /tmp/sysinfo or other locations could be imagined. In such instances, /proc/cpuinfo could be utilized as a final option to obtain any available hardware information.

Shell scripting for monitoring the server, #/bin/bash if ! curl -v -u 'username:passowrd' https://"$addr"=18.211.231.147:5555 | grep HTTP/1.1 200; then

Shell scripting for monitoring the server

#!/bin/bash status=`nc -v -z www.google.com 80 2>&1 | grep succeeded | wc -w` if [ $status -eq 0 ] then echo "server down" else echo "server up" fi 

Instead of using the uninteresting term "success", allow the curl's result to be visible. For example:

#!/bin/bash addr=192.168.1.0 # Add desired address here if ! curl -v -u 'Administrator:******' https://"$addr":5555 | grep connected:200; then echo "Server is down" | mailx -s "server is down" "******@gmail.com" echo "Server is down" >&2 fi 

How to Check Internet Connectivity in Linux Terminal, The PING command is used for sending and receiving packages from and to some external/remote server. As an example, we will try to send three

Источник

Оцените статью
Adblock
detector