Sample Header Ad - 728x90

Get the hardware model name in linux

5 votes
2 answers
8320 views
I am writing an application that works like Neofetch when a -w option is passed. It shows some of the the system information like memory, swap, cpu, battery usages, hostname, local ip, kernel version etc. I am wondering how to get the "Host" like in Neofetch. For example:
-`                    sourav@archlinux-arm 
                  .o+`                   -------------------- 
                 `ooo/                   OS: Arch Linux armv7l 
                `+oooo:                  Host: Raspberry Pi 3 Model B Rev 1.2 
               `+oooooo:                 Kernel: 4.19.108-1-ARCH 
               -+oooooo+:                Uptime: 10 mins 
             `/:-:++oooo+:               Packages: 804 (pacman) 
            `/++++/+++++++:              Shell: bash 5.0.16 
           `/++++++++++++++:             Resolution: 1366x768 
          /+++ooooooooooooo/           DE: Xfce 
         ./ooosssso++osssssso+`          WM: Xfwm4 
        .oossssso-
/ossssss+ WM Theme: XFCE_Colour_Lite_Pink -osssssso. :ssssssso. Theme: XFCE_Colour_Lite_Pink [GTK2], X :osssssss/ osssso+++. Icons: Papirus [GTK2], Tela-orange [GT /ossssssss/ +ssssooo/- Terminal: tilix `/ossssso+/:- -:/+osssso+- CPU: BCM2835 (4) @ 1.350GHz +sso+:- `.-/+oso: Memory: 333MiB / 901MiB ++:. -/+/ . /
I get an information like this.
On my laptop:
-` sourav@archlinux .o+` ---------------- `ooo/ OS: Arch Linux x86_64 `+oooo: Host: Inspiron 5567 `+oooooo: Kernel: 5.5.10-arch1-1 -+oooooo+: Uptime: 3 hours `/:-:++oooo+: Packages: 1163 (pacman) `/++++/+++++++: Shell: bash 5.0.16 `/++++++++++++++: Resolution: 1920x1080 /+++ooooooooooooo/ DE: Xfce ./ooosssso++osssssso+` WM: Xfwm4 .oossssso-
/ossssss+         WM Theme: XFCE_Colour_Lite_Ruby 
       -osssssso.      :ssssssso.        Theme: XFCE_Colour_Lite_Purple [GTK2 
      :osssssss/        osssso+++.       Icons: Papirus [GTK2/3] 
     /ossssssss/        +ssssooo/-       Terminal: tilix 
   `/ossssso+/:-        -:/+osssso+-     CPU: Intel i3-6006U (4) @ 2.000GHz 
  +sso+:-                 `.-/+oso:    GPU: Intel Skylake GT2 HD Graphics  
 ++:.                           -/+/   Memory: 2814MiB / 3755MiB 
 .                                 /
My question is related to [this question , but it doesn't answer my question because my raspberry pi can't run dmidecode, (no /sys/devices/virtual/dmi/ either), no lshw installed. Also, the /etc/hostname are not the computers' model name, instead they are just *archlinux-arm* and *archlinux*. The uname -a or cat /proc/version doesn't have the '*Rapsberry Pi*' string on the raspberry pi. Is there a way to get the hardware name like neofetch without using any dependency which should also run on most hardware?
Asked by 15 Volts (2149 rep)
Mar 25, 2020, 06:34 AM
Last activity: Mar 26, 2020, 01:01 AM