Skip to content

Instantly share code, notes, and snippets.

@adujardin
Last active January 27, 2023 15:53
Show Gist options
  • Save adujardin/73812be5026908edb6d005e8acc4e594 to your computer and use it in GitHub Desktop.
Save adujardin/73812be5026908edb6d005e8acc4e594 to your computer and use it in GitHub Desktop.
Simple script to get some info about a linux machine
#!/bin/bash
host=$(cat /etc/hostname)
echo "PC Name: ${host}"
cpu=$(cat /proc/cpuinfo | grep "model name" | head -1 | sed "s/model name : //")
echo "CPU: ${cpu}"
motherboard=$(sudo dmidecode -t 2 | grep "Product Name" | sed "s/ Product Name: //")
echo "Motherboard: ${motherboard}"
# Number of stick and their sizes
sticks=$(sudo dmidecode --type memory | grep "Volatile Size:" | sed '/Non-Volatile Size/d' | sed "s/ Volatile Size: //" | sed "s/ GB//" | paste -s -d, /dev/stdin)
# type (DDR4/DDR3)
ram_type=$(sudo dmidecode --type memory | grep "Type:" | sed '/Error Correction Type/d' | head -1 | sed 's/ Type: //')
n_stick=$(echo ${sticks} | grep -o "[[:digit:]]\+" | wc -l)
total_ram=$(echo "${sticks}" | tr '\n' ' ' | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g' | tr -s ' ' | sed 's/ /\n/g' | paste -s -d+ | bc)
echo "RAM: ${total_ram}GB (${ram_type}) ; ${n_stick} stick(s) (${sticks})"
gpu=$(sudo lshw -C display | grep "product:" | sed "s/ product: //")
echo "GPU ${gpu}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment