Command Reference
This page covers the default JSH commands grouped by user-facing purpose.
Overview
This page groups commands by what they do for the user.
Notes
- These commands operate inside the JSH virtual filesystem by default, not directly on the host OS filesystem.
- Relative paths are resolved from the current JSH working directory.
- Some commands affect the active shell session directly, such as the current directory or environment variables.
- Some commands intentionally provide a smaller feature set than their Unix counterparts.
Filesystem Commands
cd
Changes the current working directory of the active JSH shell session.
Syntax
cd [directory]If no argument is provided, cd moves to $HOME.
If the target path does not exist, it prints an error and returns a non-zero status.
Usage example
/work > cd subdir
/work/subdir >
/work/subdir > cd
/work >cat
Concatenates files to standard output. It supports line numbering, visible line endings and tabs, blank-line squeezing, and syntax highlighting.
Syntax
cat [OPTION]... [FILE]...Options
-n, --numbernumber all output lines-E, --showEndsdisplay$at the end of each line-T, --showTabsdisplay tab characters as^I-s, --squeezesuppress repeated empty lines-c, --colorenable syntax highlighting-h, --helpshow help
With -c, syntax highlighting is available for .js, .json, .ndjson, .sql, .csv, .yaml, .yml, and .toml.
Usage example
/work > cat -n notes.txt
/work > cat -c script.js
/work > cat -sE log.txtls
Lists directory contents. By default it prints entries in columns and supports hidden entries, long listing mode, time sorting, recursion, and simple wildcards.
Syntax
ls [OPTION]... [PATH]...Options
-l, --longuse a detailed listing view-a, --allinclude hidden entries-t, --timesort by modification time, newest first-R, --recursivelist subdirectories recursively
Path arguments may include simple wildcard patterns such as * and ?.
Usage example
/work > ls
/work > ls -la
/work > ls -t /lib
/work > ls -R src
/work > ls *.jsmkdir
Creates one or more directories.
Syntax
mkdir [OPTION]... DIRECTORY...Options
-p, --parentscreate parent directories as needed-v, --verboseprint a message for each created directory-h, --helpshow help
Without -p, creating an existing directory reports an error.
Usage example
/work > mkdir data
/work > mkdir -p logs/app/2026
/work > mkdir -pv build/outputpwd
Prints the current working directory.
Syntax
pwdUsage example
/work > pwd
/workrm
Removes files or directories.
Syntax
rm [OPTION]... FILE...Options
-r, -R, --recursiveremove directories and their contents recursively-d, --dir, --directoryremove empty directories-f, --forceignore nonexistent paths and missing operand errors-v, --verboseprint a message for each removed path-h, --helpshow help
Usage example
/work > rm old.txt
/work > rm -rf cache
/work > rm -d empty-dir
/work > rm -fv temp.txt missing.txtEnvironment Commands
env
Prints environment variables. With no arguments it prints the full environment in sorted order. With one or more names, it prints only those variables.
Syntax
env [NAME]...Usage example
/work > env
/work > env HOME PWDsetenv
Sets an environment variable in the current shell session.
Syntax
setenv NAME VALUE
setenv NAME=VALUEVariable names must start with a letter or _, and may then contain letters, digits, or _.
Usage example
/work > setenv GREETING hello
/work > setenv MESSAGE='hello world'unsetenv
Removes an environment variable from the current shell session.
Syntax
unsetenv NAMEInvalid names or missing arguments produce a usage error.
Usage example
/work > unsetenv GREETINGSystem Commands
pkg
Manages JSH packages and project manifests. For subcommands, options, and workflows, refer to Package Manager.
Syntax
pkg <command> [options] [args...]servicectl
Manages long-running JSH services through the service controller. For subcommands, options, and service-management workflows, refer to Service Manager.
Syntax
servicectl [--controller=<addr>] <command> [args...]Text And Utility Commands
echo
Prints its arguments separated by spaces and terminates with a newline.
Syntax
echo [ARG]...The current implementation does not support shell-style flags such as -n or escape-sequence interpretation.
Usage example
/work > echo hello world
hello worldsleep
Waits for the specified number of seconds before returning.
Syntax
sleep [OPTION] <sec>Options
-h, --helpshow help
Usage example
/work > sleep 5wc
Counts lines, words, bytes, and characters for each file.
If no file is given, or if - is used, it reads standard input.
Syntax
wc [OPTION]... [FILE]...Options
-l, --linesprint line counts-w, --wordsprint word counts-c, --bytesprint byte counts-m, --charsprint character counts-h, --helpshow help
If no count option is selected, wc prints lines, words, and bytes.
Usage example
/work > wc notes.txt
/work > wc -l *.log
/work > cat notes.txt | wc -w -which
Prints where a command resolves in the JSH command path.
Syntax
which <command>If the command cannot be found, which prints an error and returns a non-zero status.
Usage example
/work > which ls
/sbin/ls.jsMessaging Commands
mqtt_pub
Publishes a message to an MQTT broker.
Syntax
mqtt_pub [OPTION]...Options
-t, --topictopic to publish to-b, --brokerbroker address, defaulttcp://localhost:5653-m, --messageinline message payload-f, --filefile containing the payload-q, --qosMQTT QoS level, one of0,1,2-d, --debugprint debug logs-h, --helpshow help
-m and -f are mutually exclusive.
Usage example
/work > mqtt_pub -t sensors/temp -m '{"value":21.5}'
/work > mqtt_pub -b tcp://broker:1883 -t logs/app -f payload.json -q 1nats_pub
Publishes a message to a NATS subject. It can optionally wait for one reply by using an explicit reply subject or request mode.
Syntax
nats_pub [OPTION]...Options
-t, --topicsubject to publish to-s, --subjectalias for--topic-b, --brokerbroker address, defaultnats://localhost:4222-m, --messageinline message payload-f, --filefile containing the payload-r, --replyreply subject to wait on--requestgenerate a temporary inbox subject and wait for one response--timeoutconnect and reply timeout in milliseconds, default10000-d, --debugprint debug logs-h, --helpshow help
-m and -f are mutually exclusive.
Usage example
/work > nats_pub -t events.demo -m 'hello'
/work > nats_pub -s rpc.echo -m 'ping' --request
/work > nats_pub -s rpc.echo -m 'ping' -r reply.demo --timeout 3000Interactive Commands
repl
Starts the JSH JavaScript REPL. This is an interactive JavaScript evaluation environment rather than the command-oriented shell prompt.
Syntax
replshell
Starts a new JSH shell session. Use it when you want to enter a separate shell loop from the current process environment.
Syntax
shell