os_info 2.0.1

Detect the operating system type and version.


Status: CI

Project info: Docs.rs Latest Version License

Project details: LoC rust 1.41+ required dependency status


Library for detecting the operating system type and version.

Based on os_type. The main difference of os_info is that this library separates completely incompatible operating systems by conditional compilation and uses specific system API whenever is possible.


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

os_info = "2.0.1"

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

os_info = { version = "2.0.0", default-features = false }


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());

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

  • Unknown
  • Android
  • Emscripten
  • Linux
  • Redhat
  • RedHatEnterprise
  • Ubuntu
  • Debian
  • Arch
  • CentOS
  • Fedora
  • Amazon
  • Alpine
  • SUSE Linux Enterprise
  • openSUSE
  • Macos
  • Redox
  • Windows

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


On Linux based systems this library requires that lsb_release is installed.


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