0% found this document useful (0 votes)
8 views4 pages

OS Module

Uploaded by

sushree007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

OS Module

Uploaded by

sushree007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lesson:

OS Module
List of content:
Useful commands to fetch information from O
Examples and output

The OS module in Node.js is utilized to retrieve details about the operating system of a computer.

It offers methods for communication with the computer's operating system, including retrieving the
hostname and the amount of available system memory in bytes.

Let us have a look at the important commands:

1. The os.arch() method in Node.js is used to retrieve the architecture of the computer's CPU. It returns a
string that indicates the processor's architecture, eg. x32, x64 etc.

2. The os.freemem() method in Node.js is used to retrieve the amount of free system memory in bytes. It
returns a number that indicates the number of bytes of free memory available in the system. This will output
the amount of free memory available in the system, in bytes.

3. The os.totalmem() method in Node.js is used to retrieve the total amount of system memory in bytes. It
returns a number that indicates the total number of bytes of memory available in the system. This will
output the total amount of memory available in the system, in bytes.

Full Stack Web Development


4. The os.networkInterfaces() method in Node.js is used to retrieve information about the network interfaces
available on the system. It returns an object containing information about each network interface, including
its name, address family (IPv4 or IPv6), and IP addresses.

5. The os.tmpdir() method in Node.js is used to retrieve the default directory path for temporary files on the
current operating system. It returns a string that represents the path of the default directory for temporary
files.

Let us look at a few more important and frequently used commands:

1. The os.endianness() method in Node.js is used to retrieve the endianness of the computer's CPU. Endianness
refers to the order in which bytes are stored in memory. A little-endian CPU stores the least significant byte
first, while a big-endian CPU stores the most significant byte first.

The os.endianness() method returns a string that indicates the endianness of the CPU. It will return either "BE"
(big-endian) or "LE" (little-endian).

Full Stack Web Development


2. The os.hostname() method in Node.js is used to retrieve the hostname of the computer on which the
Node.js process is running. It returns a string that represents the hostname of the computer. This will output
the hostname of the computer on which the Node.js process is running. The hostname is typically a name
that is used to identify the computer on a network.

3. The os.type() method in Node.js is used to retrieve the operating system name on which the Node.js
process is running. It returns a string that represents the name of the operating system.This will output the
name of the operating system on which the Node.js process is running, such as "Windows_NT", "Linux", or
"Darwin" (for macOS). The output may vary depending on the operating system being used.

4. The os.platform() method in Node.js is used to retrieve the platform on which the Node.js process is
running. It returns a string that represents the platform, such as "win32", "linux", or "darwin" (for macOS). This
will output the platform on which the Node.js process is running, such as "win32", "linux", or "darwin". The
output may vary depending on the platform being used.

5. The os.release() method in Node.js is used to retrieve the operating system release on which the Node.js
process is running. It returns a string that represents the release of the operating system. This will output the
release of the operating system on which the Node.js process is running. The output may vary depending on
the operating system being used.

Full Stack Web Development

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy