0 前言
linux 有多個發(fā)行版本,不同的版本都有自己的版本號。
如何知道自己使用的Linux的系統(tǒng)信息呢?
使用uname命令、hostnamectl命令,或者通過查看/proc/version文件來了解這些信息。
我們先看看uname命令。
1 uname 命令的功能和格式
我們可以使用命令 uname --help命令 查看它的用法:
purpleEndurer @ ?bash ~ $ uname --help
Usage: uname [OPTION]...
Print certain system information. ?With no OPTION, same as -s.? -a, --all ? ? ? ? ? ? ? ?print all information, in the following order,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?except omit -p and -i if unknown:
? -s, --kernel-name ? ? ? ?print the kernel name
? -n, --nodename ? ? ? ? ? print the network node hostname
? -r, --kernel-release ? ? print the kernel release
? -v, --kernel-version ? ? print the kernel version
? -m, --machine ? ? ? ? ? ?print the machine hardware name
? -p, --processor ? ? ? ? ?print the processor type or "unknown"
? -i, --hardware-platform ?print the hardware platform or "unknown"
? -o, --operating-system ? print the operating system
? ? ? --help ? ? display this help and exit
? ? ? --version ?output version information and exitGNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report uname translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'uname invocation'
1.1 uname命令的功能
uname命令的功能是顯示操作系統(tǒng)信息,例如內(nèi)核版本、主機名、處理器類型等。
1.2 uname命令的格式
uname [選項]?...
?1.2.1?選項說明
選項 | 描述 | 備注 |
---|---|---|
-a, --all | 以如下次序輸出所有信息。 | 其中若-p 和-i的探測結(jié)果不可知則被省略 |
-s --kernel-name |
輸出內(nèi)核名稱 | - |
-n --nodename |
輸出網(wǎng)絡(luò)節(jié)點上的主機名 | - |
-r, --kernel-release | 輸出內(nèi)核發(fā)行號 | - |
-v --kernel-version |
輸出內(nèi)核版本 | - |
-m --machine |
輸出機器硬件名 | - |
-p --processor |
輸出處理器類型 | 非移動 |
-i --hardware-platform |
輸出硬件平臺 | 非移動 |
-o --operating-system |
輸出操作系統(tǒng) | - |
--help | 顯示此幫助信息并退出 | - |
--version | 顯示版本信息并退出 | - |
1.2.2?注意
如果不指定選項,則系統(tǒng)默認選項為-s,即只顯示內(nèi)核名稱。
2 uname命令使用實例?
2.1 uname?或 uname -s:顯示內(nèi)核名稱
purpleEndurer @ ?bash ~ $ uname
LinuxpurpleEndurer @ ?bash ~ $ uname -s
Linux
2.2? uname -n:輸出網(wǎng)絡(luò)節(jié)點上的主機名
purpleEndurer @ ?bash ~ $ uname -n
edu
2.3 uname -r:輸出內(nèi)核發(fā)行號
purpleEndurer @ ?bash ~ $ uname -r
5.10.134-15.1.2.lifsea8.x86_64
2.4 uname -v:輸出內(nèi)核版本
purpleEndurer @ ?bash ~ $ uname -v
#1 SMP Tue Aug 29 07:26:14 UTC 2023
?2.5?uname -m:輸出機器硬件名
purpleEndurer @ ?bash ~ $ uname -m
x86_64
2.6?uname -p:輸出處理器類型
purpleEndurer @ ?bash ~ $ uname -p
x86_64
2.7?uname -i:輸出硬件平臺
purpleEndurer @ ?bash ~ $ uname -i
x86_64
2.8?uname -o:輸出操作系統(tǒng)
purpleEndurer @ ?bash ~ $ uname -o
GNU/Linux
2.9 uname -a:輸出所有信息
purpleEndurer @ ?bash ~ $ uname -a
Linux edu 5.10.134-15.1.2.lifsea8.x86_64 #1 SMP Tue Aug 29 07:26:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux文章來源:http://www.zghlxwxcb.cn/news/detail-846538.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-846538.html
到了這里,關(guān)于Linux shell編程學(xué)習(xí)筆記45:uname命令-獲取Linux系統(tǒng)信息的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!