Linux offers many ways to get information about your current hardware. Such as mouse and keyboard model and type.
Here is an example, getting information about the keyboard layout installed on my system.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ setxkbmap -query | awk '/layout/ && a ~ /model/ {print a"\n"$0} {a = $0}' model: pc105 layout: us |
This tells me that it uses a 105 key keyboard model and US layout.
This useful example prints all installed USB devices plugged into your Linux system.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ lsusb | awk '{print $7,$8,$9,$10,$11}' Intel Corp. Linux Foundation 2.0 root hub Intel Corp. Linux Foundation 2.0 root hub Seagate RSS LLC Expansion Desk Linux Foundation 3.0 root hub VIA Labs, Inc. VLI Product Corsair Corsair VOID PRO Surround HP, Inc OMEN Sequencer Logitech, Inc. G402 Gaming Mouse Afatech Rtl2832UDVB Linux Foundation 2.0 root hub |
This command worked for me to identify my installed mouse.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ lsusb | awk '/Mouse/ {print $7,$8,$9,$10,$11}' Logitech, Inc. G402 Gaming Mouse |
To get the name of the current GPU card in your Linux system, use this command.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ nvidia-settings -g | awk '/renderer string:/ {print $4,$5,$6}' |
This is a very useful and simple one-liner. This does not require unnecessary use of grep.
And another way to get the model and name of the graphics card in your Linux system.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ glxinfo | awk '/OpenGL renderer string:/ {print $4,$5,$6,$7,$8}' GeForce GTX 1050/PCIe/SSE2 |
Getting just the amount of video memory is very easy with Linux.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ glxinfo | awk '/dedicated video memory:/ {print $6}' 1721 |
And to get the device driver version on Linux, do it like this. This could be very useful in a script.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ glxinfo | awk '/core profile version string:/ {print $6,$7,$8}' 4.6.0 NVIDIA 450.102.04 |
This very useful one-liner will get the desktop resolution of the current monitor.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ xdpyinfo | grep -A4 '^screen' | awk '/dimensions/ {print $2}' 3440x1440 |
Or a simpler version, like this.
┌──[jason@192.168.1.2]─[~] └──╼ ╼ $ xdpyinfo | awk '/dimensions/ {print $2}' 3440x1440 |
But these tips are very useful for anyone who wants to know more about the hardware in a Linux machine, these are great one-liners and show how easy the shell is when getting hardware information. The trick I used with awk, to search for a certain string and then show only a certain column is very useful and better than grep, it is simpler. Grep has its place, but awk is also very useful and could replace it in certain circumstances. Why have unnecessary use of grep when awk can do the job by itself? This is just like the unneeded use of cat(1). I need to practice a better way of using the command line.