• Node.js Video Tutorials

NodeJS - OS Module



Node.js OS module includes a lot of practical utility methods that may be used to learn more about the computer system, that the OS module's software is now operating on. It can include details about hardware, including CPUs, endianness, the home directory, IP address, hostname, the operating system the program is running on, system uptime, details on the currently logged-in user, and more.

List of Methods

Following is a list of methods available in the OS module −

Sr.No Module & Description
1

hostname()

Used to get the hostname of the current operating system.

2

loadavg()

Used to return an array containing load averages.

3

arch()

Used to get the CPU architecture of the computer.

4

cpus()

Used to get an array of objects, which contains detailed information about every logical CPU core of the computer.

5

devNull

Used to get the platform-specific file path of the device.

6

endianness()

Used to get the endianness of the CPU.

7

EOL

Used to get the end-of-line marker or character as specified by the operating system.

8

freemem()

Used to get the amount of free memory left in the RAM of the computer.

9

getPriority()

Used to return an integer specifying the scheduling priority of the process.

10

homedir()

Used to return a string of the path of the home directory of the user.

11

networkInterfaces()

Used to return an object which contains the network interfaces that have been assigned a network address.

12

platform()

Used to return a string value that specifies the operating system platform of the system.

13

release()

Used to return a string value that specifies the operating system release (version)

14

totalmem()

Used to return the total amount of system memory as a number of bytes.

15

type()

Used to return a string value that specifies the operating system type.

16

uptime()

Used to return an integer that has the system uptime.

17

userInfo()

Used to return an object contains information about the current effective user.

18

version()

Used to return a string that represents the kernel version of the operating system.

19

setPriority()

Allows setting the scheduling priority of a process specified by the process ID (pid).

20

tmpdir()

Used to return a string that specifies the operating system's default directory for temporary files.

Advertisements