Skip to content

Latest commit

 

History

History
119 lines (88 loc) · 1.76 KB

README.md

File metadata and controls

119 lines (88 loc) · 1.76 KB

OS DETECTION

Demonstrate how to detect the OS type in script to change parameters to commands.

Contents

REF: chrisguest75/docker_examples/10_distro_versions/README.md

Example Script

# use decision logic based on OS version
./detect-os.sh  

Docker

docker buildx build --progress=plain -f Dockerfile.os -t detect-os .
docker run --rm detect-os

Ubuntu & Debian

# kernel versions
uname -a
cat /proc/version

# distro versions  
cat /etc/os-release

# show kernel compile options
zcat /proc/config.gz

# package versions
apt list
apt update
apt list --upgradable

Alpine

# kernel versions
uname -a
cat /proc/version

# distro versions  
cat /etc/os-release

# package versions
apk list --installed
apk list -u

NixOS

# kernel versions
uname -a
cat /proc/version

# distro versions  
cat /etc/os-release

# package versions
apk list --installed
apk list -u

Fedora

# kernel versions
uname -a
cat /proc/version

# distro versions  
cat /etc/os-release

# package versions
yum list --installed
yum list --upgrades

MacOS

sw_vers -productName
sw_vers -productVersion
sw_vers -buildVersion
echo "Hostname (VPN): $(scutil --get HostName)"
echo "LocalHostName: $(scutil --get LocalHostName)"  

Windows

# in cmd prompt
ver

# versions in powershell
[System.Environment]::OSVersion

Resources