Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Linux distribution name and version?

Tags:

c++

c

linux

api

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, the code

struct utsname ver;
uname(&ver);
retVal = ver.sysname;

returns the string linux, not Ubuntu 9.04.

How can I get the Linux distribution name and version?

like image 847
Dmitriy Avatar asked Aug 24 '09 03:08

Dmitriy


People also ask

How do I find the Linux version?

The uname and /etc/os-release commands are the most common methods for getting the version of Linux you're running and are available by default on any Linux system you run.

What is distribution version in Linux?

A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that includes the Linux kernel and, often, a package management system.


1 Answers

Try:

cat /etc/lsb-release

You can also try

lsb_release -a

Or:

cat /proc/version
like image 176
thekidder Avatar answered Nov 06 '22 06:11

thekidder