May 26, 2007

获取Linux版本信息

  //很多时候这是很必要的


1) lsb_release -a ,即可列出所有版本信息,适用于所有的linux,例如:
ox0spy@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 6.06.1 LTS
Release: 6.06
Codename: dapper
ox0spy@ubuntu:~$

2) cat /etc/redhat-release ,

这种方式下可以直接看到具体的版本号,比如 AS4 Update 1

3)rpm -q redhat-release ,

 这种方式下可看到一个所谓的release号,比如上边的例子是2.4

 这个release号和实际的版本之间存在一定的对应关系,如下:

  redhat-release-3AS-1 -> Redhat Enterprise Linux AS 3

  redhat-release-3AS-7.4 -> Redhat Enterprise Linux AS 3 Update 4

  redhat-release-4AS-2 -> Redhat Enterprise Linux AS 4

  redhat-release-4AS-2.4 -> Redhat Enterprise Linux AS 4 Update 1

  redhat-release-4AS-3 -> Redhat Enterprise Linux AS 4 Update 2

  redhat-release-4AS-4.1 -> Redhat Enterprise Linux AS 4 Update 3

  redhat-release-4AS-5.5 -> Redhat Enterprise Linux AS 4 Update 4

4) cat /etc/issue
Fedora Core release 4 (Stentz)
Kernel r on an m

5) 内核版本,cat /proc/version,例如:
ox0spy@ubuntu:~$ cat /proc/version
Linux version 2.6.15-26-server (buildd@terranova) (gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)) #1 SMP Thu Aug 3 04:09:15 UTC 2006

注意:第(2)(3)两种方法只对Redhat Linux有效

No comments:

Post a Comment

您的评论将使我blog更有动力~