如何在node.js中区分不同的操作系统发行版? [英] How to distinguish between different operating system distros in node.js?

查看:114
本文介绍了如何在node.js中区分不同的操作系统发行版?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在节点中,您可以访问 process.os() process.platform ,它为您提供5个值之一:

In node you have access to process.os() and process.platform, which give you one of 5 values:

'darwin'
'freebsd'
'linux'
'sunos'
'win32'

但是您如何打印特定发行版,例如其中之一?

But how do you print out the specific distro, such as one of these?

http://en.wikipedia.org/wiki/List_of_Linux_distributions

'ubuntu'
'gentoo'
'fedora'
'SUSE Linux'
'CentOS'
dozens/hundreds more

如果没有标准方法,是否有当前的首选解决方案?主要地,这对于能够(以编程方式)辨别ubuntu与其他一些流行的EC2图像ose之间的区别很有用.

If there is no standard approach, is there any current preferred solution out there? Mainly this would be useful for being able to tell the difference (programmatically) between ubuntu and some of the other popular EC2 image oses.

推荐答案

总结所有响应:没有简单的方法来确定当前的Linux发行版.

To summarize all the responses: There is no easy way to determine the current Linux distribution.

不过,您可以从这里开始.

However here are a few thing you could start with.

  • uname -v 通常为您提供带有一些信息的长字符串.(例如:#66-Ubuntu SMP Thu Apr 25 03:27:11 UTC 2013 )
  • Debian /etc/debian_version ,但这也是在Ubuntu中设置的!
  • Ubuntu:/etc/lsb-release /etc/os-release
  • SuSe:/etc/SuSE-release
  • 许多发行版还写入/etc/issue
  • uname -v usually gives you a long string with some informations. (E.g.: #66-Ubuntu SMP Thu Apr 25 03:27:11 UTC 2013)
  • Debian /etc/debian_version, but this is set in Ubuntu, too!
  • Ubuntu: /etc/lsb-release and /etc/os-release
  • SuSe: /etc/SuSE-release
  • Many distros also write to /etc/issue

如果您有可能发生的可能分布的列表,则应该能够以某种方式获得该信息.如果您想要通用的方法,我猜不会有绝对的答案.

If you have a list of possible distributions that could happen, you should be able to get that information somehow. If you want a generic approach I'll guess there will be no absolute answer.

这篇关于如何在node.js中区分不同的操作系统发行版?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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