9

Users often seem confused about what Pi model they have and what OS version is installed or how to find details.

Where is this located?

3

2 Answers 2

21

The following script is one I use including the following commands to collect relevant details. (It is called aboutpi)

Download latest from https://github.com/Milliways2/Raspberry-Pi-Utilities/blob/main/aboutpi

#! /bin/sh
# 2024-01-30    No LSB modules are available.
# Function to print coloured headings
#  delete "tput" lines for plain output
print_head () {
 tput setaf 6
 echo $1
 tput sgr 0
}

if [ -e /etc/rpi-issue ]; then
 print_head "- Original Installation"
 cat /etc/rpi-issue | grep reference
fi

if [ -e /usr/bin/lsb_release ]; then
 print_head "- Current OS"
 lsb_release -irdc | sed 's/No LSB modules are available.//'
 cat /etc/debian_version
fi
if [ ! -e /usr/share/xsessions ]; then
    print_head "X NOT installed"
fi
print_head "- Kernel"
uname -r
print_head "- Architecture"
uname -m

print_head "- Model"
cat /proc/device-tree/model && echo

print_head "- hostname"
hostname
print_head "- Network"
hostname -I

# Check status of networking
checkactive () {
if [ $(systemctl is-active $1) = 'active' ]; then
    echo $1 'active'
fi
}
checkactive 'systemd-networkd'
checkactive 'dhcpcd'
checkactive 'NetworkManager'

# Get SSID of connected WiFi (WRONG if AP!)
if [ -e /sys/class/net/wlan0 ]; then
    if [ $(systemctl is-active 'NetworkManager') = 'active' ]; then
        nmcli connection show |  awk '/wlan0/ {print $1}'
    else
        wpa_cli -i wlan0 status | grep -w ssid | awk -F'[=]' '{print $2}'
    fi
fi

sudo fdisk -l /dev/mmcblk0 | grep "Disk identifier"

CPUID=$(awk '/Serial/ {print $3}' /proc/cpuinfo | cut -c 9-)
# CPUID=$(vcgencmd otp_dump | grep 28: | cut -c4-)
echo "Serial: " $CPUID
if [ -e /opt/vc/bin/vcgencmd -o /usr/bin/vcgencmd ]; then
#   VERS=$(vcgencmd version  | grep ":")
    VERS=$(sudo vcgencmd version  | grep ":")
    print_head "- Firmware"
    echo $VERS
fi
print_head "- Created"
sudo tune2fs -l $(mount -v | awk '/ on \/ / {print $1}') | grep created

To list the initial installation (Raspbian only) cat /etc/rpi-issue | grep reference

Raspberry Pi reference 2019-06-20

To list the Current OS lsb_release -irdc

Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster

To list the Kernel version uname -r

4.19.58-v7l+

To list the Model cat /proc/device-tree/model

Raspberry Pi 4 Model B Rev 1.1

There are a number of other interesting data:-

To list the hostname hostname

MilliwaysPi4

To list the Firmware /opt/vc/bin/vcgencmd version

Jul  9 2019 14:37:58 
Copyright (c) 2012 Broadcom
version d2b1b7fb01475cb3914b2086299e32d724e832f1 (clean) (release) (start)

To list the date the File System was "created" sudo tune2fs -l /dev/mmcblk0p2 | grep created (only for Raspbian on SD Card, but could be modified for other)

Filesystem created:       Fri Jun 21 03:05:22 2019

Output on Raspberry Pi OS (64bit) Pi4B

- Original Installation
Raspberry Pi reference 2022-01-28
- Current OS
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:    11
Codename:   bullseye
11.7
- Kernel
6.1.21-v8+
- Architecture
aarch64
- Model
Raspberry Pi 4 Model B Rev 1.1
- hostname
MilliwaysPi4
- Network
10.1.2.74 10.1.2.84 
NetworkManager active
WiFi-B13A
Disk identifier: 0x2f89a8c6
Serial:  46c9fdae
- Firmware
Mar 17 2023 10:50:39
- Created
Filesystem created:       Fri Jan 20 12:46:02 2023

Output on Raspberry Pi OS Pi3B

- Original Installation
Raspberry Pi reference 2021-10-30
- Current OS
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:    11
Codename:   bullseye
11.6
- Kernel
6.1.21-v7+
- Architecture
armv7l
- Model
Raspberry Pi 3 Model B Plus Rev 1.3
- hostname
MilliwaysPi3p
- Network
10.1.2.88 
dhcpcd active
WiFi-B13A-5G
Disk identifier: 0xff635d64
Serial:  519c72e8
- Firmware
Mar 17 2023 10:52:42
- Created
Filesystem created:       Sun Jan 29 12:34:01 2023

The output on my Pi3A+ shows

- Original Installation
Raspberry Pi reference 2021-10-30
- Current OS
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:    11
Codename:   bullseye
11.6
X NOT installed
- Kernel
6.1.21-v7+
- Architecture
armv7l
- Model
Raspberry Pi 3 Model A Plus Rev 1.0
- hostname
MilliwaysPi3A
- Network
10.1.2.93 
systemd-networkd active
WiFi-B13A
Disk identifier: 0xb5d2de0f
Serial:  f4e430a6
- Firmware
Mar 17 2023 10:52:42
- Created
Filesystem created:       Sat Aug  8 04:32:43 2020
1
  • Reminds me of the old SysInternals windows program bginfo - tempted to create a little Python program to hack the desktop :-). Bookmarked.
    – user115418
    Mar 24, 2020 at 15:02
3

A "quick and dirty" answer to the question follows. All can be entered from the command line interface:

  1. cat /etc/os-release # provides NAMES, VERSIONS & some URLs for support

  2. lsb_release -a # distribution-specific information; ref man lsb_release

  3. hostnamectl # brief & useful incl hostname, OS ver, kernel ver; ref man hostnamectl

And as if you needed more, this command provides a terse summary with several options to get a specific item - which is useful in scripts to check version dependencies, etc. See man uname for details, and for example, the kernel version can be had as follows:

  1. uname -r

Credits to nixCraft for the most complete answer I could find.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.