
When starting work with a new server, it will not be out of place to check whether it corresponds to the declared configuration. Many novice users have trouble when you need to view server information using commands that are available only in the console.
In this article, we will discuss how to get the Linux server specification on the command line.
')
General information about the system
You can get information about the system using the uname command, which writes to the standard output the name of the operating system in use. If you specify one of the options described below, more specialized information about the system characteristics will be output to the console:
# uname -a
Linux srv1 3.8.0-35-generic # 50-Ubuntu SMP Tue Dec 3 01:24:59 UTC 2013 x86_64 x86_64 x86_64 GNU / Linux
The name of the operating system, kernel compilation date, version and bit depth: Tue Dec 3 01:24:59 UTC 2013, 3.8.0-35-generic, i386 - 32 bits, x86_84 - 64 bits.
- -a display all possible information;
- -i show kernel id information;
- -m show the type of current hardware platform;
- -n show system name;
- -p show the type of server processor architecture;
- -r show operating system release information;
- -s show the name of the operating system being used;
- -v show version information of the operating system being used.
Information on the operating system distribution used can also be displayed using the cat / etc / issue command:
# cat / etc / issue
Ubuntu 13.04 \ n \ l
There is another way to view distribution information:
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 13.04
Release: 13.04
Codename: raring
Information about hardware components
Lshw utility
The lshw utility displays to the console a complete list of the hardware components of the system along with information about the devices. lshw is included in many modern Linux distributions by default; if it is missing, it can be installed by the standard package manager:
# apt-get install lshw
To display information about the hardware on the console, enter the following command:
# lshw
You can display this information in abbreviated form using the -short option:
# lshw -short
With lshw, you can also view information about individual hardware components of the system. To do this, use the key -C, after which the device is indicated, the information about which must be output to the console:
- processor:
# lshw -C pu
- memory:
# lshw -C memory
- disk subsystem:
# lshw -C disk
Lspci utility
Using the lspci utility, you can view information about all PCI buses and devices connected to them. It is included in the pciutils package included in most modern Linux distributions; if it is missing for any reason, it can be installed using the standard package manager.
By default, lspci shows a short list of devices; more information can be obtained through numerous options.
The -t option displays information about tires and connected devices in a tree. Only digital device identifiers will be listed in the output:
# lspci -t
- [0000: 00] - + - 00.0
+ -01.0- [01] - + - 00.0
| \ -00.1
+ -03.0- [02] - + - 00.0
| \ -00.1
+ -07.0- [04] -
+ -09.0- [05] -
+ -14.0
+ -14.1
+ -1c.0- [03] ---- 00.0
+ -1d.0
+ -1e.0- [06] ---- 03.0
+ -1f.0
You can view device numeric codes using the -n option:
# lspci -n
01: 00.1 0200: 14e4: 1639 (rev 20)
02: 00.0 0200: 14e4: 1639 (rev 20)
02: 00.1 0200: 14e4: 1639 (rev 20)
03: 00.0 0104: 1000: 0079 (rev 05)
06: 03.0 0300: 102b: 0532 (rev 0a)
At the beginning of each line in the output indicates the device code in the format ":.", And then - the code in the format ":".
To include in the list not only codes, but also the names of the corresponding devices, the -nn option is indicated:
# lspci -nn
01: 00.0 Ethernet controller [0200]: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet [14e4: 1639] (rev 20)
03: 00.0 RAID bus controller [0104]: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] [1000: 0079] (rev 05)
06: 03.0 VGA compatible controller [0300]: Matrox Electronics Systems Ltd. MGA G200eW WPCM450 [102b: 0532] (rev 0a)
You can define the device name using the “:.” Code using the -s option:
# lspci -s 03: 00.0
03: 00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] (rev 05)
To determine the device by the code ":," you need to use the option-d:
# lspci -d 1000: 0079
03: 00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] (rev 05)
After the -d key, you can specify only the supplier code or device code, for example:
# lspci -d 8086:
# lspci -d: 0532
In this case, a list of all devices corresponding to the entered code will be displayed.
To view information about kernel drivers responsible for specific devices, use the -k option:
# lspci -k
00: 1f.2 IDE interface: Intel Corporation 82801IB (ICH9) 2 port SATA Controller [IDE mode] (rev 02)
Subsystem: Dell PowerEdge R610 SATA IDE Controller
Kernel driver in use: ata_piix
Kernel modules: ata_generic, pata_acpi, ata_piix
02: 00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
Subsystem: Dell PowerEdge R610 BCM5709 Gigabit Ethernet
Kernel driver in use: bnx2
Kernel modules: bnx2
03: 00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] (rev 05)
Subsystem: Dell PERC H700 Integrated
Kernel driver in use: megaraid_sas
Kernel modules: megaraid_sas
Pseudo file system / proc
Information about hardware components in Linux systems is stored in the so-called pseudo-file system / proc. It is called pseudo-file, because it is virtual and does not occupy any space on the drive at all. Most of the pseudo-files stored in / proc are presented in human-readable form. The / proc tree is used by many programs that display information about the system.
CPU
Information about the processor is stored in the / proc / cpuinfo pseudo file. To view its contents, enter the following command:
# cat / proc / cpuinfo
The output of this command contains a lot of different information: about the processor model, the number of cores, supported hardware virtualization technologies, etc.
The most voluminous and difficult to understand section of the output is, of course, flags (flags). They are also contained in the output of the lshw command.
Consider the values of the most important flags:
- ht (HyperThreading) - support for simultaneous multithreading technologies; is present in the series of processors Intel Xeon, Pentium 4, Atom, Core i3, Core i5, Core i7;
- lm (long mode) - specified if the processor is made using 64-bit technology;
- vmx (for Intel), svd (for AMD) - processor support for hardware virtualization technologies; means having instructions to provide direct access to processor resources from guest systems;
- aes - support for expanding the AES command system;
- hypervisor - indicates if the OS is running under the hypervisor;
- smx - support for TXT (TPM) technology.
Detailed information on the meaning of all flags can be found
here and
here .
Memory
You can view information about the total amount of free and used memory, including swap, using the free command. The output of this command might look like this:
# free -m
total used free shared buffers cached
Memory: 3627 3216 410 0 107 1157
- / + buffers / cached: 1950 1676
Swap: 3762 31 3731
The -m option indicates that the amount of free and used memory should be displayed in megabytes. To display the volume in gigabytes, you need to specify the -g key; this is convenient for servers with a large amount of RAM (tens or even hundreds of gigabytes).
More detailed information is stored in the / proc / meminfo pseudo file.
The output of the cat / proc / meminfo command includes the following basic parameters:
- MemTotal - available RAM;
- MemFree - shows how much memory is currently not used and is available for allocation to processes;
- Buffers is a memory area in which data is waiting to be written to disk;
- Cached - the volume occupied by the cache read pages from the disk;
- SwapCached - the volume that was moved to the paging area, and then moved back into RAM;
- Active - the amount of memory occupied by the most frequently used pages;
- Inactive - the amount of memory occupied by pages that are not currently used;
- Swap {total, free} - total swap space;
- Dirty - the so-called "dirty" pages (i.e. those in RAM, but not yet flushed to disk);
- Writeback - pages that are currently flushed to disk;
- AnonPages - anonymous pages (data used by programs, but not associated with any file);
- Mapped - total amount of memory transferred to the virtual address space of processes using mmap;
- Committed_AS - the amount of memory allocated to all processes (even if they do not use it in full).
Disk subsystem
To check the breakdown and number of disks, use the command
# fdisk -l
The size of free and occupied disk space on all mounted file systems can be found using the df command. The command uses the following options:
- -a display information about all file systems;
- -h display information in human readable format;
- -T show file system type;
- -t only display information about the specified file system types.
Consider the df -h command output example in more detail:
# df -h
Filesystem Size Used Avail Use% Mounted on
/ dev / mapper / vg0-vg0root 50G 15G 32G 32% /
tmpfs 5.9G 0 5.9G 0% / dev / shm
/ dev / sda1 1008M 62M 895M 7% / boot
/ dev / mapper / vg0-var 2.7T 839G 1.7T 33% / var
Information about the size of the actual free space is displayed in the Available section. If you add the numbers listed in the sections Available and Used, then the resulting amount will not be equal to the figure in the section Size. This is due to the fact that part of the disk space is allocated for system files and metadata.
You can view detailed information about the status of your hard disk using the smartctl utility included in the official repositories of most modern Linux distributions. To view the full information you need to enter the command:
# smartctl -a / dev / sda
On the interpretation of the output command can be found
in this article .
The pvdisplay, pvs, and pvscan commands are used to display information about physical volumes.
The pvscan command checks all block devices in the system for the presence of physical volumes:
# pvscan
PV / dev / md0 VG vg0 lvm2 [462.96 GiB / 205.22 GiB free]
Total: 1 [462.96 GiB] / in use: 1 [462.96 GiB] / in no VG: 0 [0]
Using the pvdisplay command, you can view detailed multiline output for each physical volume:
# pvdisplay
--- Physical volume ---
PV Name / dev / md0
VG Name vg0
PV Size 462.96 GiB / not usable 1.87 MiB
Allocateable yes
PE Size 4.00 MiB
Total PE 118517
Free PE 52536
Allocated PE 65981
PV UUID Idm6eZ-5vS0-IJCo-RDQq-WZNk-nJ22-eb7aDd
Using the pvs command, you can customize the data display format (for each volume - one line). This is useful, for example, when writing scripts.
To view information about logical volumes of a hard disk, use the lvs, lvscan and lvdisplay utilities included in the lvm2 package. lvm2 is installed using the standard package manager:
# apt-get install lvm2
The lvscan command lists to the console a list of all logical volumes in the system (listing the output fragment):
# lvscan
ACTIVE '/ dev / vg0 / root' [18.62 GiB] inherit
ACTIVE '/ dev / vg0 / www' [200.00 GiB] inherit
Using the lvdisplay command, you can list the attributes of logical volumes (name, size, markup) on the console. You can view information about the attributes of a specific logical volume using the -v option and specifying its name (listing the output fragment):
# lvdisplay
--- Logical volume ---
LV Name / dev / vg0 / root
VG Name vg0
LV UUID yPtVFt-BON5-agWC-jXSr-cU4x-Tcu9-NRiwMF
LV Write Access read / write
LV Status available
# open 1
LV Size 18.62 GiB
Current LE 4768
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253: 0
--- Logical volume ---
LV Name / dev / vg0 / www
VG Name vg0
LV UUID reCzuE-5dgN-A4eB-LubM-VtUA-Lclq-MUt5v6
LV Write Access read / write
LV Status available
# open 1
LV Size 200.00 GiB
Current LE 51200
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253: 2
The lvs command is similar to the pvs command discussed above: it allows you to customize the data display format and displays one volume per line.
# lvs
LV VG Attr
root vg0 -wi-ao 18.62g
www vg0 -wi-ao 200.00g
Information about the status of active software RAIDs is stored in the / proc / mdstat pseudo file. You can view its contents using the cat / proc / mdstat command:
# cat / proc / mdstat
Personalities: [raid1]
read_ahead 1024 sectors
md1: active raid1 hda3 [0] hdc3 [1]
522048 blocks [2/2] [UU]
md0: active raid1 hda2 [0] hdc2 [1]
4192896 blocks [2/2] [UU]
md2: active raid1 hda1 [0] hdc1 [1]
128384 blocks [2/2] [UU]
In the example we are considering, the system contains three arrays. For each of them in the pseudo file / proc / mdstat there is a separate section containing the following information:
- RAID name;
- RAID status;
- array level;
- the names of the physical partitions that make up the array;
- the number of configured devices and the number of working devices in the array;
- the state of each working device (U means that the device is working, and _ - that the device has failed, sync - synchronization is in progress).
You can check whether hardware RAID is used on the server using the lspci command already familiar to us:
# lspci -nn | grep RAID
If RAID is used, then the following response will be output to the console:
02: 00.0 RAID bus controller [0104]: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] [1000: 0079] (rev 04)
Information about the state of hardware RAID using standard tools of the operating system cannot be obtained. There are special utilities for this: MegaCLI for LSI controllers and Adaptec Storage Manager (asm) for adaptec. They are not included in the official Linux repositories. You can download megacli
from here , and ASM comes
from the Adaptec website .
Network interfaces
Information about all network interfaces connected to the system is contained in the / proc / net / dev pseudo file. If you enter the cat / proc / net / dev command, the list of all active and inactive network interfaces will be displayed on the console.
The status of all current interfaces can be viewed using the ip link show up command.
The ip address command displays information about all network interfaces:
# ip address
1: lo: mtu 16436 qdisc noqueue state UNKNOWN
link / loopback 00: 00: 00: 00: 00: 00 brd 00: 00: 00: 00: 00: 00
inet 127.0.0.1/8 scope host lo
inet6 :: 1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link / ether 00: 30: 48: f2: 7a: a0 brd ff: ff: ff: ff: ff: ff
inet 5.178.83.252/29 brd 5.178.83.255 scope global eth0
inet6 fe80 :: 230: 48ff: fef2: 7aa0 / 64 scope link
valid_lft forever preferred_lft forever
3: eth1: mtu 1500 qdisc noop state DOWN qlen 1000
link / ether 00: 30: 48: f2: 7a: a1 brd ff: ff: ff: ff: ff: ff
UP means the interface is up; NO CARRIER means no cable or transceiver in the port of the network card. The ip route command (abbreviated version - ip r) displays routing tables on the console.
# ip r
default via 88.93.16.185 dev br0
50.178.87.0/24 via 192.16.122.1 dev br0
10.0.0.0/8 via 192.16.122.1 dev br0
1.131.251.0/24 via 192.16.122.1 dev br0
192.16.122.0/24 dev br0 proto kernel scope link src 192.16.122.2
88.93.16.184/29 dev br0 proto kernel scope link src 88.93.16.186
Conclusion
This article is the first in a series of publications devoted to the problems of setting up and administering web services. In the near future, we plan to publish articles about the features of installing and optimizing server software, troubleshooting, etc.
We will be happy if in the comments you make suggestions and suggestions on the subject of the next publications of the cycle.
Readers who for one reason or another cannot comment on posts on Habré are invited to
our blog .