---
name: "Sys::Info::OS"
section: "3pm"
platform: "linux"
package: "libsys-info-base-perl"
version: "0.7807-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Sys::Info::OS"
---

# Sys::Info::OS(3pm)

Detailed os information.

## NAME

Sys::Info::OS

## VERSION

version 0.7807

## SYNOPSIS

```
   use Sys::Info;
   my $info = Sys::Info->new;
   my $os   = $info->os(%options);
```

or

```
   use Sys::Info::OS;
   my $os = Sys::Info::OS->new(%options);
```

Example:

```
   use Data::Dumper;

   warn "Collected information can be incomplete\n" if $os->is_unknown;

   my %fs = $os->fs;
   print Data::Dumper->Dump([\%fs], ['*FILE_SYSTEM']);

   print "B1ll G4teZ rull4z!\n" if $os->is_windows;
   print "Pinguin detected!\n"  if $os->is_linux;
   if ( $os->is_windows ) {
      printf "This is a %s based system\n", $os->is_winnt ? 'NT' : '9.x';
   }
   printf "Operating System: %s\n", $os->name( long => 1 );

   my $user = $os->login_name( real => 1 ) || $os->login_name || 'User';
   print "$user, You've Got The P.O.W.E.R.!\n" if $os->is_root;

   if ( my $up = $os->uptime ) {
      my $tick = $os->tick_count;
      printf "Running since %s\n"   , scalar localtime $up;
      printf "Uptime: %.2f hours\n" , $tick / (60*60      ); # probably windows
      printf "Uptime: %.2f days\n"  , $tick / (60*60*24   ); # might be windows
      printf "Uptime: %.2f months\n", $tick / (60*60*24*30); # hmm... smells like tux
   }
```

## DESCRIPTION

Supplies detailed operating system information.

## NAME

Sys::Info::OS - Detailed os information.

## METHODS

### new

Object constructor.

### name

Returns the OS name. Supports these named parameters: `"edition"`, `"long"`:

```
   # also include the edition info if present
   $os->name( edition => 1 );
```

This will return the long OS name (with build number, etc.):

```
   # also include the edition info if present
   $os->name( long => 1, edition => 1 );
```

### version

Returns the OS version.

### build

Returns the OS build number or build date, depending on the system.

### uptime

Returns the uptime as a unix timestamp.

### tick\_count

Returns the uptime in seconds since the machine booted.

### node\_name

Machine name

### domain\_name

Returns the network domain name.

Synonyms:

- workgroup

  ### login\_name

Returns the name of the effective user. Supports parameters in `"name => value"` format. Accepted parameters: `"real"`:

```
    my $user = $os->login_name( real => 1 ) || $os->login_name;
```

### ip

Returns the IP number.

### fs

Returns an info hash about the filesystem. The contents of the hash can vary among different systems.

### host\_name

### time\_zone

### product\_type

### bitness

If successful, returns the bitness ( `32` or `64` ) of the OS. Returns false otherwise.

### meta

Returns a hash containing various informations about the OS.

### cdkey

### locale

## UTILITY METHODS

These are some useful utility methods.

### is\_windows

Returns true if the os is windows. Synonyms:

- is\_win32

  - is\_win

  ### is\_winnt

Returns true if the OS is a NT based system (NT/2000/XP/2003).

Always returns false if you are not under windows or you are not under a NT based system.

### is\_win95

Returns true if the OS is a 9x based system (95/98/Me).

Always returns false if you are not under Windows or Windows9x.

Synonyms:

- is\_win9x

  ### is\_linux

Returns true if the os is linux. Synonyms:

- is\_lin

  ### is\_bsd

Returns true if the os is (free\|open\|net)bsd.

### is\_unknown

Returns true if this module does not support the OS directly.

### is\_root

Returns true if the current user has admin rights. Synonyms:

- is\_admin

  - is\_admin\_user

  - is\_adminuser

  - is\_root\_user

  - is\_rootuser

  - is\_super\_user

  - is\_superuser

  - is\_su

  ## CAVEATS

- •

  I don't have access to all operating systems in the world, so this module (currently) only supports Windows, Linux and (Free)BSD. Windows support is better. If you want support for some other OS, you'll need to write the driver yourself. Anything other than natively supported systems will fall-back to the generic `"Unknown"` driver which has *very* limited capabilities.

- •

  **Win32::IsAdminUser()** implemented in 5.8.4 (However, it is possible to manually upgrade the `"Win32"` module). If your ActivePerl is older than this, `"is_admin"` method will always returns false. (There *may* be a workaround for that).

- •

  Contents of the filesystem hash may change in further releases.

- •

  Filesystem \[Windows\]

  File system information can not be extracted under restricted environments. If this is the case, we'll get an *access is denied* error.

- •

  Bitness has some problems \[Linux, BSD\], especially on the os side.

## SEE ALSO

Win32, POSIX,  Sys::Info, Sys::Info::Device, \<http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfoex\_str.asp\>.

## AUTHOR

Burak Gursoy \<burak@cpan.org\>

## COPYRIGHT AND LICENSE

This software is copyright (c) 2006 by Burak Gursoy.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
