# Welcome!

## Welcome to system\_info2

Welcome to system*info2! Here you'll find all the documentation you need to get up and running with the system\_info2* API.

The system\_info2 package provides details about your operating system and hardware beyond what the Dart Platform class provides.

Before you launching to using system\_info2 you should check that the Dart Platform class doesn't already provide the features you need.

## Sponsored by OnePub

Help support system\_info2 by supporting [OnePub](https://onepub.dev/drive/4c62ce07-bfe4-46e6-9f81-987a78c03ce7), the private Dart repository.&#x20;

OnePub allows you to privately share Dart packages across your Team and with your customers.

Try it for free and publish your first private package in seconds.

| ![](https://4213309366-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FohCP4PEUFU4ta1pBoVo3%2Fuploads%2F4DwcntrfbBrmkSvPKNBz%2Fimage.png?alt=media\&token=911007a9-0b1c-4149-9393-1d93d92ecc28) | <p>Publish a private package in five commands:</p><p><mark style="color:green;"><code>dart pub global activate onepub</code></mark></p><p><mark style="color:green;"><code>onepub login</code></mark></p><p><mark style="color:green;"><code>cd \<my package></code></mark></p><p><mark style="color:green;"><code>onepub pub private</code></mark> </p><p><mark style="color:green;"><code>dart pub publish</code></mark></p> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

We also need to recognize Andrew Mezoni's work to create the package in the first place.

## Documentation conventions

This document uses the term **Posix** to collectively refer to all non-Windows operating systems including:

* Linux
* Android
* MacOS
* iOS

### Recommended Packages

If you are looking for additional OS level functionality you might what to take a look at the following Dart packages:

* [posix](https://pub.dev/packages/posix)
* [win32](https://pub.dev/packages/win32)

## Want to jump right in?

Feeling like an eager beaver? Jump into the quick-start docs and make your first request:

{% content-ref url="/pages/LrltO6Cyyy5l11P9UHcu" %}
[Quick Start](/quick-start)
{% endcontent-ref %}

## Want to deep dive?

Dive a little deeper and start exploring our API reference to get an idea of everything that's possible with the API:

{% content-ref url="/pages/DTdAv569c6iPqfTsRSne" %}
[SysInfo](/reference/sysinfo)
{% endcontent-ref %}


# Installing

The easiest way to install system\_info2 is from the cli.

```bash
dart pub add system_info2
dart pub get
```

To use the system\_info2 package import into your code:

```dart
import 'package:system_info2/system_info2.dart
```


# Quick Start

{% hint style="info" %}
**Start by following the install** [**instructions**](/installing)**.**
{% endhint %}

## Discover your hardware

```dart
import 'package:system_info2/system_info2.dart';

if (SysInfo.operatingSystemName == "Ubuntu") {
  log.info("We love Ubuntu users");
}

if (SysInfo.userSpaceBitness == 32) {
  log.info("Dart VM runs as a 32-bit process");
}
```

The system\_info2 package provides a variety of details:

```dart
import 'package:system_info2/system_info2.dart';

void main() {
  print('Kernel architecture     : ${SysInfo.kernelArchitecture}');
  print('Kernel bitness          : ${SysInfo.kernelBitness}');
  print('Kernel name             : ${SysInfo.kernelName}');
  print('Kernel version          : ${SysInfo.kernelVersion}');
  print('Operating system name   : ${SysInfo.operatingSystemName}');
  print('Operating system version: ${SysInfo.operatingSystemVersion}');
  print('User directory          : ${SysInfo.userDirectory}');
  print('User id                 : ${SysInfo.userId}');
  print('User name               : ${SysInfo.userName}');
  print('User space bitness      : ${SysInfo.userSpaceBitness}');
  final processors = SysInfo.processors;
  print('Number of processors    : ${processors.length}');
  for (var processor in processors) {
    print('  Architecture          : ${processor.architecture}');
    print('  Name                  : ${processor.name}');
    print('  Socket                : ${processor.socket}');
    print('  Vendor                : ${processor.vendor}');
  }
  print(
      'Total physical memory   : ${SysInfo.getTotalPhysicalMemory() ~/ MEGABYTE} MB');
  print(
      'Free physical memory    : ${SysInfo.getFreePhysicalMemory() ~/ MEGABYTE} MB');
  print(
      'Total virtual memory    : ${SysInfo.getTotalVirtualMemory() ~/ MEGABYTE} MB');
  print(
      'Free virtual memory     : ${SysInfo.getFreeVirtualMemory() ~/ MEGABYTE} MB');
  print(
      'Virtual memory size     : ${SysInfo.getVirtualMemorySize() ~/ MEGABYTE} MB');
}

const int MEGABYTE = 1024 * 1024;

```


# SysInfo

The SysInfo class is the core class that provides all the details of the hardware you are running on.

See the individual pages listed in the TOC for details.

### Example:

```dart
import "package:system_info2/system_info2.dart";

const int MEGABYTE = 1024 * 1024;

void main() {
  print("Kernel architecture     : ${SysInfo.kernelArchitecture}");
  print("Kernel bitness          : ${SysInfo.kernelBitness}");
  print("Kernel name             : ${SysInfo.kernelName}");
  print("Kernel version          : ${SysInfo.kernelVersion}");
  print("Operating system name   : ${SysInfo.operatingSystemName}");
  print("Operating system version: ${SysInfo.operatingSystemVersion}");
  print("User directory          : ${SysInfo.userDirectory}");
  print("User id                 : ${SysInfo.userId}");
  print("User name               : ${SysInfo.userName}");
  print("User space bitness      : ${SysInfo.userSpaceBitness}");
  var processors = SysInfo.processors;
  print("Number of processors    : ${processors.length}");
  for (var processor in processors) {
    print("  Architecture          : ${processor.architecture}");
    print("  Name                  : ${processor.name}");
    print("  Socket                : ${processor.socket}");
    print("  Vendor                : ${processor.vendor}");
  }
  print("Total physical memory   : ${SysInfo.getTotalPhysicalMemory() ~/ MEGABYTE} MB");
  print("Free physical memory    : ${SysInfo.getFreePhysicalMemory() ~/ MEGABYTE} MB");
  print("Total virtual memory    : ${SysInfo.getTotalVirtualMemory() ~/ MEGABYTE} MB");
  print("Free virtual memory     : ${SysInfo.getFreeVirtualMemory() ~/ MEGABYTE} MB");
  print("Virtual memory size     : ${SysInfo.getVirtualMemorySize() ~/ MEGABYTE} MB");
}
```

Output:

```
Kernel architecture     : i686
Kernel bitness          : 32
Kernel name             : Linux
Kernel version          : 3.13.0-43-generic
Operating system name   : Ubuntu
Operating system version: 14.04
User directory          : /home/andrew
User id                 : 1000
User name               : andrew
User space bitness      : 32
Number of processors    : 2
  Architecture          : X86_64
  Name                  : AMD Athlon(tm) II X2 240 Processor
  Socket                : 0
  Vendor                : AuthenticAMD
  Architecture          : X86_64
  Name                  : AMD Athlon(tm) II X2 240 Processor
  Socket                : 0
  Vendor                : AuthenticAMD
Total physical memory   : 3782 MB
Free physical memory    : 385 MB
Total virtual memory    : 7651 MB
Free virtual memory     : 4249 MB
```

###


# kernelArchitecture

### SysInfo.kernelArchitecture

The kernelArchitecture describes the type of CPU your app is running on.

Possible values are:

| Architecture                  | Reported By             | Value   |
| ----------------------------- | ----------------------- | ------- |
| ProcessorArchitecture.aarch64 |                         | AARCH64 |
| ProcessorArchitecture.arm     | MacOS Arm, Raspberry Pi | ARM     |
| ProcessorArchitecture.ia64    |                         | IA64    |
| ProcessorArchitecture.mips    |                         | MIPS    |
| ProcessorArchitecture.x86     | Windows 32, Linux 32    | X86     |
| ProcessorArchitecture.x86\_64 | Windows 64, Linux 64    | X86\_64 |
| ProcessorArchitecture.unknown |                         | UNKNOWN |

#### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Kernel architecuture          : ${SysInfo.kernelArchitecture}");
```

{% hint style="info" %}
Please help expand the list of examples by raising an issue with examples on the [onpub.dev github site](https://github.com/onepub-dev/system_info).
{% endhint %}


# kernelBitness

## kernelBitness

The kernelBitness describes the number of bits your kernel is running.&#x20;

If you need to know what bitness your app is running as use [userSpaceBitness](/reference/sysinfo/userspacebitness).

{% hint style="info" %}
In most cases you actually want to use userSpaceBitness as it more correctly reflects the capabilities that your application has access to. The usersSpaceBitness constrains how much memory you can allocate.
{% endhint %}

Possible values are:

* 32
* 64

#### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Kernel bitness          : ${SysInfo.kernelBitness}");
```


# kernelName

### kernelName

The name of your operating system.

Possible values are:

* Linux
* Windows
* MacOS
* iOS
* Android

Example:

```dart
import "package:system_info2/system_info2.dart";

print("Kernel name          : ${SysInfo.kernelName}");
```

{% hint style="info" %}
Please help expand the list of examples by raising an issue with examples on the [onpub.dev github site](https://github.com/onepub-dev/system_info).
{% endhint %}


# kernelVersion

### kernelVersion

Returns the version of your OS.

The format of the version is heavily dependent on which OS and version of the OS you are running.

Possible values are:

* Linux - 3.13.0-43-generic

Help us maintain this list. Please raise an issue on the [system\_info2](https://github.com/onepub-dev/system_info) github site with details of the version numbers you have seen.

Example:

```dart
import "package:system_info2/system_info2.dart";

print("Kernel version          : ${SysInfo.kernelVersion}");
```

{% hint style="info" %}
Please help expand the list of examples by raising an issue with examples on the [onpub.dev github site](https://github.com/onepub-dev/system_info).
{% endhint %}


# operatingSystemName

### operatingSystemName

Provides the name of your operating system.

Possible values are:

* Ubuntu
* MacOS
* Windows
* iOS
* Android

### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Operating System name          : ${SysInfo.operatingSystemName}");
```

{% hint style="info" %}
Please help expand the list of examples by raising an issue with examples on the [onpub.dev github site](https://github.com/onepub-dev/system_info).
{% endhint %}


# operatingSystemVersion

### operatingSystemVersion

Provides the name of your operating system.

The operating system version will depend on your operating system.

Possible Values:

* Linux 22.04

### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Operating System version          : ${SysInfo.operatingSystemVersion}");
```

{% hint style="info" %}
Please help expand the list of examples by raising an issue with examples on the [onpub.dev github site](https://github.com/onepub-dev/system_info).
{% endhint %}


# userDirectory

### userDirectory

Generally referred to as your home directory.

On most platforms, this is the content of the HOME environment variable.

If you are going to do further manipulation of paths and files you should be aware of the following packages:

* [path](https://pub.dev/packages/path)
* [dcli\_core](https://pub.dev/packages/dcli_core)

Typical values are:

* Linux -  /home/myusername
* MacOS - /usres/username
* Windows - \user\username

### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Home Directory          : ${SysInfo.userDirectory}");
```

{% hint style="info" %}
Please help expand the list of examples by raising an issue with examples on the [onpub.dev github site](https://github.com/onepub-dev/system_info).
{% endhint %}


# userId

### userId

A value representing the logged in user.

On Windows this is the user SID on all other platforms it is the value returned by `id`.

Be aware that if you are running under `sudo` then you `id` will change to 0.

If you require additional information look at the [posix](https://pub.dev/packages/posix) package or the [DCli](https://pub.dev/packages/dcli) `isPrivilegedUser` function.

Possible values:

* Windows - S-1-5-21
* All others - 1000
* if running under sudo - 0

### Example:

```dart
import "package:system_info2/system_info2.dart";

print("User ID          : ${SysInfo.userId}");
```

{% hint style="info" %}
Please help expand the list of examples by raising an issue with examples on the [onpub.dev github site](https://github.com/onepub-dev/system_info).
{% endhint %}


# userName

The logged in user's name.

If you are running under sudo then the username will be 'root'.

Possible Values:

* bsutton
* andrew

### Example:

```dart
import "package:system_info2/system_info2.dart";

print("User Name          : ${SysInfo.userName}");
```


# userSpaceBitness

### userSpaceBitness

Reflects the bitness that your application is running with.

A number of OS allow you to run a 32 bit app on a 64bit kernel. The userSpaceBitness reflects the the bitness you compiled your app to.

If you are in a virtualised environment this may not reflect the actual hardware CPU bitness.

Virtualisation environments include Windows wow64. In these cases, the bitness will reflect the bitness of your compiled executable.

Possible values:

* 32
* 64

### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Bitness          : ${SysInfo.userSpaceBitness}");
```


# cores

### cores

Reports details about each core your chip supports.

On chips that support Simultaneous Multi-Threading (hyper-threading) we return a core for each virtual core. So a CPU with 8 physical cores that supports hyper-threading will report 16 cores.

For each core we return

* Name - brand name of cpu
* Vendor&#x20;
* Architecture
* Socket - zero based socket no. Not supported on all systems and will return 0 in these cases.

The `Socket` represents a physical processor. Most PC and mobile devices only have a single Socket. Server grade hardware may report multiple sockets.

Example Values:

* 4
* 16

&#x20;Example:

```dart
import "package:system_info2/system_info2.dart";

print("Processors         : ${SysInfo.processors}");
```


# getTotalPhysicalMemory

### getTotalPhysicalMemory

Returns the total physical RAM available to the operating system in bytes.

#### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Processors         : ${SysInfo.getTotalPhysicalMemory()}");
```


# getFreePhysicalMemory

### getFreePhysicalMemory

Returns the total Free physical RAM available to the operating system in bytes.

#### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Processors         : ${SysInfo.getFreePhysicalMemory()}");
```


# getTotalVirtualMemory

### getTotalVirtualMemory

Returns the total virtual RAM available to the operating system in bytes.

Virtual Memory is reported as the total of the physical memory plus swap space.

#### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Processors         : ${SysInfo.getTotalVirtualMemory()}");
```


# getFreeVirtualMemory

### getFreeVirtualMemory

Returns the total Free virtual RAM available to the operating system in bytes.

Virtual Memory is reported as the total of the physical memory plus swap space.

#### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Processors         : ${SysInfo.getTotalVirtualMemory()}");
```


# getVirtualMemorySize

### getVirtualMemorySize

Returns the total amount of virtual memory used by your app.

#### Example:

```dart
import "package:system_info2/system_info2.dart";

print("Processors         : ${SysInfo.getVirtualMemorySize()}");
```


