inxi 最初是为控制台和 irc(网络中继聊天)开发的一个强大且优秀的命令行系统信息脚本。可以使用它获取用户的硬件和系统信息,它也用于调试或者社区技术支持工具。
使用 inxi 可以很容易的获取所有的硬件信息:硬盘、声卡、显卡、网卡、cpu 和 ram 等。同时也能够获取大量的操作系统信息,比如硬件驱动、xorg 、桌面环境、内核、gcc 版本,进程,开机时间和内存等信息。
运行在命令行和 irc 上的 inxi 输出略有不同,irc 上会有一些可供用户使用的默认过滤器和颜色选项。支持的 irc 客户端有:bitchx、gaim/pidgin、ircii、irssi、 konversation、 kopete、 ksirc、 kvirc、 weechat 和 xchat 以及其它的一些客户端,它们具有展示内置或外部 inxi 输出的能力。
在 linux 系统上安装 inxi
大多数主流 linux 发行版的仓库中都有 inxi ,包括大多数 bsd 系统。
$ sudo apt-get install inxi [on debian/ubuntu/linux mint]
$ sudo yum install inxi [on centos/rhel/fedora]
$ sudo dnf install inxi [on fedora 22+]
在使用 inxi 之前,用下面的命令查看 inxi 所有依赖和推荐的应用,以及各种目录,并显示需要安装哪些包来支持给定的功能。
$ inxi --recommends
inxi 的输出:
inxi will now begin checking for the programs it needs to operate. first a check of the main languages and tools
inxi uses. python is only for debugging data collection.
---------------------------------------------------------------------------
bash version: 4.3.42(1)-release
gawk version: 4.1.3,
sed version:
sudo version: 1.8.16
python version: 2.7.12
test one: required system directories (linux only).
if one of these system directories is missing, inxi cannot operate:
/proc....................................................................... present
/sys........................................................................ present
all the directories are present.
test two: required core applications.
if one of these applications is missing, inxi cannot operate:
df (info: partition data)................................................... /bin/df
gawk (info: core tool)...................................................... /usr/bin/gawk
grep (info: string search).................................................. /bin/grep
lspci (info: hardware data)................................................. /usr/bin/lspci
ps (info: process data)..................................................... /bin/ps
readlink.................................................................... /bin/readlink
sed (info: string replace).................................................. /bin/sed
tr (info: character replace)................................................ /usr/bin/tr
uname (info: kernel data)................................................... /bin/uname
wc (info: word character count)............................................. /usr/bin/wc
all the applications are present.
test three: script recommends for graphics features.
note: if you do not use x these do not matter (like a headless server). otherwise, if one of these applications
is missing, inxi will have incomplete output:
glxinfo (info: -g glx info)................................................. /usr/bin/glxinfo
xdpyinfo (info: -g multi screen resolution)................................. /usr/bin/xdpyinfo
xprop (info: -s desktop data)............................................... /usr/bin/xprop
xrandr (info: -g single screen resolution).................................. /usr/bin/xrandr
test four: script recommends for remaining features.
if one of these applications is missing, inxi will have incomplete output:
dig (info: -i first wlan ip default test)................................... /usr/bin/dig
dmidecode (info: -m if no sys machine data; -m memory)...................... /usr/sbin/dmidecode
file (info: -o unmounted file system)....................................... /usr/bin/file
hciconfig (info: -n -i bluetooth data)...................................... /bin/hciconfig
hddtemp (info: -dx show hdd temp)........................................... /usr/sbin/hddtemp
ifconfig (info: -i ip lan-deprecated)....................................... /sbin/ifconfig
ip (info: -i ip lan)........................................................ /sbin/ip
sensors (info: -s sensors output)........................................... /usr/bin/sensors
strings (info: -i sysvinit version)......................................... /usr/bin/strings
lsusb (info: -a usb audio;-n usb networking)................................ /usr/bin/lsusb
modinfo (info: -ax,-nx module version)...................................... /sbin/modinfo
runlevel (info: -i runlevel)................................................ /sbin/runlevel
sudo (info: -dx hddtemp-user;-o file-user).................................. /usr/bin/sudo
uptime (info: -i uptime (check which package owns debian)).................. /usr/bin/uptime
test five: script recommends for remaining features.
one of these downloaders needed for options -i/-w/-w (-u/-! [11-15], if supported):
wget (info: -i wan ip;-w/-w;-u/-! [11-15] (if supported))................... /usr/bin/wget
curl (info: -i wan ip;-w/-w;-u/-! [11-15] (if supported))................... /usr/bin/curl
test six: system directories for various information.
(unless otherwise noted, these are for gnu/linux systems)
if one of these directories is missing, inxi may have incomplete output:
/sys/class/dmi/id (info: -m system, motherboard, bios)...................... present
/dev (info: -l,-u,-o,-p,-p,-d disk partition data).......................... present
/dev/disk/by-label (info: -l,-o,-p,-p partition labels)..................... present
/dev/disk/by-uuid (info: -u,-o,-p,-p partition uuid)........................ present
test seven: system files for various information.
if one of these files is missing, inxi may have incomplete output:
/proc/asound/cards (info: -a sound card data)............................... present
/proc/asound/version (info: -a alsa data)................................... present
/proc/cpuinfo (info: -c cpu data)........................................... present
/etc/lsb-release (info: -s distro version data [deprecated])................ present
/proc/mdstat (info: -r mdraid data)......................................... present
/proc/meminfo (info: -i memory data)........................................ present
/etc/os-release (info: -s distro version data).............................. present
/proc/partitions (info: -p,-p partitions data).............................. present
/proc/modules (info: -g module data)........................................ present
/proc/mounts (info: -p,-p partition advanced data).......................... present
/var/run/dmesg.boot (info: -d,-d disk data [bsd only])...................... missing
/proc/scsi/scsi (info: -d advanced hard disk data [used rarely])............ present
/var/log/xorg.0.log (info: -g graphics driver load status).................. present
the following files are missing from your system:
file: /var/run/dmesg.boot
all tests completed.
inxi 工具的基本用法
用下面的基本用法获取系统和硬件的详细信息。
获取 linux 系统信息
inix 不加任何选项就能输出下面的信息:cpu 、内核、开机时长、内存大小、硬盘大小、进程数、登录终端以及 inxi 版本。
$ inxi
cpu~dual core intel core i5-4210u (-ht-mcp-) speed/max~2164/2700 mhz kernel~4.4.0-21-generic x86_64 up~3:15 mem~3122.0/7879.9mb hdd~1000.2gb(20.0% used) procs~234 client~shell inxi~2.2.35
获取内核和发行版本信息
使用 inxi 的 -s 选项查看本机系统信息(主机名、内核信息、桌面环境和发行版):
$ inxi -s
system: host: tecmint kernel: 4.4.0-21-generic x86_64 (64 bit) desktop: cinnamon 3.0.7
distro: linux mint 18 sarah
获取电脑机型
使用 -m 选项查看机型(笔记本/台式机)、产品 id 、机器版本、主板、制造商和 bios 等信息:
$ inxi -m
machine: system: lenovo (portable) product: 20354 v: lenovo z50-70
mobo: lenovo model: lancer 5a5 v: 31900059win bios: lenovo v: 9bcn26ww date: 07/31/2014
获取 cpu 及主频信息
使用 -c 选项查看完整的 cpu 信息,包括每核 cpu 的频率及可用的最大主频。
$ inxi -c
cpu: dual core intel core i5-4210u (-ht-mcp-) cache: 3072 kb
clock speeds: max: 2700 mhz 1: 1942 mhz 2: 1968 mhz 3: 1734 mhz 4: 1710 mhz
获取显卡信息
使用 -g 选项查看显卡信息,包括显卡类型、显示服务器、系统分辨率、glx 渲染器和 glx 版本等等(lctt 译注: glx 是一个 x 窗口系统的 opengl 扩展)。
$ inxi -g
graphics: card-1: intel haswell-ult integrated graphics controller
card-2: nvidia gm108m [geforce 840m]
display server: x.org 1.18.4 drivers: intel (unloaded: fbdev,vesa) resolution: [email protected]
glx renderer: mesa dri intel haswell mobile glx version: 3.0 mesa 11.2.0
获取声卡信息
使用 -a 选项查看声卡信息:
$ inxi -a
audio: card-1 intel 8 series hd audio controller driver: snd_hda_intel sound: alsa v: k4.4.0-21-generic
card-2 intel haswell-ult hd audio controller driver: snd_hda_intel
获取网卡信息
使用 -n 选项查看网卡信息:
$ inxi -n
network: card-1: realtek rtl8111/8168/8411 pci express gigabit ethernet controller driver: r8169
card-2: realtek rtl8723be pcie wireless network adapter driver: rtl8723be
获取硬盘信息
使用 -d 选项查看硬盘信息(大小、id、型号):
$ inxi -d
drives: hdd total size: 1000.2gb (20.0% used) id-1: /dev/sda model: st1000lm024_hn size: 1000.2gb
获取简要的系统信息
使用 -b 选项显示上述信息的简要系统信息:
$ inxi -b
system: host: tecmint kernel: 4.4.0-21-generic x86_64 (64 bit) desktop: cinnamon 3.0.7
cpu: dual core intel core i5-4210u (-ht-mcp-) speed/max: 2018/2700 mhz
drives: hdd total size: 1000.2gb (20.0% used)
info: processes: 233 uptime: 3:23 memory: 3137.5/7879.9mb client: shell (bash) inxi: 2.2.35
获取硬盘分区信息
使用 -p 选项输出完整的硬盘分区信息,包括每个分区的分区大小、已用空间、可用空间、文件系统以及文件系统类型。
$ inxi -p
partition: id-1: / size: 324g used: 183g (60%) fs: ext4 dev: /dev/sda10
id-2: swap-1 size: 4.00gb used: 0.00gb (0%) fs: swap dev: /dev/sda9
获取完整的 linux 系统信息
使用 -f 选项查看可以完整的 inxi 输出(安全起见比如网络 ip 地址信息没有显示,下面的示例只显示部分输出信息):
$ inxi -f
clock speeds: max: 2700 mhz 1: 1716 mhz 2: 1764 mhz 3: 1776 mhz 4: 1800 mhz
if: enp1s0 state: up speed: 100 mbps duplex: full mac: 28:d2:44:eb:bd:98
if: wlp2s0 state: down mac: 38:b1:db:7c:78:c7
raid: no raid devices: /proc/mdstat, md_mod kernel module present
sensors: system temperatures: cpu: 56.0c mobo: n/a
fan speeds (in rpm): cpu: n/a
info: processes: 234 uptime: 3:26 memory: 3188.9/7879.9mb client: shell (bash) inxi: 2.2.35
使用 inxi 工具监控 linux 系统
下面是监控 linux 系统进程、开机时间和内存的几个选项的使用方法。
监控 linux 进程的内存使用
使用下面的命令查看进程数、开机时间和内存使用情况:
$ inxi -i
info: processes: 232 uptime: 3:35 memory: 3256.3/7879.9mb client: shell (bash) inxi: 2.2.35
监控进程占用的 cpu 和内存资源
inxi 默认显示 前 5 个最消耗 cpu 和内存的进程。 -t 选项和 c 选项一起使用查看前 5 个最消耗 cpu 资源的进程,查看最消耗内存的进程使用 -t 选项和 m 选项; -t选项 和 cm 选项一起使用显示前 5 个最消耗 cpu 和内存资源的进程。
----------------- linux cpu usage -----------------
$ inxi -t c
processes: cpu: % used - top 5 active
1: cpu: 53.7% command: plugin-container pid: 3066
2: cpu: 20.0% command: java pid: 1527
3: cpu: 19.7% command: firefox pid: 3018
4: cpu: 4.6% command: xorg pid: 2114
5: cpu: 3.0% command: cinnamon pid: 2835
----------------- linux memoery usage -----------------
$ inxi -t m
processes: memory: mb / % used - used/total: 3212.5/7879.9mb - top 5 active
1: mem: 980.51mb (12.4%) command: plugin-container pid: 3066
2: mem: 508.96mb (6.4%) command: java pid: 1527
3: mem: 507.89mb (6.4%) command: firefox pid: 3018
4: mem: 244.05mb (3.0%) command: chrome pid: 7405
5: mem: 211.46mb (2.6%) command: chrome pid: 6146
----------------- linux cpu and memory usage -----------------
$ inxi -t cm
memory: mb / % used - used/total: 3223.6/7879.9mb - top 5 active
1: mem: 991.93mb (12.5%) command: plugin-container pid: 3066
3: mem: 507.86mb (6.4%) command: firefox pid: 3018
4: mem: 244.45mb (3.1%) command: chrome pid: 7405
5: mem: 211.68mb (2.6%) command: chrome pid: 6146
可以在选项 cm 后跟一个整数(在 1-20 之间)设置显示多少个进程,下面的命令显示了前 10 个最消耗 cpu 和内存的进程:
$ inxi -t cm10
processes: cpu: % used - top 10 active
1: cpu: 53.4% command: plugin-container pid: 3066
2: cpu: 19.8% command: java pid: 1527
3: cpu: 19.5% command: firefox pid: 3018
4: cpu: 4.5% command: xorg pid: 2114
6: cpu: 2.8% command: chrome pid: 7405
7: cpu: 1.1% command: pulseaudio pid: 2733
8: cpu: 1.0% command: soffice.bin pid: 7799
9: cpu: 0.9% command: chrome pid: 5763
10: cpu: 0.5% command: chrome pid: 6179
memory: mb / % used - used/total: 3163.1/7879.9mb - top 10 active
1: mem: 976.82mb (12.3%) command: plugin-container pid: 3066
2: mem: 511.70mb (6.4%) command: java pid: 1527
3: mem: 466.01mb (5.9%) command: firefox pid: 3018
4: mem: 244.40mb (3.1%) command: chrome pid: 7405
5: mem: 203.71mb (2.5%) command: chrome pid: 6146
6: mem: 199.74mb (2.5%) command: chrome pid: 5763
7: mem: 168.30mb (2.1%) command: cinnamon pid: 2835
8: mem: 165.51mb (2.1%) command: soffice.bin pid: 7799
9: mem: 158.91mb (2.0%) command: chrome pid: 6179
10: mem: 151.83mb (1.9%) command: mysqld pid: 1259
监控网络设备
下面的命令会列出网卡信息,包括接口信息、网络频率、mac 地址、网卡状态和网络 ip 等信息。
$ inxi -nni
wan ip: 111.91.115.195 if: wlp2s0 ip-v4: n/a
if: enp1s0 ip-v4: 192.168.0.103
监控 cpu 温度和电脑风扇转速
可以使用 -s 选项监控 配置了传感器的机器 获取温度和风扇转速:
sensors: system temperatures: cpu: 53.0c mobo: n/a
用 linux 查看天气预报
使用 -w 选项查看本地区的天气情况(虽然使用的 api 可能不是很可靠),使用 -w <different_location> 设置另外的地区。
$ inxi -w
weather: conditions: 93 f (34 c) - smoke time: february 20, 1:38 pm ist
$ inxi -w mumbai,india
$ inxi -w nairobi,kenya
weather: conditions: 70 f (21 c) - mostly cloudy time: february 20, 11:08 am eat
查看所有的 linux 仓库信息
另外,可以使用 -r 选项查看一个 linux 发行版的仓库信息:
$ inxi -r
repos: active apt sources in file: /etc/apt/sources.list.d/dawidd0811-neofetch-xenial.list
deb http://ppa.launchpad.net/dawidd0811/neofetch/ubuntu xenial main
deb-src http://ppa.launchpad.net/dawidd0811/neofetch/ubuntu xenial main
active apt sources in file: /etc/apt/sources.list.d/dhor-myway-xenial.list
deb http://ppa.launchpad.net/dhor/myway/ubuntu xenial main
deb-src http://ppa.launchpad.net/dhor/myway/ubuntu xenial main
active apt sources in file: /etc/apt/sources.list.d/official-package-repositories.list
deb http://packages.linuxmint.com sarah main upstream import backport
deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://archive.canonical.com/ubuntu/ xenial partner
active apt sources in file: /etc/apt/sources.list.d/qbittorrent-team-qbittorrent-stable-xenial.list
deb http://ppa.launchpad.net/qbittorrent-team/qbittorrent-stable/ubuntu xenial main
deb-src http://ppa.launchpad.net/qbittorrent-team/qbittorrent-stable/ubuntu xenial main
active apt sources in file: /etc/apt/sources.list.d/slgobinath-safeeyes-xenial.list
deb http://ppa.launchpad.net/slgobinath/safeeyes/ubuntu xenial main
deb-src http://ppa.launchpad.net/slgobinath/safeeyes/ubuntu xenial main
active apt sources in file: /etc/apt/sources.list.d/snwh-pulp-xenial.list
deb http://ppa.launchpad.net/snwh/pulp/ubuntu xenial main
deb-src http://ppa.launchpad.net/snwh/pulp/ubuntu xenial main
active apt sources in file: /etc/apt/sources.list.d/twodopeshaggy-jarun-xenial.list
deb http://ppa.launchpad.net/twodopeshaggy/jarun/ubuntu xenial main
deb-src http://ppa.launchpad.net/twodopeshaggy/jarun/ubuntu xenial main
active apt sources in file: /etc/apt/sources.list.d/ubuntu-mozilla-security-ppa-xenial.list
deb http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu xenial main
deb-src http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu xenial main
下面是查看 inxi 的安装版本、快速帮助和打开 man 主页的方法,以及更多的 inxi 使用细节。
$ inxi -v #显示版本信息
$ inxi -h #快速帮助
$ man inxi #打开 man 主页
浏览 inxi 的官方 github 主页 https://github.com/smxi/inxi 查看更多的信息。
inxi 是一个功能强大的获取硬件和系统信息的命令行工具。这也是我使用过的最好的 获取硬件和系统信息的命令行工具 之一。
写下你的评论。如果你知道其他的像 inxi 这样的工具,我们很高兴和你一起讨论。
作者:aaron kili
来源:51cto