|
摘要
linux uname命令参数及用法详解(linux查看系统信息命令)
uname 是Linux命令用途显示当前操作系统名称。语法uname -a | -x | -S Name -F -f -l -L -m -M -n -p -r -s -T Name -u -v 描述uname 命令将正在使用的操作系统名写到标准输出中
uname 命令可用于大多数 UNIX 和类 UNIX 系统以及 Linux。 几个使用示例(资料来自jb51.net): [root@jb51.net ~]# uname Linux 注:单独使用uname命令时相当于uname -s [root@jb51.net ~]# uname -a Linux jb51.net 2.6.18-4-686 #1 SMP Mon Mar 26 17:17:36 UTC 2007 i686 GNU/Linux [root@jb51.net ~]# uname -m i686 [root@jb51.net ~]# uname -n jb51.net [root@jb51.net ~]# uname -r 2.6.18-4-686 [root@jb51.net ~]# uname -s Linux [root@jb51.net ~]# uname -v #1 SMP Mon Mar 26 17:17:36 UTC 2007 [root@jb51.net ~]# uname -p i686 [root@jb51.net ~]# uname -i i386 [root@jb51.net ~]# uname -o GNU/Linux [root@jb51.net ~]# uname --version //两个- uname (GNU coreutils) 5.97 Copyright (C) 2006 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. Written by David MacKenzie.
推荐阅读 Linux uname函数调用 资料收集
struct utsname {
char sysname[_UTSNAME_SYSNAME_LENGTH];//当前操作系统名
char nodename[_UTSNAME_NODENAME_LENGTH];//网络上的名称
char release[_UTSNAME_RELEASE_LENGTH];//当前发布级别
char version[_UTSNAME_VERSION_LENGTH];//当前发布版本
char machine[_UTSNAME_MACHINE_LENGTH];//当前硬件体系类型
#if _UTSNAME_DOMAIN_LENGTH - 0
/* Name of the domain of this node on the network. */
# ifdef __USE_GNU
char domainname[_UTSNAME_DOMAIN_LENGTH]; //当前域名
# else
char __domainname[_UTSNAME_DOMAIN_LENGTH];
# endif
#endif
};
返回说明:
#include <sys/utsname.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
struct utsname testbuff;
int fb=0;
fb=uname(&testbuff);
if(fb<0)
{
perror("uname");
return 0;
}else
{
printf(" sysname:%s\n nodename:%s\n release:%s\n version:%s\n machine:%s\n \n ",\
testbuff.sysname,\
testbuff.nodename,\
testbuff.release,\
testbuff.version,\
testbuff.machine);
#if _UTSNAME_DOMAIN_LENGTH - 0
# ifdef __USE_GNU
printf(" domainame:%s\n ",testbuff.domainname);
//char domainname[_UTSNAME_DOMAIN_LENGTH]; //当前域名
# else
printf(" __domainame:%s\n ",testbuff.__domainname);
//char __domainname[_UTSNAME_DOMAIN_LENGTH];
# endif
#endif
}
return 0;
}
(责任编辑:IT) |
