Machine info in linux

10 Commands to Collect System and Hardware Info in Linux

It is always a good practice to know the hardware components of your Linux system is running on, this helps you to deal with compatibility issues when it comes to installing packages, drivers on your system using yum, dnf, or apt.

10 Commands to Check Hardware and System Information in Linux

Therefore in these tips and tricks series, we shall look at some useful commands that can help you to extract information about your Linux system and hardware components.

1. How to View Linux System Information

To know only the system name, you can use the uname command without any switch that will print system information or the uname -s command will print the kernel name of your system.

To view your network hostname, use the ‘-n’ switch with the uname command as shown.

To get information about kernel-version, use the ‘-v’ switch.

To get the information about your kernel release, use the ‘-r’ switch.

To print your machine hardware name, use the ‘-m’ switch:

All this information can be printed at once by running the ‘uname -a’ command as shown below.

2. How to View Linux System Hardware Information

Here you can use the lshw tool to gather vast information about your hardware components such as cpu, disks, memory, usb controllers, etc.

lshw is a relatively small tool and there are few options that you can use with it while extracting information. The information provided by lshw was gathered from different /proc files.

Note: Do remember that the lshw command is executed by the superuser (root) or sudo user.

To print information about your Linux system hardware, run this command.

You can print a summary of your hardware information by using the -short option.

If you wish to generate output as an html file, you can use the option -html.

Generate Linux Hardware Information in HTML

3. How to View Linux CPU Information

To view information about your CPU, use the lscpu command as it shows information about your CPU architecture such as a number of CPUs, cores, CPU family model, CPU caches, threads, etc from sysfs and /proc/cpuinfo.

4. How to Collect Linux Block Device Information

Block devices are storage devices such as hard disks, flash drives, etc. lsblk command is used to report information about block devices as follows.

Читайте также:  Zsh permission denied kali linux

If you want to view all block devices on your system then include the -a option.

5. How to Print USB Controllers Information

The lsusb command is used to report information about USB controllers and all the devices that are connected to them.

You can use the -v option to generate detailed information about each USB device.

6. How to Print PCI Devices Information

PCI devices may include usb ports, graphics cards, network adapters, etc. The lspci tool is used to generate information concerning all PCI controllers on your system plus the devices that are connected to them.

To print information about PCI devices run the following command.

Use the -t option to produce output in a tree format.

Use the -v option to produce detailed information about each connected device.

7. How to Print SCSI Devices Information

To view all your scsi/sata devices, use the lsscsi command as follows. If you do not have the lsscsi tool installed, run the following command to install it.

After installation, run the lsscsi command as shown:

Use the -s option to show device sizes.

8. How to Print Information about SATA Devices

You can find some information about sata devices on your system as follows using the hdparm utility. In the example below, I used the block device /dev/sda1 which is the hard disk on my system.

To print information about device geometry in terms of cylinders, heads, sectors, size, and the starting offset of the device, use the -g option.

9. How to Check Linux File System Information

To gather information about file system partitions, you can use the fdisk command. Although the main functionality of the fdisk command is to modify file system partitions, it can also be used to view information about the different partitions on your file system.

You can print partition information as follows. Remember to run the command as a superuser or else you may not see any output.

10. How to Check Linux Hardware Components Info

You can also use the dmidecode utility to extract hardware information by reading data from the DMI tables.

To print information about memory, run this command as a superuser.

To print information about the system, run this command.

To print information about BIOS, run this command.

To print information about the processor, run this command.

Summary

There are many other ways you can use to obtain information about your system hardware components. Most of these commands use files in the /proc directory to extract system information.

Hope you find these tips and tricks useful and remember to post a comment in case you want to add more information to this or if you face any difficulties in using any of the commands. Remember to always stay connected to Tecmint.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Читайте также:  Цифровое аудио hdmi не подключено что делать windows 10

We are thankful for your never ending support.

Источник

Получение информации о компьютере на UNIX

