OS Module
OS Module
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.
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.
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.
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).
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.