Linux ist extrem weit verbreitet. Fast jedes Gerät mit einem Netzwerkanschluss hat meist irgendeine Form von Linux enthalten. Wenn man nun per Telnet oder SSH vor einer Konsole sitzt, stellt sich oft die Frage, mit was man es zu tun hat. In Windows würde man
C:>systeminfo|findstr /C:"Betriebs" /C:"OS" /C:"System"
Betriebssystemname: Microsoft Windows 10 Pro
Betriebssystemversion: 10.0.14393 Nicht zutreffend Build 14393
Betriebssystemhersteller: Microsoft Corporation
Betriebssystemkonfiguration: Eigenst?ndige Arbeitsstation
Betriebssystem-Buildtyp: Multiprocessor Free
Systemstartzeit: 04.08.2016, 19:43:55
Systemhersteller: Microsoft Corporation
Systemmodell: Virtual Machine
Systemtyp: x64-based PC
BIOS-Version: Microsoft Corporation Hyper-V UEFI Release v1.0, 26.11.2012
System-Verzeichnis: C:\Windows\system32
Systemgebietsschema: de;Deutsch (Deutschland)
aufrufen um zu wissen wo man sich befindet. In Linux ist dies nicht so einfach. Je nach Distribution gibt es unterschiedliche Wege die Versionen zu ermitteln aber es gibt dennoch ein paar Stellen, wo man es herausfinden kann.
Die meisten Linuxdistributionen speichern Infos in der issue-Datei im etc-Verzeichnis, welche mit cat ausgeben kann:
cat /etc/issue
Ubuntu 14.04.5 LTS \n \l
Damit ist bereits die grobe Richtung bekannt. Bei einem Raspberry Pi sieht die Sache so aus:
cat /etc/issue
Raspbian GNU/Linux 8 \n \l
Hier fangen die Schwierigkeiten mit Linux und den Distributionen an. Denn es gibt so viele unterschiedliche Distributionen. Hier ein weiteres Beispiel:
cat /etc/issue
vuplus 3.0.0 \n \l
In diesem Fall weiß ich, dass ich auf einer Vu+, einem Mediaplayer unterwegs bin. OK, vuplus ist eine eigene Distribution aber um weitere Möglichkeiten besser einschätzen zu können, wäre es wichtig die verwendete Linuxversion bzw. Kernelversion herauszufinden. Hierzu kann man /proc/version abfragen:
Unter Ubuntu liefert dies z. B.:
cat /proc/version
Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
und unter dem Pi:
cat /proc/version
Linux version 4.1.19-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #858 SMP Tue Mar 15 15:56:00 GMT 2016
und unter der Vu+:
cat /proc/version
Linux version 3.13.5 (plnick@build-plnick) (gcc version 4.9.2 (GCC) ) #1 SMP Tue
Jan 19 02:38:57 CET 2016
OK die Vu+ verwendet Kernel 3.13.5, die Ubuntuvariante 3.4.0 jedoch, hier muss ich sagen ist es keine normale Ubuntuvariante sondern die vom Windows Subsystem for Linux (WSL) die seit Windows 10 v1607 verfügbar ist
. Wobei man hier nicht von Kernel sprechen darf, da es bei WSL keinen Linux-Kernel gibt sondern die Syscalls auf den NT-Kernel, also Windows-Kernel abgebildet werden.
Ein richtiges Ubuntu würde sich so melden:
Linux version 4.2.0—27—generic (buildd@lcy01—23) (gcc version
4.8.2 (Ubuntu 4.8.2—19ubuntu1) ) #32~14.04.1—Ubuntu SMP
Fri Jan 22 15:32:26 UTC 16
Neben diesen Informationen wäre es ganz gut zu wissen, auf welcher Plattform bzw Architektur man sich befindet, dazu kann man uname verwenden:
uname -a
Linux vuzero 3.13.5 #1 SMP Tue Jan 19 02:38:57 CET 2016 mips GNU/Linux
bzw auf Ubuntu:
uname -a
Linux DESKTOP-FJE246N 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux
Der Pi:
uname -a
Linux raspberrypi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux
Bei der Vu+ haben wir es also mit einem Mips-System zu tun, beim Pi mit ARM und bei der Ubuntugeschichte mit einem üblichen Intel x64-System.
Um die wesentlichen Informationen einfacher lesen zu können, kann man auch diese Variante benutzen:
uname -m
Damit bekommt man direkt armv7l, mips, 32 oder 64 zurück.
Jede Distribution speichert im /etc-Verzeichnis Infos über sich ab. Man muss in der Regel nur nach Dateien mit der Endung release, info oder version suchen, man kann dies praktischerweise in einen Einzeiler packen:
ls /etc/*version /etc/*release /etc/*info
Wie diese Seite http://www.sysadminslife.com/linux/quicktipp-installierte-linux-distribution-anzeigen-und-version-herausfinden/ aufzeigt, verwenden die meisten Distributionen die Endung version oder release.
Bei unserem Dreiklang sehen die Ausgaben wie folgt aus, zunächst der Raspberry:
ls /etc/*version /etc/*release /etc/*info
/etc/debian_version /etc/os-release
/etc/terminfo:
README
cat /etc/debian_version
8.0
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL=http://www.raspbian.org/RaspbianBugs
Nun die WSL-Ubuntu-Variante:
ls /etc/*version /etc/*release /etc/*info
/etc/debian_version /etc/ec2_version /etc/lsb-release /etc/os-release
/etc/terminfo:
README
cat /etc/debian_version
jessie/sid
cat /etc/ec2_version
Ubuntu 14.04 LTS (Trusty Tahr)
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
cat /etc/os-release
NAME="Ubuntu"
VERSION="14.04.5 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.5 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL=http://bugs.launchpad.net/ubuntu/
Nun die Vu+:
ls /etc/*version /etc/*release /etc/*info
ls: /etc/*release: No such file or directory
/etc/image-version /etc/version /etc/vtiversion.info
/etc/terminfo:
a d l r s v x
cat /etc/image-version
version=0903201605170204
creator=VTi <info@vuplus-support.org>
url=http://www.vuplus-support.org/
cat /etc/version
201605170159
cat /etc/vtiversion.info
VTi-Team Image Release v.9.0.3
Über diese Informationen erhält man also oftmals auch URLs um weitere Informationen zu erhalten.
Beim Raspberry mit seinem Raspbian weiß man nun also, dass man es mit einem Debian 8 (Jessie) zu tun hat, auch Ubuntu basiert auf Debian. Leider sind solche Infos bei der Vu+ nicht zu erhalten. Hier erhält man nur die Information, dass VTi in Version 9.0.3 vom 9.3.2016 installiert ist.
Neben der Software spielt natürlich auch die Hardware eine Rolle. Welchen Prozessor hat man konkret vor sich. Hier hilft /proc/cpuinfo
Die Vu+:
cat /proc/cpuinfo
system type : BCM7362A0 STB platform
machine : Unknown
processor : 0
cpu model : Broadcom BMIPS4380 V6.5 FPU V0.1
BogoMIPS : 749.56
cpu MHz : 751.518
wait instruction : yes
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : no
isa : mips1 mips2 mips32r1
ASEs implemented : mips16
shadow register sets : 1
kscratch registers : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
processor : 1
cpu model : Broadcom BMIPS4380 V6.5 FPU V0.1
BogoMIPS : 753.66
cpu MHz : 751.518
wait instruction : yes
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : yes
hardware watchpoint : no
isa : mips1 mips2 mips32r1
ASEs implemented : mips16
shadow register sets : 1
kscratch registers : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
beim Pi:
cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
processor : 1
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
processor : 2
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
processor : 3
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
Hardware : BCM2709
Revision : a01041
Serial : 00AAAAAAAAAAAAAA
und noch Ubuntu:
cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 78
model name : Intel(R) Core(TM) i5-6260U CPU @ 1.80GHz
stepping : 3
microcode : 0xffffffff
cpu MHz : 1800.000
cache size : 256 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 6
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 ss ht syscall nx pdpe1gb rdtscp lm pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave osxsave avx f16c rdrand hypervisor
bogomips : 3600.00
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 : 78
model name : Intel(R) Core(TM) i5-6260U CPU @ 1.80GHz
stepping : 3
microcode : 0xffffffff
cpu MHz : 1800.000
cache size : 256 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 6
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 ss ht syscall nx pdpe1gb rdtscp lm pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave osxsave avx f16c rdrand hypervisor
bogomips : 3600.00
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
Bei so vielen Infos macht es evtl. noch Sinn nach dem Speicher zu fragen, den Arbeitsspeicher bekommt man mittels free –h und den Plattenplatz mittels df –h.
Bei ARM kommt in Zukunft sicher noch die Frage nach 32-Bit oder 64-Bit Prozessor. Der Raspberry z. B. ist noch 32-Bit ein armv8 wäre 64-Bit. http://unix.stackexchange.com/questions/136407/is-my-linux-arm-32-or-64-bit.
Weitere Infos zum Thema kann man hier finden: http://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script.