Skip to content

Instantly share code, notes, and snippets.

@cking
Last active February 9, 2016 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cking/407434cab0f90a0c9290 to your computer and use it in GitHub Desktop.
Save cking/407434cab0f90a0c9290 to your computer and use it in GitHub Desktop.
linux pcinfo
#!/bin/bash
F=~/pcinfo.txt
echo "Gathering hardware information..."
echo "Result file will be saved @ $F"
# Ubuntu, Debian, Fedora, ...
if [ `which lsb_release 2>/dev/null` ]; then
lsb_release -ir >$F 2>/dev/null
# arch
elif [ -f /etc/arch-release ]; then
echo "Distributor ID: Arch" >$F
echo "Release: $(cat /etc/arch-release)" >>$F
fi
echo "CPU: $(cat /proc/cpuinfo | grep "model name" | head -n1 | cut -d':' -f2)" >>$F
echo "RAM: $(free -m | head -n2 | tail -n1 | awk -F' ' '{ print $2 }')MB" >>$F
#lspci
if [ `which lspci 2>/dev/null` ]; then
echo "GPU: $(lspci | grep VGA | awk -F':' '{ print $3 }')" >>$F
echo "GPU RAM: $(lspci -v | grep VGA -A6 | grep Memory | awk -F'=' '{ print $2 }' | cut -d']' -f1)B" >>$F
#lshw
elif [ `which lshw 2>/dev/null` ]; then
echo "lshw instead of lscpi detected, for more accurate results install lspci please!"
echo "GPU: $(lshw -c display 2>/dev/null | grep product | awk -F':' '{ print $2 }')" >>$F
echo "GPU RAM: $(lshw -c display 2>/dev/null | grep memory: | cut -d':' -f3 | awk -F'-' '{
low = strtonum("0x" substr($1, 2))
high = strtonum("0x" substr($2, 2))
size = (high - low) / 1024 / 1024
print size
}')MB" >>$F
fi
echo "" >>$F
echo "HDD:" >>$F
LANG=C df -h | head -n1 >>$F
LANG=C df -h | grep -e '^/dev/s' >>$F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment