Last active
October 15, 2016 23:09
-
-
Save prabh-62/5bddfdd2cbf5bd30677f2dd63203d205 to your computer and use it in GitHub Desktop.
SystemInfo for Debian based Linux OS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| rootCheck="sudo" | |
| # Format SYstemInfo Output | |
| printToFile(){ | |
| printf "\n\n" >> $FILE | |
| printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - >> $FILE | |
| echo -e "$(tput setaf 1) ${1} $(tput setaf 7) " >> $FILE | |
| printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' - >> $FILE | |
| printf "\n" >> $FILE | |
| $rootCheck ${2} >> $FILE | |
| } | |
| # This method contains all the commands we need to run to obtain SYstemInfo | |
| function systeminfo(){ | |
| echo "Enter File Name: " | |
| read -a FILE | |
| if [ -e $FILE ]; then | |
| rm -f $FILE | |
| echo " Overwriting Existing File"; | |
| fi | |
| printToFile "Kernel Information" "uname -a" | |
| printToFile "Hardware Information" "lshw -short" | |
| printToFile "Drivers" "lspci" | |
| printToFile "Disk Information" "lsblk" | |
| printToFile "Current RAM Usage" "free -m" | |
| printToFile "CPU Information" "cat /proc/cpuinfo" | |
| printToFile "Network Information" "ifconfig" | |
| printToFile "Currently Logged In users" "w" | |
| echo "DISPLAYING OUTPUT FILE" | |
| cat $FILE | |
| } | |
| # Check if current user has root access | |
| if [[ $EUID -ne 1000 ]]; then | |
| echo "To get more information, please run this script with sudo privileges: sudo <ScriptName>" | |
| $rootCheck="" | |
| systeminfo | |
| else | |
| systeminfo | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment