Friday, November 15, 2013

Linux System Info Commands


In this post, I will cover the cli commands that can be used to get system information. I will also cover some GUI tools in my upcoming posts. Embedded systems do not have GUI capabilities & hence the following commands would be handy despite the availability of various GUI based tools.

CPU Info

How many processors does the system have?

Method1:
      root@babu-VirtualBox:~# grep processor /proc/cpuinfo
      processor     : 0
      processor     : 1


               root@babu-VirtualBox:~# 

Method2:
      root@babu-VirtualBox:~# lscpu | grep "CPU(s):"
      CPU(s):                2
      root@babu-VirtualBox:~# 

What processor make/vendor, speed?

Method1:
      root@babu-VirtualBox:~# grep "model name" /proc/cpuinfo | unique   <-- architecture specific, but works for intel processors
      model name   : Intel(R) Core(TM) i7-3540M CPU @ 3.00GHz
      root@babu-VirtualBox:~# 

Method2:
      root@babu-VirtualBox:~# lscpu | grep Vendor
      Vendor ID:             GenuineIntel
      root@babu-VirtualBox:~# 

      root@babu-VirtualBox:~# lscpu | grep MHz
      CPU MHz:               2976.472
      root@babu-VirtualBox:~# 

What is processor type/architecture?
Method1:
      root@babu-VirtualBox:~# uname -p
      i686
      root@babu-VirtualBox:~# 
      
      root@babu-VirtualBox:~# uname -m   
      i686

      root@babu-VirtualBox:~#
Method2:
      root@babu-VirtualBox:~# arch <-- is this installed kernel or processor type?
      i686
      root@babu-VirtualBox:~# 
Method3:
      root@babu-VirtualBox:~# lscpu | grep Architecture
      Architecture:          i686
      root@babu-VirtualBox:~# 

Is the processor 32-bit or 64-bit or both? (this is different from whether the running OS  is 32-bit or 64-bit)


root@babu-VirtualBox:~# lscpu | grep "CPU op"
CPU op-mode(s):        32-bit
root@babu-VirtualBox:~# 

What is the endian-ness of the processor?

root@babu-VirtualBox:~# echo -n I | od -to2 | awk 'FNR==1{ print substr($2,6,1)}'
1
root@babu-VirtualBox:~# 
    <-- 0 if Big endian, 1 if little endian

root@babu-VirtualBox:~# lscpu | grep "Byte"
Byte Order:            Little Endian
root@babu-VirtualBox:~# 

RAM Info

What is the RAM size?
Method1:
      root@babu-VirtualBox:~# cat /proc/meminfo | grep MemTotal
      MemTotal:        1026276 kB
      root@babu-VirtualBox:~# 
Method2:
      root@babu-VirtualBox:~# free -m
                 total              used       free     shared    buffers     cached
Mem:          1002        732        269          0         43        431
-/+ buffers/cache:        257        744
Swap:          510         110        400
root@babu-VirtualBox:~# 

Disk Info

What is the size of the disk?
root@babu-VirtualBox:~# df | grep '^/dev/*' | awk '{s+=$2} END {print s/1048576}'
54.0081          <--- in GB
         root@babu-VirtualBox:~#


root@babu-VirtualBox:~# inxi -D
Drives:    HDD Total Size: 59.6GB (23.8% used) 1: id: /dev/sda model: VBOX_HARDDISK size: 59.6GB 
root@babu-VirtualBox:~#
   
Is the disk SSD or HDD? 
         root@babu-VirtualBox:~# cat /sys/block/sda/queue/rotational
        1         <---  1 for hard disks and 0 for an SSD
         root@babu-VirtualBox:~# 

OS Info


What is the OS distribution?

root@babu-VirtualBox:~# head -n1 /etc/issue
Ubuntu 13.10 \n \l
root@babu-VirtualBox:~# 

root@babu-VirtualBox:~# cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.10
DISTRIB_CODENAME=saucy
DISTRIB_DESCRIPTION="Ubuntu 13.10"
NAME="Ubuntu"
VERSION="13.10, Saucy Salamander"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 13.10"
VERSION_ID="13.10"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
root@babu-VirtualBox:~# 

root@babu-VirtualBox:~# lsb_release -a
No LSB modules are available.
Distributor ID:           Ubuntu
Description:   Ubuntu 13.10
Release:         13.10
Codename:    saucy
root@babu-VirtualBox:~# 

What is the linux kernel version?
root@babu-VirtualBox:~# uname -r
3.11.0-12-generic
          root@babu-VirtualBox:~#


root@babu-VirtualBox:~# cat /proc/version 
Linux version 3.13.5 (root@babu-VirtualBox) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu9) ) #2 SMP Tue Mar 25 00:40:49 PDT 2014
root@babu-VirtualBox:~# 

Is the OS 32-bit or 64-bit?
root@babu-VirtualBox:~# uname -a
Linux babu-VirtualBox 3.13.5 #1 SMP Wed Mar 5 12:34:20 PST 2014 i686 i686 i686 GNU/Linux
root@babu-VirtualBox:~# 
          <-- In case of 64 bit, we get x86_64. In case of 32-bit, we get i386/i486/i586/i686

root@babu-VirtualBox:~# file /sbin/init   (or any binary in /bin directory)
/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xc0d86a25a7abb14cad4a65a1f7d03605bcbd41f6, stripped
root@babu-VirtualBox:~# 
        <--- 32-bit above indicates 32 bit. 64 bit above indicates 64 bit.

root@babu-VirtualBox:~# getconf LONG_BIT
32         <----- 32, if OS is 32 bit - 64, if OS is 64 bit
root@babu-VirtualBox:~# 
            

More detailed info about the system:
root@babu-VirtualBox:~# lscpu
Architecture
: i686
CPU op-mode(s)
: 32-bit
Byte Order
: Little Endian
CPU(s)
: 2
On-line CPU(s) list
: 0,1
Thread(s) per core
: 1
Core(s) per socket
: 2
Socket(s)
: 1
Vendor ID
: GenuineIntel
CPU family
: 6
Model
: 58
Stepping
: 9
CPU MHz
: 2976.472
BogoMIPS
: 5952.94
L1d cache
: 32K
L1d cache
: 32K
L2d cache
: 6144K

root@babu-VirtualBox:~# 

root@babu-VirtualBox:~# cat /proc/cpuinfo
processor
: 0
vendor_id
: GenuineIntel
cpu family
: 6
model
: 58
model name
: Intel(R) Core(TM) i7-3540M CPU @ 3.00GHz
stepping
: 9
cpu MHz
: 2976.472
cache size
: 6144 KB
physical id
: 0
siblings
: 2
core id
: 0
cpu cores
: 2
apicid
: 0
initial apicid
: 0
fdiv_bug
: no
f00f_bug
: no
coma_bug
: no
fpu
: yes
fpu_exception
: yes
cpuid level
: 5
wp
: yes
flags
: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht nx rdtscp constant_tsc pni ssse3
bogomips
: 5952.94
clflush size
: 64
cache_alignment
: 64
address sizes
: 36 bits physical, 48   bits virtual
power management:



processor
: 1
vendor_id
: GenuineIntel
cpu family
: 6
model
: 58
model name
: Intel(R) Core(TM) i7-3540M CPU @ 3.00GHz
stepping
: 9
cpu MHz
: 2976.472
cache size
: 6144 KB
physical id
: 0
siblings
: 2
core id
: 1
cpu cores
: 2
apicid
: 1
initial apicid
: 1
fdiv_bug
: no
f00f_bug
: no
coma_bug
: no
fpu
: yes
fpu_exception
: yes
cpuid level
: 5
wp
: yes
flags
: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht nx rdtscp constant_tsc pni ssse3
bogomips
: 5952.94
clflush size
: 64
cache_alignment
: 64
address sizes
: 36 bits physical, 48   bits virtual
power management:

root@babu-VirtualBox:~# 

To install inxi tool in ubuntu, I had to do these:

root@babu-VirtualBox:~# inxi -b
System:    Host: babu-VirtualBox Kernel: 3.11.0-12-generic i686 (32 bit) Desktop: N/A Distro: Ubuntu 13.10
Machine:   System: innotek product: VirtualBox version: 1.2 serial: 0 
           Mobo: Oracle model: VirtualBox version: 1.2 serial: 0 Bios: innotek version: VirtualBox date: 12/01/2006
CPU:       Dual core Intel Core i7-3540M CPU (-MCP-) clocked at 2976.472 MHz 
Graphics:  Card: InnoTek Systemberatung VirtualBox Graphics Adapter 
           X.org: 1.14.3 drivers: ati,vboxvideo (unloaded: fbdev,vesa) tty size: 70x24 Advanced Data: N/A for root 
Network:   Card: Intel 82540EM Gigabit Ethernet Controller driver: e1000 
Drives:    HDD Total Size: 59.6GB (23.8% used)
Info:      Processes: 171 Uptime: 8:45 Memory: 300.7/1002.2MB Client: Shell (bash) inxi: 1.9.12 
root@babu-VirtualBox:~#


root@babu-VirtualBox:~# inxi -F
System:    Host: babu-VirtualBox Kernel: 3.11.0-12-generic i686 (32 bit) Desktop: N/A Distro: Ubuntu 13.10
Machine:   System: innotek product: VirtualBox version: 1.2 serial: 0 
           Mobo: Oracle model: VirtualBox version: 1.2 serial: 0 Bios: innotek version: VirtualBox date: 12/01/2006
CPU:       Dual core Intel Core i7-3540M CPU (-MCP-) cache: 6144 KB flags: (nx pae sse sse2 sse3 ssse3) 
           Clock Speeds: 1: 2976.472 MHz 2: 2976.472 MHz
Graphics:  Card: InnoTek Systemberatung VirtualBox Graphics Adapter 
           X.org: 1.14.3 drivers: ati,vboxvideo (unloaded: fbdev,vesa) tty size: 70x24 Advanced Data: N/A for root 
Audio:     Card: Intel 82801AA AC'97 Audio Controller driver: snd_intel8x0 Sound: ALSA ver: k3.11.0-12-generic
Network:   Card: Intel 82540EM Gigabit Ethernet Controller driver: e1000 
           IF: eth0 state: up speed: 1000 Mbps duplex: full mac: 08:00:27:2a:c0:33
Drives:    HDD Total Size: 59.6GB (23.8% used) 1: id: /dev/sda model: VBOX_HARDDISK size: 59.6GB 
Partition: ID: / size: 55G used: 14G (26%) fs: ext4 ID: swap-1 size: 0.54GB used: 0.11GB (21%) fs: swap 
RAID:      No RAID devices detected - /proc/mdstat and md_mod kernel raid module present
Sensors:   None detected - is lm-sensors installed and configured?
Info:      Processes: 171 Uptime: 8:46 Memory: 301.2/1002.2MB Client: Shell (bash) inxi: 1.9.12 
root@babu-VirtualBox:~#

TBD/Advanced/Detailed
lshw, lspci, lsblk, lsusb, lsscsi, lshal, lsraid, lsdev, hwinfo, dmidecode, hdparm, biosdecode



No comments:

UA-48797665-1