如何获取 Linux 发行版名称和版本? [英] How to get Linux distribution name and version?

查看:29
本文介绍了如何获取 Linux 发行版名称和版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 中,我读取注册表项 SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName 以获取操作系统的完整名称和版本.

In Windows I read the registry key SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName to get the full name and version of the OS.

但在 Linux 中,代码

But in Linux, the code

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

返回字符串 linux,而不是 Ubuntu 9.04.

returns the string linux, not Ubuntu 9.04.

如何获取 Linux 发行版名称和版本?

How can I get the Linux distribution name and version?

推荐答案

尝试:

cat /etc/lsb-release

你也可以试试

lsb_release -a

或者:

cat /proc/version

这篇关于如何获取 Linux 发行版名称和版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