写在前面
今天部署项目的时候需要在服务器安装 nodeJS,因为不知道服务器 linux 系统的具体类型,所以不知道采用哪种方式安装最简便。然后就有了下面这篇 blog ( ̄▽ ̄)~*
方法一
# lsb_release -a
该命令适用于所有遵守 LSB 规范的 linux,包括Redhat、SuSE、Debian、Ubuntu、Centos等发行版。
1 | LSB Version: :core-4.1-amd64:core-4.1-noarch |
接下来的命令虽然不能查看当前系统名和版本,但是可以显示系统核心信息.
# uname linux# uname -r 3.10.0-693.2.2.el7.x86_64# uname -a Linux iz2zeehaoxba5ca8lcw79yz 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
方法二
适用于 Redhat CentOS
# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
登录到 linux 执行
# rpm -q redhat-release package redhat-release is not installed (当前系统是 CentOS)
登录到 CentOS 执行
# rpm -q centos-release centos-release-7-4.1708.el7.centos.x86_64
方法三
当前 CentOS 版本与 Redhat 对应的版本的命令,这个命令在 CentOS 下并不准确,显示的系统和版本也是Redhat
# cat /proc/version Linux version 3.10.0-693.2.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Tue Sep 12 22:26:13 UTC 2017
在 Ubuntu 上使用能看出是 Ubuntu 系统,但看不出版本
方法四
#cat /etc/issue
在 CentOS 下执行显示
1 | \S |
在 Ubuntu 下执行显示
1 | Ubuntu 11.04 \n \l |