Getting Comprehensive System Information

Posted by JD 09/05/2015 at 16:00

Updated 2020 – a few better commands
Updated 2017 – tested on Ubuntu 16.04.

When you ask for computer help, the people who you ask could really use some basic information about the computer. That information includes

  • CPU
  • Memory
  • Video
  • Networking
  • Disk, partitions, LVM

Basically, I find myself asking for this same information over and over, day after day. The more accurate and detailed the provided information is, the better. However, gathering the information needs to be easy for the beginner too. That is the attempt here. Simple and easy to use for everyone, while not being so hard to audit that people have to make a huge leap of faith to trust it.

A Simple Script

Anyway, below is my attempt at a script to capture the data I generally want. It doesn’t cover everything, if it did, it would be even longer. I really wanted it to be 1pg or less in length.

Sadly, the

blog software breaks this code. Copy/paste will not work, you must use the download link below.

There is a link after to get the unmolested script. The script below is only provided so folks who wish to see the script quickly don’t have to download it. The blog software alters some important characters to the script while trying to make it more viewable. The blog software authors knew this would happen and make a poor decision, IMHO.

File: quick-sys-info.sh
#!/bin/bash

LOG=/tmp/sys-info-$$

cmd() {
echo "

INFO === Running: $CMD
" | tee -a $LOG
$CMD | tee -a $LOG
}

CMD=“lsb_release -a”; cmd
CMD=“grep name /proc/cpuinfo”; cmd
CMD=“lscpu”; cmd
CMD=“free -hm”; cmd
CMD=“sudo lshw -sanitize -C video -C network”; cmd

CMD=“route -n”; cmd
CMD=“ifconfig”; cmd
CMD=“iwconfig”; cmd
CMD=“rfkill list”; cmd

CMD=“sudo parted -l”; cmd
CMD=“df -Th -x squashfs -x tmpfs -x devtmpfs”; cmd
CMD=“lsblk -o name,size,type,fstype,mountpoint”; cmd
CMD="sudo pvs “; cmd
CMD=”sudo vgs “; cmd
CMD=”sudo lvs “; cmd
CMD=”inxi -Fz "; cmd

echo "
=======
Log file: $LOG
Data uploaded to sprunge.us here:

"
#####

  1. push output to sprunge.us?
    cat $LOG | curl F ’sprunge=<’ http://sprunge.us

exit;

This script breaks many bash scripting guidelines. I’m trusting the PATH, just to avoid issues on different Linux distros.

How to Run

  1. dependencies: for most people the dependencies should already be installed, except for lshw or inxi . On debian/Ubuntu systems, sudo apt-get install lshw inxi will install the packages. This can be done on liveCD/DVD or bootable flash systems too.
  2. boot off any liveCD or bootable Flash version of Linux. If you already have Linux installed, that can be used too.
  3. download this script and save it into a file on your system – something like /tmp/quick-sys-info.sh would be a good name.
  4. Run bash /tmp/quick-sys-info.sh or feel free to make it executable and run it that way too. The log file is placed in /tmp/ with a unique name for each run. The log file is displayed at the end of the run.
  5. Copy/paste the log file output to the forum where someone asked for the results. Do NOT edit it. Also, please, please, please use code tags if possible in the forum software. Ubuntu Forums support this.
  6. Updated the script to push the data to a pastebin-clone (sprunge.us). Anyone with the URL can see it. Please post the URL in forums rather than all the output. Doing this means you don’t have to learn “code tags” or waste bandwidth for people paying by-the-byte for data.

Posting a photo or screen capture is rude for people with low-bandwidth connections. Please do not do this.

Wifi on Ubuntu

A script for wifi info on Ubuntu.

Summary

A simple example of how to capture data from a running system through a script was shown. Hope this helps someone.

I’ve tested the script on Ubuntu 12.04, 14.04, 16.04 and CentOS v7.×. Some of the commands don’t work on CentOS, but most do. Simplicity overrode completeness in this case.