- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
linux uname函数及命令的使用方法
【uname系统调用】
功能描述:
获取当前内核名称和其它信息。
用法:
#include sys/utsname.h
/* Put information about the system in NAME. */
extern int uname (struct utsname *__name) __THROW;
参数:
__name:指向存放系统信息的缓冲区,原型如下
/* Structure describing the system and machine. */
struct utsname
{
/* Name of the implementation of the operating system. */
char sysname[_UTSNAME_SYSNAME_LENGTH]; //当前操作系统名
/* Name of this node on the network. */
char nodename[_UTSNAME_NODENAME_LENGTH]; //网络上的名称
/* Current release level of this implementation. */
char release[_UTSNAME_RELEASE_LENGTH]; //当前发布级别
/* Current version level of this release. */
char version[_UTSNAME_VERSION_LENGTH]; //当前发布版本
/* Name of the hardware type the system is running on. */
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
};
返回说明:
成功执行时,返回0。失败返回-1,errno被设为EFAULT,表示buf无效。
关于uname的具体用法可以使用“man uname”来查看。
实例如下:
#include sys/utsname.h
#include stdio.h
#include stdlib.h
int main()
{
struct utsname testbuff;
int fb=0;
fb=uname(testbuff);
if(fb0)
{
perror(uname);
return 0;
}else
{
printf( sysname:%s nodename:%s release:%s version:%s machine:%s ,
testbuff.sysname,
testbuff.nodename,
testbuff.release,
testbuff.version,
testbuff.machine);
#if _UTSNAME_DOMAIN_LENGTH - 0
# ifdef __USE_GNU
printf( domainame:%s ,testbuff.domainname);
//char domainname[_UTSNAME_DOMAIN_LENGTH]; //当前域名
# else
printf( __domainame:%s ,testbuff.__domainname);
//char __domainname[_UTSNAME_DOMAIN_LENGTH];
# endif
#endif
}
return 0;
}
uname 作为Linux命令
用途
显示当前操作系统名称。
语法
uname [ -a | -x | -S Name ] [ -F ] [ -f ] [ -l ] [ -L ] [ -m ]
您可能关注的文档
- Influence Parameters on Properties of Dolomite Bricks Containing Different Bonding Systems.pdf
- Influences of degree inhomogeneity on average path length and random walks in disassortativ.pdf
- Influencing Factors Analysis of CoBranding Fit Degree Based on Niche Trend.pdf
- Information Search and Retrieval General Terms.pdf
- Informatics in Administration and Economics.pdf
- Inherent limitations of Visual Search and the Role of InnerScene Similarity.pdf
- initial catalog与database的区别.doc
- Inoue法制备超级感受态细胞丁香通.doc
- InSAR and Mathematical Modelling for Measuring Surface Deformation Due to Geothermal Water.pdf
- insearchoftheamberroom导学案.docx
文档评论(0)