41 stable releases (3 major)

3.8.2 Mar 22, 2024
3.7.0 Mar 20, 2023
3.5.1 Sep 19, 2022
3.4.0 May 22, 2022
0.4.0 Nov 12, 2017

#6 in Operating systems

Download history 109124/week @ 2024-01-12 129355/week @ 2024-01-19 129258/week @ 2024-01-26 130032/week @ 2024-02-02 144095/week @ 2024-02-09 129624/week @ 2024-02-16 142865/week @ 2024-02-23 152619/week @ 2024-03-01 154141/week @ 2024-03-08 161647/week @ 2024-03-15 156846/week @ 2024-03-22 172751/week @ 2024-03-29 138422/week @ 2024-04-05 140792/week @ 2024-04-12 142240/week @ 2024-04-19 117774/week @ 2024-04-26

565,259 downloads per month
Used in 500 crates (97 directly)

MIT license

110KB
2.5K SLoC

os_info

Status: CI Coverage Dependency status

Project info: Docs.rs Latest version License

Project details: LoC Rust 1.60+ required

Overview

This project consists of two parts: the library that can be used to detect the operating system type (including version and bitness) and the command line tool that uses the library.

Library (os_info)

os_info usage

To use this crate, add os_info as a dependency to your project's Cargo.toml:

[dependencies]
os_info = "3"

This project has serde as an optional dependency, so if you don't need it, then you can speed up compilation disabling it:

[dependencies]
os_info = { version = "3", default-features = false }

Example

let info = os_info::get();

// Print full information:
println!("OS information: {info}");

// Print information separately:
println!("Type: {}", info.os_type());
println!("Version: {}", info.version());
println!("Bitness: {}", info.bitness());
println!("Architecture: {}", info.architecture());

Command line tool (os_info_cli)

A simple wrapper around the os_info library.

Installation

This tool can be installed using the following cargo command:

cargo install os_info_cli

os_info_cli usage

Despite being named os_info_cli during installation, it is actually named os_info. You can use the --help flag to see available options:

os_info --help

Supported operating systems

Right now, the following operating system types can be returned:

  • AIX
  • AlmaLinux
  • Alpaquita Linux
  • Alpine Linux
  • Amazon Linux AMI
  • Android
  • Arch Linux
  • Artix Linux
  • CentOS
  • Debian
  • DragonFly BSD
  • Emscripten
  • EndeavourOS
  • Fedora
  • FreeBSD
  • Garuda Linux
  • Gentoo Linux
  • HardenedBSD
  • illumos
  • Kali Linux
  • Linux
  • Mabox
  • macOS (Mac OS X or OS X)
  • Manjaro
  • Mariner
  • MidnightBSD
  • Mint
  • NetBSD
  • NixOS
  • OpenBSD
  • OpenCloudOS
  • openEuler (EulerOS)
  • openSUSE
  • Oracle Linux
  • Pop!_OS
  • Raspberry Pi OS
  • Red Hat Linux
  • Red Hat Enterprise Linux
  • Redox
  • Rocky Linux
  • Solus
  • SUSE Linux Enterprise Server
  • Ubuntu
  • Ultramarine Linux
  • Unknown
  • Void Linux
  • Windows

If you need support for more OS types, I am looking forward to your Pull Request.

License

os_info is licensed under the MIT license. See LICENSE for the details.

Dependencies

~0.5–9.5MB
~91K SLoC