System Info
System Info
Section titled “System Info”ps, env, date, hostname, whoami, which, balias, time, and sleep commands for process listing, environment inspection, and shell utilities.
Report a snapshot of the current processes. Returns structured PsEntry objects with typed properties for process ID, CPU, memory, and more.
Syntax
Section titled “Syntax”ps [OPTIONS]| Flag | Description |
|---|---|
aux | BSD-style: show all processes with full columns |
-e / -A | Show all processes |
-f | Full-format listing (current user’s processes, no TTY restriction) |
-u USER | Filter by username |
-p PID | Filter by process ID |
--sort=KEY | Sort by key (prefix with - for descending) |
-o COLS | Custom column output (comma-separated) |
Sort keys: pid, ppid, cpu, %cpu, mem, %mem, rss, vsz, user, comm, time
Custom columns (-o): pid, ppid, user, %cpu, cpu, %mem, mem, vsz, rss, tty, stat, start, time, command, cmd, comm, args
PsEntry Properties
Section titled “PsEntry Properties”Each result is a PsBash.PsEntry object:
| Property | Type | Description |
|---|---|---|
PID | int | Process ID |
PPID | int | Parent process ID |
User | string | Username of the process owner |
CPU | double | CPU usage percentage |
Memory | double | Memory usage percentage |
MemoryMB | double | Resident memory in megabytes |
VSZ | long | Virtual memory size in KB |
RSS | long | Resident set size in KB |
TTY | string | Controlling terminal |
Stat | string | Process state code |
Start | DateTime | Process start time |
Time | string | Cumulative CPU time (M:SS format) |
Command | string | Command line |
CommandLine | string | Full command line |
ProcessName | string | Short process name |
WorkingSet | long | Working set in bytes |
BashText | string | Formatted text output line |
Examples
Section titled “Examples”List all processes (BSD-style):
ps auxroot 1 0.0 0.1 2456 1024 ? S 09:15 0:01 /sbin/inityou 1234 2.5 1.3 45600 13312 pts/0 Sl 10:30 1:42 pwshTop 5 processes by CPU usage:
ps aux | sort -k3 -rn | head 5The output looks like text, but each result is still a PsEntry object. Properties survive the pipeline:
$top = ps aux | sort -k3 -rn | head 1$top[0].PID # 1234$top[0].MemoryMB # 13.0Filter by user:
ps -u rootFilter by PID:
ps -p 1Sort by memory descending:
ps aux --sort=-%memCustom column output:
ps -e -o pid,user,%cpu,%mem,command 1 root 0.0 0.1 /sbin/init 1234 you 2.5 1.3 pwshAccess properties programmatically:
$procs = ps aux$procs | Where-Object { $_.Memory -gt 1.0 } | ForEach-Object { '{0}: {1} MB' -f $_.ProcessName, $_.MemoryMB}env / printenv
Section titled “env / printenv”Print environment variables as structured objects. Both env and printenv call the same function.
Syntax
Section titled “Syntax”env [VARNAME]printenv [VARNAME]When called with no arguments, lists all environment variables sorted by name. When called with a variable name, returns that single variable.
EnvEntry Properties
Section titled “EnvEntry Properties”Each result is a PsBash.EnvEntry object:
| Property | Type | Description |
|---|---|---|
Name | string | Environment variable name |
Value | string | Environment variable value |
BashText | string | Formatted as NAME=VALUE |
Examples
Section titled “Examples”List all environment variables:
envHOME=/home/youPATH=/usr/bin:/binSHELL=/bin/bashGet a specific variable:
env HOMEHOME=/home/youAccess the value programmatically:
$home = env HOME$home.Value # "/home/you"$home.Name # "HOME"Filter environment variables with grep:
env | grep PATHPATH=/usr/bin:/binMANPATH=/usr/share/manCount environment variables:
env | wc -lPrint the current date and time, or format a specific date. Returns a DateOutput object with typed date components.
Syntax
Section titled “Syntax”date [OPTIONS] [+FORMAT]| Flag | Description |
|---|---|
-d STRING / --date=STRING | Display time described by STRING instead of now |
-u / --utc / --universal | Print in UTC |
-r FILE / --reference=FILE | Display the last modification time of FILE |
+FORMAT | Output format using % specifiers |
Format Specifiers
Section titled “Format Specifiers”| Specifier | Description | Example |
|---|---|---|
%Y | Four-digit year | 2026 |
%m | Month (01-12) | 04 |
%d | Day of month (01-31) | 02 |
%H | Hour, 24-hour (00-23) | 14 |
%M | Minute (00-59) | 30 |
%S | Second (00-59) | 45 |
%s | Seconds since Unix epoch | 1775340645 |
%A | Full weekday name | Thursday |
%B | Full month name | April |
%Z | Timezone | UTC |
%a | Abbreviated weekday | Thu |
%b | Abbreviated month | Apr |
%e | Day of month, space-padded | 2 |
%j | Day of year (001-366) | 092 |
%p | AM/PM | PM |
%n | Newline | |
%t | Tab | |
%% | Literal % | % |
DateOutput Properties
Section titled “DateOutput Properties”Each result is a PsBash.DateOutput object:
| Property | Type | Description |
|---|---|---|
Year | int | Four-digit year |
Month | int | Month number (1-12) |
Day | int | Day of month (1-31) |
Hour | int | Hour (0-23) |
Minute | int | Minute (0-59) |
Second | int | Second (0-59) |
Epoch | long | Unix timestamp (seconds since 1970-01-01) |
DayOfWeek | string | Full weekday name |
TimeZone | string | Timezone identifier |
DateTime | DateTimeOffset | The underlying .NET DateTimeOffset |
BashText | string | Formatted date string |
Examples
Section titled “Examples”Current date and time (default format):
dateThu Apr 2 14:30:45 America/Chicago 2026Custom format:
date '+%Y-%m-%d %H:%M:%S'2026-04-02 14:30:45Unix epoch timestamp:
date '+%s'1775340645Display a specific date:
date -d '2025-12-25'Thu Dec 25 00:00:00 America/Chicago 2025UTC output:
date -uThu Apr 2 19:30:45 UTC 2026Last modification time of a file:
date -r package.jsonAccess properties programmatically:
$d = date$d.Year # 2026$d.Epoch # 1775340645$d.DayOfWeek # "Thursday"hostname
Section titled “hostname”Print the system hostname.
Syntax
Section titled “Syntax”hostnameReturn Type
Section titled “Return Type”PsBash.TextOutput with a single property:
| Property | Type | Description |
|---|---|---|
BashText | string | The system hostname |
Uses [System.Net.Dns]::GetHostName() for cross-platform compatibility.
Examples
Section titled “Examples”Print the hostname:
hostnamemy-workstationAccess the value programmatically:
$h = hostname$h.BashText # "my-workstation"Use in a formatted string:
$user = whoami$host = hostnameprintf '%s@%s\n' $user.BashText $host.BashTextyou@my-workstationwhoami
Section titled “whoami”Print the current username.
Syntax
Section titled “Syntax”whoamiReturn Type
Section titled “Return Type”PsBash.TextOutput with a single property:
| Property | Type | Description |
|---|---|---|
BashText | string | The current username |
Uses [System.Environment]::UserName for cross-platform compatibility.
Examples
Section titled “Examples”Print the current user:
whoamiyouAccess the value programmatically:
$me = whoami$me.BashText # "you"Combine with other commands:
ps -u (whoami).BashTextLocate a command by name. Returns the path to the executable or function definition.
Syntax
Section titled “Syntax”which [OPTIONS] NAME...| Flag | Description |
|---|---|
-a | Show all matches, not just the first |
WhichOutput Properties
Section titled “WhichOutput Properties”Each result is a PsBash.WhichOutput object:
| Property | Type | Description |
|---|---|---|
Command | string | The command name that was looked up |
Path | string | Resolved path or definition |
Type | string | Command type (e.g., application, function, alias) |
BashText | string | The resolved path |
Examples
Section titled “Examples”Locate a command:
which pwsh/usr/bin/pwshShow all matches:
which -a python/usr/bin/python/usr/local/bin/pythonCheck the command type:
$w = which grep$w.Type # "alias"$w.Path # "Invoke-BashGrep"$w.Command # "grep"Locate multiple commands:
which ls cat grepInvoke-BashLsInvoke-BashCatInvoke-BashGrepbalias / unalias
Section titled “balias / unalias”Define, display, or remove shell aliases. The command is named balias to avoid conflicting with PowerShell’s built-in alias command. The unalias command is also available.
Syntax
Section titled “Syntax”balias [OPTIONS] [NAME[=VALUE]...]unalias NAME...unalias -a| Flag | Description |
|---|---|
-p | List all aliases (same as calling balias with no arguments) |
-u | Unalias mode (remove aliases) |
-a | Remove all aliases (used with -u) |
AliasOutput Properties
Section titled “AliasOutput Properties”Each result is a PsBash.AliasOutput object:
| Property | Type | Description |
|---|---|---|
Name | string | Alias name |
Value | string | Alias value (the command it expands to) |
BashText | string | Formatted as alias name='value' |
Examples
Section titled “Examples”Define an alias:
balias ll='ls -la'List all aliases:
baliasalias ll='ls -la'Look up a specific alias:
balias llalias ll='ls -la'Access properties programmatically:
balias mygrep='grep -rn'$a = balias mygrep$a.Name # "mygrep"$a.Value # "grep -rn"Remove an alias:
balias -u llRemove all aliases:
balias -u -aRun a command and measure its execution time. Returns the command’s output along with timing information.
Syntax
Section titled “Syntax”time COMMAND [ARGS...]TimeOutput Properties
Section titled “TimeOutput Properties”Each result is a PsBash.TimeOutput object:
| Property | Type | Description |
|---|---|---|
RealTime | TimeSpan | Wall-clock elapsed time |
Command | string | The command that was timed |
ExitCode | int | Exit code of the command (0 = success) |
BashText | string | The command’s text output |
The real time is also printed to stderr in the format real 0.123s.
Examples
Section titled “Examples”Time a command:
time ls -la-rw-r--r-- 1 you you 141234 Apr 2 10:30 PsBash.psm1real 0.045sAccess timing properties:
$t = time sleep 2$t.RealTime.TotalSeconds # ~2.0$t.ExitCode # 0$t.Command # "sleep"Time a pipeline-producing command:
$t = time grep -r 'function' src/$t.RealTime.TotalMilliseconds # elapsed msDelay execution for a specified amount of time. Produces no output.
Syntax
Section titled “Syntax”sleep NUMBER[SUFFIX]...Duration Suffixes
Section titled “Duration Suffixes”| Suffix | Meaning | Example |
|---|---|---|
s | Seconds (default) | sleep 5s |
m | Minutes | sleep 2m |
h | Hours | sleep 1h |
d | Days | sleep 1d |
When no suffix is given, the number is treated as seconds. Multiple arguments are summed together.
Examples
Section titled “Examples”Sleep for 3 seconds:
sleep 3Sleep for 500 milliseconds:
sleep 0.5Sleep with a suffix:
sleep 2mCombine multiple durations:
sleep 1m 30sThis sleeps for 90 seconds total (1 minute + 30 seconds).