Little Girl's Mostly Linux Blog

MySystemReports

The mysystemreports Script

This page was last updated on September 29, 2013.

Table Of Contents

About the script

This is a simple Bash script that creates 6 reports on your hardware, boot-up messages, installed packages, etc. in a directory on your Desktop and lets you know what it’s doing while it runs. The reports it creates are:

  • A list of installed packages.
  • A list of currently loaded kernel modules.
  • A list of your PCI buses and all devices connected to them.
  • A report of the partitions on your computer.
  • A copy of your boot-up messages.
  • A list of your hardware.

Three of the commands (fdisk, dmesg and lshw) require root access to run properly, so you’ll be asked for your system password.

Requirements

See the script

#!/bin/sh
##################################################################################
# STEP_1 - ABOUT THIS SCRIPT                                                     #
##################################################################################
STEP_1() {
	echo "###################################################################"
	echo "#    mysystemreports v0.4                                         #"
	echo "#    by Little Girl                                               #"
	echo "#    https://mostlylinux.wordpress.com                             #"
	echo "#                                                                 #"
	echo "#    Anyone may feel free to use and/or modify this script.       #"
	echo "#                                                                 #"
	echo "#  This script creates reports on your hardware, boot-up          #"
	echo "#  messages, installed packages, etc.                             #"
	echo "#                                                                 #"
	echo "#  The reports will be placed on your Desktop in a directory      #"
	echo "#  named MySystemReports and will have the current date and       #"
	echo "#  time added to their names.                                     #"
	echo "#                                                                 #"
	echo "#  Three of these commands (fdisk, dmesg and lshw) require root   #"
	echo "#  access to run properly. As a result, you will be asked for     #"
	echo "#  your system password when running this script.                 #"
	echo "###################################################################"
	echo
	}
##################################################################################
# STEP_2 - HELP SECTION                                                          #
##################################################################################
STEP_2() {
	echo "###################################################################"
	echo "#    HOW TO USE THIS SCRIPT IN A TERMINAL:                        #"
	echo "#                                                                 #"
	echo "#  1. Open a terminal window.                                     #"
	echo "#                                                                 #"
	echo "#  2. Change to the directory this script is in. For example:     #"
	echo "#                                                                 #"
	echo "#                      cd /home/Desktop                           #"
	echo "#                                                                 #"
	echo "#  3. Type this command:                                          #"
	echo "#                                                                 #"
	echo "#                  bash mysystemreports.bash                      #"
	echo "#                                                                 #"
	echo "#     HOW TO USE THIS SCRIPT FROM A SHORTCUT:                     #"
	echo "#                                                                 #"
	echo "#  1. Right-click this script in your file manager. Change its    #"
	echo "#     properties so that it's executable and runs in a terminal.  #"
	echo "#                                                                 #"
	echo "#  2. Create a shortcut to the script and place the shortcut      #"
	echo "#     anywhere you like.                                          #"
	echo "#                                                                 #"
	echo "#  3. Use the shortcut to run the script.                         #"
	echo "##################################################################"
	}
##################################################################################
# STEP_3 - CHECK FOR DESTINATION DIRECTORY. CREATE IT IF NECESSARY.              #
##################################################################################
STEP_3() {
	echo "Checking if MySystemReports directory exists on the Desktop...";
	if
		[ -d ~/Desktop/MySystemReports ];
	then
		echo "MySystemReports directory exists. Continuing...";
	else
		echo "Creating MySystemReports directory...";
		mkdir ~/Desktop/MySystemReports;
	fi;
	}
##################################################################################
# STEP_4 - CREATE SYSTEM REPORTS IN THE DESTINATION DIRECTORY                    #
##################################################################################
STEP_4() {
	echo "Creating 1st report - a list of installed packages...";
	dpkg --get-selections > ~/Desktop/MySystemReports/MyPackages.txt--`date +%Y-%m-%d`;

	echo "Creating 2nd report - a list of currently loaded kernel modules...";
	lsmod > ~/Desktop/MySystemReports/lsmod.txt--`date +%Y-%m-%d`;

	echo "Creating 3rd report - a list of my PCI buses and all devices connected to them...";
	lspci -vv > ~/Desktop/MySystemReports/lspci.txt--`date +%Y-%m-%d`;

	echo "Creating 4th report - a report showing the partitions on my computer...";
	sudo fdisk -l > ~/Desktop/MySystemReports/fdisk.txt--`date +%Y-%m-%d`;

	echo "Creating 5th report - a copy of my boot-up messages...";
	sudo dmesg > ~/Desktop/MySystemReports/dmesg.txt--`date +%Y-%m-%d`;

	echo "Creating 6th report - a list of my hardware...";
	sudo lshw -html > ~/Desktop/MySystemReports/lshw.html--`date +%Y-%m-%d`;
	}
##################################################################################
# STEP_5 - DISPLAY JOB DONE AND PROMPT USER TO CLOSE THE WINDOW                  #
##################################################################################
STEP_5() {
	echo -n "Done! Press the Enter key to exit this script.";
	read keypress;
	}
##################################################################################
# STEP_6 - BEGIN THE SCRIPT                                                      #
##################################################################################
################################################
# IF NO OPTIONS ARE USED RUN THESE STEPS       #
################################################
if
	[ $# = '0' ];
then
	STEP_1 | more;
	STEP_3;
	STEP_4;
	STEP_5;
################################################
# IF ONE OPTION IS USED RUN ONE OF THESE STEPS #
################################################
elif
	[ $# = '1' ];
then
	########################################
	# IF KNOWN OPTION RUN THIS STEP        #
	########################################
	if
		[ "$1" = "-h" ];
	then
		STEP_2 | more;
	########################################
	# IF KNOWN OPTION RUN THIS STEP        #
	########################################
	elif
		[ "$1" = "--help" ];
	then
		STEP_2 | more;
	########################################
	# IF UNKNOWN OPTION DO THIS            #
	########################################
	else
		echo "invalid option";
	fi
################################################
# IF MORE THAN ONE OPTION IS USED DO THIS      #
################################################
else
	echo "invalid number of options";
fi

Get the script

Get the script in one of these ways:

  • Download mysystemreports_v0.4.zip from Box.
  • Download mysystemreports_v0.4.zip from Host-A.
  • Get the script manually:

    1. Copy the script above.
    2. Paste the copied script into a text editor.
    3. Save it as mysystemreports.bash somewhere on your computer.

Use The Script

  1. Open a terminal window.
  2. Change to the directory the script is in. For example, if the script is on the Desktop, you would type this command:

    cd ~/Desktop
  3. Press the Enter key.
  4. Run the script by typing this command:

    bash mysystemreports.bash
  5. Press the Enter key.
  6. Type in your password when asked.
  7. When the script finishes running, press the Enter key and close the terminal window.
  8. The reports will be in the MySystemReports directory on your Desktop. You can move the directory to another location on your computer or keep it on your Desktop.

Obligatory Happy Ending

And they all lived happily ever after. The end.

2 Comments »

  1. Great script!! I’ve modified it slightly to suit my #! install as “Desktop” is only visible in a file manager by default.

    Thanks, cheers.

    Comment by yakrider — December 23, 2010 @ 9:18 am

    • I’m glad you like it! Since it was written for Ubuntu/Kubuntu and both have the Desktop, that isn’t an issue for them. I suppose I could rewrite it to use a variable and then have the user make one edit to specify the path used by the variable. By the way, have you checked out the mysystemfiles script, which is the sister script to this one? :)

      Comment by mostlylinux — December 23, 2010 @ 6:39 pm


RSS feed for comments on this post. TrackBack URI

Comment:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: