Unix/Linux Commands

Interactive terminal for learning Unix/Linux commands. Click buttons in the sidebar or type commands directly.

Example Code

HTML and JavaScript to create this interactive Unix terminal demo.

HTML

<terminal-window id="terminal" theme="dark" prompt="user@linux:~$ " cursor-style="block" cursor-blink="true" welcome="Unix Command Trainer - Type 'help' for available commands." ></terminal-window>

JavaScript

import { registerUnixCommands } from './commands/unix-commands.js'; const terminal = document.getElementById('terminal'); // Register all Unix commands registerUnixCommands(terminal); // Helper to run commands from buttons function run(cmd) { terminal.executeCommand(cmd); }

Custom Command Example

// Simulated ls command terminal.registerCommand('ls', (args) => { const showHidden = args.includes('-a') || args.includes('-la'); const longFormat = args.includes('-l') || args.includes('-la'); let files = ['Documents', 'Downloads', 'Pictures']; if (showHidden) files.unshift('.bashrc', '.profile'); if (longFormat) { return files.map(f => `drwxr-xr-x 2 user user 4096 Jan 15 10:30 ${f}` ).join('\\n'); } return files.join(' '); });