In Windows I read the registry key SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName
to get the full name and version of the OS.
But in Linux, th
What's the purpose of getting that information?
If you're trying to detect some features or properties of the system (e.g. does it support some syscall or does it have some library), instead of relying on output of lsb_release you should either:
Note that the first way above applies even if your software is binary-only.
Some code examples:
dl = dlopen(module_path, RTLD_LAZY);
if (!dl) {
fprintf(stderr, "Failed to open module: %s\n", module_path);
return;
}
funcptr = dlsym(dl, module_function);
if (!funcptr) {
fprintf(stderr, "Failed to find symbol: %s\n", module_function);
return;
}
funcptr();
dlclose(dl);
You can even gracefully test for CPU opcodes support, read e.g. http://neugierig.org/software/chromium/notes/2009/12/flash-lahf.html , http://code.google.com/p/chromium/issues/detail?id=29789
/etc/os-release is available on at least both CentOS 7 and Ubuntu 16.04, which makes it more cross-platform than lsb_release
(not on CentOS) or /etc/system-release
(not on Ubuntu).
$ cat /etc/os-release
Example:
NAME=Fedora
VERSION="17 (Beefy Miracle)"
ID=fedora
VERSION_ID=17
PRETTY_NAME="Fedora 17 (Beefy Miracle)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:17"
HOME_URL="https://fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
cat release file to display Linux distro version
$ cat /etc/*-release
lsb_release will return Linux distribution name and version
$ lsb_release -a
hostnamectl will return Linux distribution name and version
$ hostnamectl
To print certain system information
$ uname -a
or
-s, --kernel-name print the kernel name
-n, --nodename print the network node hostname
-r, --kernel-release print the kernel release
-v, --kernel-version print the kernel version
-m, --machine print the machine hardware name
-p, --processor print the processor type (non-portable)
-i, --hardware-platform print the hardware platform (non-portable)
-o, --operating-system print the operating system
To find out Static hostname, Chassis, Mchine ID, Virtualization, OS, Kernel, Architecture
$ cat /proc/version
Not sure I followed exactly what you're after but I think you just want the "all" flag on uname:
uname -a
Usually:
cat /etc/issue
lsb_release -ds ; uname -mr
on my system yields the following from the bash (terminal) prompt:
Ubuntu 10.04.4 LTS
2.6.32-41-generic x86_64