В данной статье пойдет речь о способах сбора сведений об оборудовании компьютера, который находится под управлением операционных систем семейства UNIX, такие как Linux и BSD. Также, будет немного затронута часть получения системной информации. Действия будут выполняться из командной строки без графической оболочки — их можно выполнить, подключившись к компьютеру удаленно по SSH.

Информация о процессоре

Команды для получения данных о процессоре.

1. lscpu (Linux)

Команда показывает информацию о характеристиках процессора в удобном виде:

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 2
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Model name: Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
Stepping: 4
CPU MHz: 2592.918
BogoMIPS: 5187.50
Hypervisor vendor: VMware
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 20480K
NUMA node0 CPU(s): 0-7

* больше всего нас интересует:

  • Architecture — архитектура процессора — 32 бит или 64.
  • Core(s) per socket — количество ядер на процессор.
  • Socket(s) — количество физических/виртуальных процессоров.
  • CPU(s) — суммарное количество процессорных ядер.
  • Model name — модель процессора.

2. sysctl -a (FreeBSD)

Команда отображает множество данных, поэтому добавляем фильтр:

sysctl -a | egrep -i ‘hw.machine|hw.model|hw.ncpu’

hw.model: Intel(R) Xeon(R) CPU X5690 @ 3.47GHz
hw.machine: amd64
hw.ncpu: 2

* на самом деле, команда sysctl работает и в Linux, но формат вывода менее удобен, по сравнению с вышерассмотренной lscpu.

3. Файл /proc/cpuinfo (Linux)

Позволяет увидеть подробную информацию по каждому ядру:

Команда для подсчета количества ядер:

cat /proc/cpuinfo | grep processor | wc -l

4. Температура процессора

Linux

Сначала необходимо установить утилиту.

yum install lm_sensors

apt-get install lm-sensors

После установки утилиты выполняем:

FreeBSD

Загружаем необходимый модуль:

* для автоматической его загрузки добавляем в файл /boot/loader.conf строку coretemp_load=»YES»

sysctl -a | grep temperature

dev.cpu.0.temperature: 40.0C
dev.cpu.1.temperature: 41.0C

Информация об оперативной памяти

1. Файл /proc/meminfo (Linux)

MemTotal: 8010284 kB
MemFree: 1058580 kB
MemAvailable: 2791616 kB
Buffers: 1884 kB
Cached: 1754092 kB
SwapCached: 122280 kB
Active: 4330296 kB
Inactive: 2006792 kB
Active(anon): 3623768 kB
Inactive(anon): 983120 kB
Active(file): 706528 kB
Inactive(file): 1023672 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 1048572 kB
SwapFree: 597684 kB
Dirty: 20 kB
Writeback: 0 kB
AnonPages: 4466532 kB
Mapped: 92808 kB
Shmem: 25776 kB
Slab: 408732 kB
SReclaimable: 308820 kB
SUnreclaim: 99912 kB
KernelStack: 7312 kB
PageTables: 23276 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 5053712 kB
Committed_AS: 3770324 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 159328 kB
VmallocChunk: 34359341052 kB
HardwareCorrupted: 0 kB
AnonHugePages: 3248128 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 257984 kB
DirectMap2M: 8130560 kB

* чаще всего, самое важное:

  • MemTotal — общий объем оперативной памяти.
  • MemFree — объем памяти, который не используется системой.
  • Buffers — память, которая в данным момент ожидает записи на диск.
  • Cached — объем, задействованный под кэш чтения с диска.
  • MemAvailable — объем памяти, доступной в распределители без необходимости обмена.
  • SwapTotal — объем файла подкачки.
  • SwapFree — свободный объем файла подкачки.

* Объем используемой памяти = MemTotal – MemFree — Cached — Buffers.

Для перевода килобайт в гигабайты можно воспользоваться онлайн калькулятором.

2. free (Linux)

