This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" | |
) || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# serial.sh | |
( # edgeos | |
show version | | |
grep "HW S/N:" || | |
# linux/bsd x86 | |
dmidecode --string system-serial-number || | |
# macos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cpu_threads.sh | |
( # linux | |
getconf _NPROCESSORS_ONLN || | |
# bsd | |
sysctl -n hw.ncpu | |
) 2>/dev/null || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# disks.sh | |
( # linux | |
lsblk --all --noheadings --list --output NAME,TYPE | | |
grep disk | | |
sed 's/[[:space:]]disk//g' || | |
# bsd | |
geom disk list | | |
grep "Geom name: " | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cpu_aes.sh | |
( # linux | |
lscpu | | |
grep --quiet "aes" || | |
# bsd | |
sysctl dev. | | |
grep --quiet "aes" || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# host_name.sh | |
hostname 2>/dev/null || | |
exit 1 #failure | |
exit 0 #success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mem.sh | |
( # linux | |
grep "MemTotal" /proc/meminfo | | |
awk '{ printf "%d\n", $2 * 1000 }' || | |
# bsd | |
sysctl -n hw.realmem 2>/dev/null || | |
# macos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# math_round.sh | |
# | |
# parameter: number (float) | |
# example: 3.14 | |
( echo "$1" | | |
awk '{ | |
x=$1 | |
ival = int(x) # integer part, int() truncates | |
# see if fractional part |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# net_ip4.sh | |
( # linux (NetworkManager) | |
nmcli -terse -mode tabular -fields IP4.ADDRESS device show || | |
# linux (iproute2) | |
ip -family inet -brief address | | |
# linux/bsd | |
( ip address || ifconfig ) | |
OlderNewer