https://github.com/developerstoolbox/os-detect
A script for working out what OS you are running on as some scripts need to be OS aware.
https://github.com/developerstoolbox/os-detect
bash os-detect wolfsoftware
Last synced: 6 months ago
JSON representation
A script for working out what OS you are running on as some scripts need to be OS aware.
- Host: GitHub
- URL: https://github.com/developerstoolbox/os-detect
- Owner: DevelopersToolbox
- License: mit
- Created: 2021-02-15T14:34:35.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-07-21T05:53:39.000Z (6 months ago)
- Last Synced: 2025-07-21T07:29:11.294Z (6 months ago)
- Topics: bash, os-detect, wolfsoftware
- Language: Shell
- Homepage:
- Size: 163 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
## Overview
A script for working out what OS you are running on as some scripts need to be OS aware.
## Table of Contents
1. [Usage](#usage)
1. [Functions](#functions)
1. [Environment Variables](#environment-variables)
1. [Example Output](#example-output)
### Simple Usage
```shell
source os-detect.sh
full_os_detect
echo "OS: $OSD_OS"
echo "DISTRIBUTION: $OSD_DISTRIBUTION"
echo "NAME: $OSD_NAME"
echo "CODENAME: $OSD_CODENAME"
echo "RELEASE: $OSD_RELEASE"
echo "VERSION: $OSD_VERSION"
echo "PLATFORM_VERSION: $OSD_PLATFORM_VERSION"
echo "BASEDON: $OSD_BASEDON"
echo "KERNEL: $OSD_KERNEL"
echo "ARCH: $OSD_ARCH"
```
### Custom usage
```shell
source os-detect.sh
detect_distribution
detect_version
echo "DISTRIBUTION: $OSD_DISTRIBUTION"
echo "VERSION: $OSD_VERSION"
```
The following functions exist:
* detect_os
* detect_kernel
* detect_architecture
* detect_distribution
* detect_name
* detect_version
* detect_platform_version
* detect_release
* detect_codename
* detect_basedon
* full_os_detect
The following environment variables are set:
* OSD_OS
* OSD_DISTRIBUTION
* OSD_NAME
* OSD_CODENAME
* OSD_RELEASE
* OSD_VERSION
* OSD_PLATFORM_VERSION
* OSD_BASEDON
* OSD_KERNEL
* OSD_ARCH
### Alma Linux
```shell
OS: Linux
DISTRIBUTION: almalinux
NAME: AlmaLinux
CODENAME: Arctic Sphynx
RELEASE: 8.5
VERSION: 8.5
PLATFORM VERSION: el-8
BASEDON: rhel centos fedora
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Alpine
```shell
OS: Linux
DISTRIBUTION: alpine
NAME: Alpine Linux
CODENAME: unknown
RELEASE: unknown
VERSION: 3.14.2
PLATFORM VERSION: unknown
BASEDON: unknown
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Amazon Linux
```shell
OS: Linux
DISTRIBUTION: amzn
NAME: Amazon Linux
CODENAME: unknown
RELEASE: 2
VERSION: 2
PLATFORM VERSION: unknown
BASEDON: centos rhel fedora
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Arch Linux
```shell
OS: Linux
DISTRIBUTION: arch
NAME: Arch Linux
CODENAME: unknown
RELEASE: unknown
VERSION: unknown
PLATFORM VERSION: unknown
BASEDON: unknown
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Centos
```shell
OS: Linux
DISTRIBUTION: centos
NAME: CentOS Linux
CODENAME: Core
RELEASE: 7.9.2009
VERSION: 7
PLATFORM VERSION: unknown
BASEDON: rhel fedora
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Debian
```shell
OS: Linux
DISTRIBUTION: debian
NAME: Debian GNU/Linux
CODENAME: bullseye
RELEASE: 11.1
VERSION: 11
PLATFORM VERSION: unknown
BASEDON: debian
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Mac OS
```shell
OS: Mac OS
DISTRIBUTION: unknown
NAME: macOS
CODENAME: unknown
RELEASE: 12.2.1
VERSION: unknown
PLATFORM VERSION: unknown
BASEDON: unknown
KERNEL: 21.3.0
ARCH: x86_64
```
### Oracle Linux
```shell
OS: Linux
DISTRIBUTION: ol
NAME: Oracle Linux Server
CODENAME: Ootpa
RELEASE: 8.5
VERSION: 8.5
PLATFORM VERSION: el-8
BASEDON: fedora
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Photon Linux
```shell
OS: Linux
DISTRIBUTION: photon
NAME: VMware Photon OS
CODENAME: unknown
RELEASE: 4.0
VERSION: 4.0
PLATFORM VERSION: unknown
BASEDON: unknown
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Rocky Linux
```shell
OS: Linux
DISTRIBUTION: rocky
NAME: Rocky Linux
CODENAME: Green Obsidian
RELEASE: 8.5
VERSION: 8.5
PLATFORM VERSION: el-8
BASEDON: rhel centos fedora
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Scientific Linux
```shell
OS: Linux
DISTRIBUTION: scientific
NAME: Scientific Linux
CODENAME: Nitrogen
RELEASE: 7.9
VERSION: 7.9
PLATFORM VERSION: unknown
BASEDON: rhel centos fedora
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```
### Ubuntu
```shell
OS: Linux
DISTRIBUTION: ubuntu
NAME: Ubuntu
CODENAME: focal
RELEASE: 20.04
VERSION: 20.04
PLATFORM VERSION: unknown
BASEDON: debian
KERNEL: 5.10.76-linuxkit
ARCH: x86_64
```