number of physical sockets and cpu cores

a small script to check out the number of processors in your linux machine #!/bin/bash S=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l) C=$(grep "cpu cores" /proc/cpuinfo |sort -u |cut -d":" -f2) grep -i "model name" /proc/cpuinfo echo your system has $S sockets with $C CPU cores each mandatory sample output: model name : Intel(R) Xeon(R) CPU L5640 @ 2.27GHz your system has 2 sockets with 6 CPU cores each

September 14, 2013 · Andrea Manzini

generare comandi di creazione utenze a partire da un passwd

A volte e’ necessario replicare le utenze con gli stessi parametri su piu’ server linux diversi. Perche’ farlo a mano ? Se sono tanti e’ un lavoro noioso e potremmo anche commettere degli errori. Ecco un semplice one-liner che fa il parsing di un file /etc/passwd e genera i corrispondenti comandi useradd awk -F: '{printf "useradd -m -u%s -g%s -d%s -s%s %s\n" , $3,$4,$6,$7,$1}' /etc/passwd Ovviamente l’output puo’ essere comodamente filtrato con grep, usato via copy&paste, inserito in uno script, eccetera…

November 23, 2012 · Andrea Manzini