System information and environment utilities for inspecting and managing system state within the WebAssembly environment. These utilities provide access to system information, user context, and environment variables.
Display system and kernel information.
/**
* Display system information
* WebAssembly binary: dist/wasm/bin/uname
*
* Usage patterns:
* - uname [options]
* - Supports -a (all info), -s (system), -n (node), -r (release)
* - Shows system name, version, and architecture information
*/Display user and group identification information.
/**
* Display user and group IDs
* WebAssembly binary: dist/wasm/bin/id
*
* Usage patterns:
* - id [options] [user]
* - Supports -u (user ID), -g (group ID), -G (all groups)
* - Shows effective and real user/group information
*//**
* Display login name
* WebAssembly binary: dist/wasm/bin/logname
*
* Usage patterns:
* - logname
* - Displays the current user's login name
* - Gets name from login session information
*/Display and manipulate environment variables.
/**
* Display or modify environment
* WebAssembly binary: dist/wasm/bin/env
*
* Usage patterns:
* - env [options] [variable=value...] [command [args...]]
* - Supports -i (ignore environment), -u (unset variable)
* - Can run commands with modified environment
* - Note: execvp functionality limited in WebAssembly context
*/Display or set system date and time.
/**
* Display or set system date
* WebAssembly binary: dist/wasm/bin/date
*
* Usage patterns:
* - date [options] [+format]
* - date [options] [date_string]
* - Supports custom formatting with strftime format specifiers
* - Can parse and display dates in various formats
*/Display terminal device information.
/**
* Display terminal device name
* WebAssembly binary: dist/wasm/bin/tty
*
* Usage patterns:
* - tty [options]
* - Supports -s (silent mode)
* - Shows the file name of the terminal connected to stdin
*/Display directory space usage information.
/**
* Display directory space usage
* WebAssembly binary: dist/wasm/bin/du
*
* Usage patterns:
* - du [options] [directory...]
* - Supports -h (human readable), -s (summary), -a (all files)
* - Calculates disk usage for directories and files
*/Locate executable commands in the system PATH.
/**
* Locate commands in PATH
* WebAssembly binary: dist/wasm/bin/which
*
* Usage patterns:
* - which [options] command...
* - Supports -a (all matches), -s (silent mode)
* - Shows the full path of executable commands
*/System inspection:
const { path } = require("@cowasm/coreutils");
const { join } = require("path");
// Access system utility binaries
const binPath = join(path, "bin");
const unameBinary = join(binPath, "uname");
const idBinary = join(binPath, "id");
const dateBinary = join(binPath, "date");
// These would be executed via your WebAssembly runtimeCommon system queries:
# System identification
uname -a # Full system information
uname -s # System name only
# User context
id # Current user and group IDs
logname # Login name
# Environment inspection
env # All environment variables
env | grep PATH # PATH variable specifically
# Date and time
date # Current date and time
date "+%Y-%m-%d %H:%M:%S" # Custom format
# Disk usage
du -sh /path/to/directory # Directory size summary
du -h /path/to/directory # Human-readable directory usage
# Command location
which ls # Find ls command locationEnvironment manipulation:
# Run command with modified environment
env PATH="/custom/path:$PATH" command
# Run command with clean environment
env -i HOME="$HOME" PATH="/bin:/usr/bin" command
# Unset specific variables
env -u TEMP_VAR commandDate formatting examples:
# Various date formats
date "+%Y-%m-%d" # 2023-12-25
date "+%H:%M:%S" # 14:30:45
date "+%A, %B %d, %Y" # Monday, December 25, 2023
date "+%s" # Unix timestampuname reports WebAssembly/WASI system informationdu operates on the virtual file system provided by WASM runtime