大网数据广告活动
服务器运维问答

How to detect linux distribution and version?

· 52CE 我爱测

I want to detect linux distribution and version. I searched with my favorite search engine and discovered lsb_release . Unfortunately this tool is not installed by default. I would like to avoid to install lsb_release first. Is t…

问题原文

原帖链接 · guettli · CC BY-SA 3.0

I want to detect linux distribution and version.

I searched with my favorite search engine and discovered lsb_release.

Unfortunately this tool is not installed by default.

I would like to avoid to install lsb_release first.

Is there no easier way to detect the linux distribution and version in a portable way?

With "portable" I mean different kind of linux distributions. Not *BSD or Windows.

社区高分解答

原帖链接 · Jan Grewe · CC BY-SA 3.0

Pick one...

cat /etc/issue
source /etc/os-release && echo "$NAME $VERSION"
cat /etc/os-release
uname -a

I guess most modern and LSB compliant distributions should provide /etc/os-release, but as usual: it's complicated! ;-)

Some further reading material:

https://en.wikipedia.org/wiki/Linux_Standard_Base

http://0pointer.de/blog/projects/os-release.html

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。