Данная команда позволяет получить информацию об использовании памяти в удобной таблице. Для еще большего удобства, мы выведем ее с помощью дополнительного параметра -h:

Читайте также:  Добавить символьную ссылку linux

total used free shared buff/cache available
Mem: 3,7G 568M 378M 193M 2,8G 2,6G
Swap: 4,0G 94M 3,9G

Источник

Получаем информацию об оборудовании в Linux

Рассмотрим несколько полезных команд и утилит с помощью которых можно получить информацию об оборудовании в Linux. Такая потребность возникает, например, тогда, когда вам нужно установить драйвер для какого-нибудь устройства компьютера и вам нужно знать его точное название. Или, например, вы хотите получить информацию о занимаемой памяти или ресурсах компьютера.

Информация о процессоре (CPU)

Получить всю необходимую информацию о центральном процессоре в Linux можно выполнив в терминале команду:

Чтобы определить является ли ваш процессор 32-х или 64-битным нужно просмотреть флаги, которые указаны в выводе команды. Если среди флагов присутствует lm (long mode), это означает, что ваш процессор 64-битный. Например, при выполнении команды cat /proc/cpuinfo мы можем получить следующие флаги:

Информация о PCI устройствах (информация о видео-карте)

С помощью команды lspci можно вывести всю информацию о PCI устройствах:

Эту команду часто используют, чтобы получить информацию о видео-карте. Так как вывод команды lspci достаточно большой, то можно воспользоваться командой grep, чтобы задать условие поиска. Например, если мы знаем, что у нас видео-карта от Nvidia, тогда можно воспользоваться командой:

И в результате получить что-нибудь вроде:

Обратите внимание на то, что команда grep чувствительна к регистру символов и поэтому, если вы с первого раза не нашли то, что искали, то стоит попробовать другое написание, например, nvidia, NVIDIA или просто idia. Аналогично можно искать информацию в выводе любых других команд, добавляя к команде: «| grep строка-поиска.

Информацию о версии драйвера для видео-карт Nvidia в Linux можно получить выполнив:

Информация об оперативной памяти (ОЗУ)

Чтобы получить информацию об объеме, а также о количестве свободной и занятой оперативной памяти можно воспользоваться командой:

Информацию о виртуальной памяти можно получить командой vmstat:

Если вам нужна более детальная информация о процессах, занимающих оперативную память, о загруженности процессора (CPU), тогда можно использовать утилиты Top или htop. Утилита top как правило всегда присутствует в Linux. Для ее запуска просто выполните:

Информация о жестких дисках

Информация о разделах жесткого диска в Linux:

Информация о монтированных разделах, количество свободной и занятой памяти:

Есть еще одна полезная команда du, которая выводит информацию о размере каждого файла в текущей и во вложенных директориях. Если вы хотите получить информацию обо всех файлах в текущей директории выполните команду без параметров:

В качестве параметра можно задать имя файла, например, чтобы узнать размер файла abc.bin выполните:

Информация о USB устройствах и шинах USB

Для вывода информации о шинах USB и о подключенных USB устройствах используется команда lsusb:

Неконсольные программы

Рассмотрим несколько графических программ, которые помогут при работе с оборудованием.

В среде рабочего стола Gnome есть графическая утилита System monitor (Системный монитор). Она выводит информацию об использовании процессора, о запущенных процессах (приложениях), информацию о жестких дисках, а также выводит графики, включая использование сети. Из командой строки ее можно запустить выполнив:

Для работы с жесткими можно воспользоваться программой GParted.

Дополнительная информация

Напоследок обязательно стоит упомянуть об очень важной команде lshw, которая выводит практически всю информацию о вашем компьютере. Команду lshw нужно запускать под пользователем root:

Чтобы вывести краткую информацию используется ключ -short:

Получить более подробную информацию о командах, описанных в статье, можно используя справочную систему Linux. Для этого в консоли нужно выполнить:

Например, чтобы получить всю информацию о команде du, выполните команду:

Источник

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