14

I have a number of distros I'm playing with. I label the SD cards, but:

  1. They are in upside down
  2. I'm usually in another room from the RPi

I set up a service in init.d which lets me know via Pushover when my Pi is shutting down or starting up (using the API via curl).

I'd like this to include which distro I'm currently using.

I can see on my latest boot (playing with adafruit Raspbian):

Linux raspberrypi 3.1.9adafruit+ #8 PREEMPT Wed Aug 1 18:02:42 EDT 2012 armv6l

How can I get that information to include in my script?

I installed lsb-release, but that only gives me this:

pi@raspberrypi / $ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux testing/unstable
Release:    testing/unstable
Codename:   n/a

Which would look the same as my regular Raspbian.

In addition, I would probably like to indicate something myself about the particular instance on the SD card (since I'll probably have multiple of the same base distro). Obviously, I can just drop a file in the same place on each SD-card, but is there a convention for where to put that kind of information?

Cade Roux
  • 2,117
  • 5
  • 23
  • 27

3 Answers3

10

Try

cat /etc/*-release

On my desktop, it gives

NAME="Arch Linux"
ID=arch
PRETTY_NAME="Arch Linux"
ANSI_COLOR="0;36"
HOME_URL="https://www.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"

Having checked the official Raspberry Pi images (Raspbian and Arch), /etc/os-release is available on both and contains at least the NAME and PRETTY_NAME properties.

How do I extract the distribution's name?

That's quite simple, try

$ cat /etc/os-release | perl -n -e '/^NAME=\"([a-zA-Z ]*)\"$/ && print "$1\n"'
Arch Linux

References

  1. HowTo: Find Out My Linux Distribution Name and Version
Alex Chamberlain
  • 15,638
  • 15
  • 69
  • 113
8
$ uname -a
Linux raspberrypi 3.1.9+ #174 PREEMPT Sun Jul 22 19:04:28 BST 2012 armv6l GNU/Linux
John La Rooy
  • 12,005
  • 9
  • 48
  • 77
4

As pointed out, you can use uname, but this will only show the kernel version. If you have the same kernel version on a couple of different distributions/cards (which is very likely since a couple of them are using the same foundation kernel), you will get the same result for each of them. So the best way to differentiate between distros is to use something other than the kernel. There is no universal way however. One easy way would be to use the hostname (and change it for every distro).

cat /proc/version /proc/sys/kernel/hostname

or

hostname && uname -a

tlhIngan
  • 3,372
  • 5
  • 21
  • 33
Krzysztof Adamski
  • 9,605
  • 1
  • 38
  • 53