Tuesday, March 24, 2015

TuxArena | Guide: Show System/Hardware Information in Linux

http://www.tuxarena.com/intro/sysinfo.php

This is a tutorial aimed at showing how to get hardware and general system information on Linux. There are also a few examples which normally work on Debian and its derivatives, like Ubuntu or Linux Mint.

Kernel Info

The tool which is always at hand when looking for basic system information and kernel information is uname. To output all the available information this tool can show, use uname -a. Example output:
$ uname -a
Linux mint 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:31:42 UTC 2014 i686 i686 i686 GNU/Linux
It shows OS type, hostname, kernel version, date and architecture.

HDD Info

A very good tool for getting HDD information and health reporting is smartctl, included in the smartmontools package. To get HDD information, run it like this:
sudo smartctl -a /dev/sda
Eventually replace /dev/sda with your HDD device. To run a health test, use:
sudo smartctl -t short /dev/sda
The tool will tell you to wait a few minutes until the test is over, after which you can see the test results using the following:
sudo smartctl -l selftest /dev/sda

HDD Partition Info/Free Space

df is a tool used to report total, used and free space on HDD partitions or other mounted filesystems, like USB memory drives. It's usually availale on any Linux system, inside the /bin directory. Probably the most usual way to use it is df -h, which will display information using human-readable format for sizes (KB, MB and so on). Example output:
$ df -h
/dev/sda6        82G   67G   11G  87% /floydb
/dev/sda5       202G  184G  7.4G  97% /floyda
Here's what the columns mean:
  • 1st column: device
  • 2nd column: total filesystem space
  • 3rd column: used filesystem space
  • 4th column: free filesystem space
  • 5th column: free filesystem space in percentage of the total size
  • 6th column: mount point
You can use df to show the filesystem type (ext3, ext4, etc) as well, using the -T switch:
$ df -T
/dev/sda6      ext3       82G   67G   11G  87% /floydb
/dev/sda5      ext3      202G  184G  7.4G  97% /floyda
As you can see, a new column is now displayed, showing the filesystem type. Grouping arguments works as well:
df -hT

CPU Temperature

For this we will use the sensors tool, which is available in the lm-sensors package, which is a hardware health monitoring tool. Here's how the output may look like, showing the temperature of each of the CPU cores:
$ sensors
Core 0:         +32.0°C  (high = +82.0°C, crit = +102.0°C)
Core 1:         +33.0°C  (high = +82.0°C, crit = +102.0°C)

Memory Info

Use the free tool, located inside /usr/bin:
$ free -m
             total       used       free     shared    buffers     cached
Mem:          3913       3502        411        179        277       1965

Debian Version

Debian comes with the plain text file /etc/debian_version showing the codename of the release. This is also available in Ubuntu or Mint:
$ cat /etc/debian_version 
jessie/sid

Ubuntu/Mint Version

Ubuntu and Mint have a similar file showing the codename of the release in /etc/issue:
$ cat /etc/issue
Linux Mint 17 Qiana \n \l

Powerful System Info Script: inxi

Linux Mint comes with the powerful inxi script installed by default, providing comprehensive information about the system hardware and software. By default, inxi will report a short description for the CPU, kernel version or memory, but it can display detailed information using various switches.
$ inxi
CPU~Dual core Intel Celeron CPU G530 (-MCP-) clocked at 1600.000 Mhz Kernel~3.13.0-24-generic i686 Up~1 day Mem~1093.9/3913.6MB HDD~500.1GB(66.3% used) Procs~189 Client~Shell inxi~1.8.4
For detailed information, use inxi -v 7. To see all the available arguments which change its output, see inxi -h.

Inxi: Motherboard and BIOS Info

$ inxi -M
Machine:   Mobo: ASUSTeK model: P8H61-M LX3 PLUS R2.0 version: Rev X.0x
           Bios: American Megatrends version: 1106 date: 02/25/2014

Inxi: Audio Info

$ inxi -A
Audio:     Card: Intel 6 Series/C200 Series Chipset Family High Definition Audio Controller driver: snd_hda_intel
           Sound: Advanced Linux Sound Architecture ver: k3.13.0-24-generic

Additional Info: /proc

Get CPU info:
cat /proc/cpuinfo
Get memory info:
cat /proc/meminfo

Processes Info: ps

See a list of processes:
ps aux

Processes Monitoring: top and htop

Monitor processes in real-time with top and its improved, color-formatted variant, htop:
$ top
             total       used       free     shared    buffers     cached
Mem:          3913       3502        411        179        277       1965
...

Display Network Interfaces

The ifconfig tool will come in handy to show interfaces, IPs and MAC address of the network card:
ifconfig eth0

Show Network Info and Open Sockets

Use the netstat tool:
$ netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 localhost:46653         localhost:microsoft-ds  TIME_WAIT
...

Network Monitor: iptraf

This tool is a network monitoring program which shows various network statistics.

No comments:

Post a Comment