我想使用python在linux中检测一个人的发行版,我想根据发行版做不同的事情,我不知道在哪里可以找到这样的列表,我用谷歌搜索了它,但什么也没找到,我也跑了,man lsb_release
但我得到了那里什么都没有,也许有人知道我在哪里可以找到这样的清单?
user14842316
问问题
70 次
1 回答
0
lsb_release
是一个外壳脚本:
$ file $(command -v lsb_release )
/usr/bin/lsb_release: a /usr/bin/sh script, ASCII text executable
所以你可以在你的编辑器中打开它,看看它做了什么。
我想根据发行版做不同的事情,但我不知道在哪里可以找到这样的列表
我不认为这样的列表存在,lsb_release
只是读取
/etc/lsb-release
或本地/etc/[distro]-release
文件,正如评论中所说:
# Description:
# Collect informations from sourceable /etc/lsb-release file (present on
# LSB-compliant systems) : LSB_VERSION, DISTRIB_ID, DISTRIB_RELEASE,
# DISTRIB_CODENAME, DISTRIB_DESCRIPTION (all optional).
# Then (if needed) find and parse the /etc/[distro]-release file.
例如,在我的 Slackware 系统上它会读取/etc/lsb-release
,而在 Fedora 上它会读取/etc/redhat-release
,因此您输入的任何信息都会被报告。
于 2021-03-13T23:37:57.857 回答