Skip to content

Instantly share code, notes, and snippets.

@o0-o
o0-o / cpu_threads.sh
Last active May 7, 2019 02:30
[Number Threads] Prints the number of processing threads #Shell
# cpu_threads.sh
( # linux
getconf _NPROCESSORS_ONLN ||
# bsd
sysctl -n hw.ncpu
) 2>/dev/null ||
@o0-o
o0-o / serial.sh
Last active May 10, 2019 18:04
[Serial Number] Retrieves the serial number of the host (if one exists) #Shell
# serial.sh
( # edgeos
show version |
grep "HW S/N:" ||
# linux/bsd x86
dmidecode --string system-serial-number ||
# macos
@o0-o
o0-o / bash_version.sh
Last active May 7, 2019 02:27
[Bash Version] Prints the version of bash that is locally installed #Shell
# bash_version.sh
( bash --version |
grep --only-matching --max-count=1 "([0-9]*\.){2}[0-9]*" |
head -n 1 #`head --lines=` isn't portable, so `-n` is used
) 2>/dev/null ||
exit 1 #failure
@o0-o
o0-o / ssh_key_create.sh
Last active May 7, 2019 02:27
[Create SSH Key] Generate and install an SSH key #Shell
# ssh_key_create.sh
#
# parameter: user@host
# example: [email protected]
( # try ed25519
( ssh-keygen -t ed25519 -b 4096 -f "~/.ssh/$1" &&
ssh-copy-id -i ~/.ssh/"$1" "$1"
) ||