Skip to content

Instantly share code, notes, and snippets.

@knoxxs
Created October 22, 2013 10:13
Show Gist options
  • Save knoxxs/7098187 to your computer and use it in GitHub Desktop.
Save knoxxs/7098187 to your computer and use it in GitHub Desktop.
Generate System Information
#Function to print info about your system. Usage: genInfo <filename> [-v(Verbose = more)] [-n(Network)]
function genInfo() {
echo -e '=======================\nLinux distribution and version\n=======================\n\n' > $1;
lsb_release -a >> $1;
echo -e '\n\n=======================\nKernel Version\n=======================\n\n' >> $1;
uname -mrs >> $1
uname -a >> $1
cat /proc/version >> $1;
if [ -n $2 ] && [ "$2" == "-v" ]
then
echo -e '\n\n=======================\nCPU INFO\n=======================\n\n' >> $1;
cat /proc/cpuinfo >> $1;
echo -e '\n\n=======================\nMemory INFO\n=======================\n\n' >> $1;
cat /proc/meminfo >> $1;
echo -e '\n\n=======================\nPCI Devices\n=======================\n\n' >> $1;
lspci >> $1;
echo -e '\n\n=======================\nUSB Devices\n=======================\n\n' >> $1;
lsusb >> $1;
echo -e '\n\n=======================\nBlock Devices\n=======================\n\n' >> $1;
lsblk >> $1;
if [ -n $3 ] && [ "$3" == "-n" ]
then
echo -e '\n\n=======================\nNetwork\n=======================\n\n' >> $1;
ifconfig -a >> $1;
echo -e '\n\n=======================\nPorts\n=======================\n\n' >> $1;
sudo netstat -tulpn >> $1;
echo -e '\n\n=======================\nRouting\n=======================\n\n' >> $1;
route -n >> $1;
fi
echo -e '\n\n=======================\nHardware Information\n=======================\n\n' >> $1;
sudo dmidecode >> $1;
echo -e '\n\n=======================\nX Server\n=======================\n\n' >> $1;
xdpyinfo >> $1;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment