/etc/lsb-release与/etc/os-release [英] /etc/lsb-release vs /etc/os-release

查看:96
本文介绍了/etc/lsb-release与/etc/os-release的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用bash找出正在运行的Linux发行版.在此页面中找到了,这非常有帮助./p>

但是我的系统有两个/etc/*-release文件

 /etc/lsb-发行版/etc/os-release 

os-release 似乎有更多信息,但是看起来这两个文件本质上都在做同样的事情.有谁知道他们之间有什么区别?在我们讨论的同时, lsb-release 中的 lsb 代表什么?

解决方案

/etc/lsb-release 文件是一些(但不是全部)Linux发行版中存放的文件,用于较旧的程序可以用."lsb"是指Linux Standard Base,该项目致力于为所有Linux发行版(包括文件系统布局之类的东西)定义一套通用的标准.但是,该文件/etc/lsb-release 不是标准的一部分.有些发行版使用的是额外的东西,但不是全部.

然而,/etc/os-release 文件.必须具有该systemd的任何基于systemd的发行版,包括Red Hat Enterprise Linux,CentOS,Fedora,Gentoo,Debian,Mint,Ubuntu和许多其他发行版.不使用systemd的发行版也可能包含该文件.

如果您需要一种可靠的方式来检测正在运行的发行版,那么最好的选择是阅读/etc/os-release文件.如果不存在,您可以尝试运行名为 lsb_release 的程序.但是只需忽略/etc/lsb-release 文件.

您可以在此处上阅读有关os-release的更多信息此处.只是为了好玩,看看Linux发行版使用的所有不同的文件使用!

I needed to find out what Linux distro I'm running by using bash. Found this page, which was very helpful.

However my system has two /etc/*-release files

/etc/lsb-release
/etc/os-release

It seems os-release has a little more info, but it looks that both of these files essentially do the same thing. Does anyone know what is the difference between them? While we are at it, what does lsb in lsb-release stand for?

解决方案

The /etc/lsb-release file is a file that some, but not all, Linux distributions put there for older programs to use. The "lsb" refers to the Linux Standard Base, a project working to define a common set of standards for any Linux distribution to follow, including things like filesystem layout. However, that file, /etc/lsb-release, isn't part of the standard. It's an extra thing that some distributions use, but not all.

The /etc/os-release file is the standard, however. Any distribution based on systemd, including Red Hat Enterprise Linux, CentOS, Fedora, Gentoo, Debian, Mint, Ubuntu, and many others, is required to have that file. Distributions that don't use systemd may also have the file.

If you need a reliable way of detecting what distribution you're running on, your best bet will be to read the /etc/os-release file. If it's not there you can try running the program called lsb_release. But just ignore the /etc/lsb-release file.

You can read more about os-release here and here. And just for fun, take a look at all the different files that Linux distributions used to use!

这篇关于/etc/lsb-release与/etc/os-release的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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