-
Notifications
You must be signed in to change notification settings - Fork 0
command reference
Every shell built-in across stages 3, 4, and 5 — syntax, behavior, and which stage ships it.
The interactive shell appears in stage 3 with 5 commands, grows to 20 in stage 4, and
settles at 18 in stage 5 (the same set as stage 4 minus alias/unalias). This page is
the authoritative cross-stage command table, verified against
README_SHELL.md and the shell.c command
array in helloworld-os-c-v3 (shell.c:46-49).
| Property | Value |
|---|---|
| Prompt text | shell> |
| Prompt color | Green |
| Max input length | 128 characters |
| Tab completion | Against the command table; single match completes in place, multiple match are listed |
| History | Previously entered commands retained, shown by history
|
| Input source | Polled 8042 keyboard: status 0x64, data 0x60
|
Color conventions: prompt green, system messages yellow, help/info cyan, errors red.
| Command | Syntax | Description | Stage 3 | Stage 4 | Stage 5 |
|---|---|---|---|---|---|
help |
help |
List all commands with one-line descriptions | ✅ | ✅ | ✅ |
clear |
clear |
Clear the screen, reset cursor to top | ✅ | ✅ | ✅ |
echo |
echo [text] |
Print the argument text | ✅ | ✅ | ✅ |
about |
about |
Show OS name, version, system details | ✅ | ✅ | ✅ |
shutdown |
shutdown |
Halt the CPU (cli + hlt) |
✅ | ✅ | ✅ |
calc |
calc <a> <op> <b> |
Evaluate a binary expression (+ - * /) |
— | ✅ | ✅ |
memory |
memory |
Show memory usage / layout | — | ✅ | ✅ |
stats |
stats |
Show system statistics | — | ✅ | ✅ |
history |
history |
List previously entered commands | — | ✅ | ✅ |
ps |
ps |
List processes (PID, name, state) | — | ✅ | ✅ |
run |
run <name> |
Start a sample process (counter, fibonacci, prime) |
— | ✅ | ✅ |
kill |
kill <pid> |
Terminate a process by PID | — | ✅ | ✅ |
suspend |
suspend <pid> |
Move a process to the blocked state | — | ✅ | ✅ |
resume |
resume <pid> |
Return a suspended process to ready | — | ✅ | ✅ |
time |
time |
Current time (HH:MM:SS) from the CMOS RTC | — | ✅ | ✅ |
date |
date |
Current date from the CMOS RTC | — | ✅ | ✅ |
clock |
clock |
Combined date and time | — | ✅ | ✅ |
uptime |
uptime |
Time elapsed since boot | — | ✅ | ✅ |
alias |
alias / alias name=command
|
List aliases, or define one | — | ✅ | — |
unalias |
unalias name |
Remove an alias | — | ✅ | — |
Counts: Stage 3 = 5, Stage 4 = 20, Stage 5 = 18.
| Command | Notes |
|---|---|
help |
The discoverability entry point; lists the active command set. |
clear |
Resets the VGA cursor to the top-left of the 0xB8000 framebuffer. |
echo |
Example: echo Hello, World! prints Hello, World!. |
about |
OS name and version banner. |
history |
Stage 4+. Lists the retained command history. |
shutdown |
Issues cli then hlt, freezing the CPU. |
calc <a> <op> <b> — operators +, -, *, /.
calc 2 + 2
calc 3.14 * 2
calc 10.5 / 2.5
Numbers are parsed into fixed-point integers scaled by 1000 (three fractional digits), so results are accurate to 1/1000. There is no FPU math library.
time, date, clock, uptime read the CMOS RTC through
ports 0x70/0x71 and convert the BCD fields to binary. uptime
reports elapsed time since boot.
| Command | Effect |
|---|---|
ps |
List processes with PID, name, and state. |
run <name> |
Start one of counter, fibonacci, prime. |
kill <pid> |
Terminate a process. |
suspend <pid> |
Move a process to the blocked state. |
resume <pid> |
Return a suspended process to ready. |
Scheduling is cooperative round-robin; sample
processes yield with process_yield(). There is no timer-driven preemption.
| Rule | Detail |
|---|---|
| Define |
alias name=command — no spaces around =
|
| List |
alias with no argument lists current aliases |
| Remove | unalias name |
| Collision | An alias name may not shadow a built-in command |
| Resolution | Aliases are resolved to the target command before dispatch |
alias ll=ps
ll # runs ps
unalias ll
Stage 5 drops alias and unalias, reducing the set to 18.
| Key | Effect |
|---|---|
| Printable keys | Echoed and appended to the line |
| Shift + key | Uppercase letters / shifted symbols (see scancode tables) |
| Backspace | Delete the previous character |
| Tab | Complete the current word against the command table |
| Enter | Submit the line |
💡 Tidbit: Tab completion matches against the very command array shown here (
shell.c:46-49in stage 5). Because stage 5 omitsalias/unaliasfrom that array, typingal<Tab>completes nothing there — but in stage 4 it would offeralias.
⚠️ Caveat:calccarries only three decimal places because the parser scales by exactly 1000.calc 1 / 3yields0.333, not a rounded0.333…; the fourth digit is truncated, not rounded. This is a property of the fixed-point representation, not a bug.
💡 Tidbit:
shutdowndoes not power the machine off — there is no ACPI driver. It runscli; hlt, which masks interrupts and halts the CPU until the next (now-masked) interrupt, effectively freezing QEMU. Close the emulator window to exit.
- Stage 3: interactive shell — the 5-command shell
- Stage 4: clock, processes, calculator — the 20-command shell
- Stage 5: release — the consolidated 18-command set
- CMOS / RTC — backing the time commands
- Cooperative scheduling — backing the process commands
-
Fixed-point arithmetic — backing
calc - Scancode tables — what the keys map to
- Glossary
- Home
Stages
- 1 · Assembly boot
- 2 · C protected mode
- 3 · Interactive shell
- 4 · Clock / processes / calc
- 5 · Stabilized release
Concepts — boot
Concepts — protected mode
Concepts — hardware
Concepts — OS services
Reference
- Memory map
- I/O ports
- GDT descriptor format
- Scancode tables
- Command reference
- Toolchain & build
- Glossary
Guides