Command hub

Terminal & Shell Scripting commands

CMD batch concepts mapped to Bash/Zsh shell behavior, including environment variables, conditionals, loops, exit codes and aliases.

AliasesControl OperatorsEnvironment VariablesHelpLoopsPipelinesRedirectionScriptsSearchTerminal

Distro notes

Debian/Ubuntu vs Fedora vs Arch

Terminal & Shell Scripting

Debian/Ubuntu apt sudo apt install bash zsh shellcheck

Bash is the default interactive shell for many Debian/Ubuntu installations.

Fedora dnf sudo dnf install bash zsh ShellCheck

Fedora uses Bash by default; ShellCheck package capitalization can differ.

Arch pacman sudo pacman -S bash zsh shellcheck

Arch commonly uses Bash by default, but many users install Zsh or Fish.

Guides

All Terminal & Shell Scripting command guides

48 mappings · 19 expanded guides

doskey /macros→alias Quick reference Aliases List shell aliases Lists defined aliases. Distro equivalents Debian/Ubuntu alias Fedora alias Arch alias Open quick reference → doskey macro=value→alias name="command" Quick reference Aliases Create command alias Creates a temporary shell alias. Distro equivalents Debian/Ubuntu alias name="command" Fedora alias name="command" Arch alias name="command" Open quick reference → & command separator→command1; command2 Quick reference Control Operators Run commands sequentially Runs commands one after another regardless of success. Distro equivalents Debian/Ubuntu command1; command2 Fedora command1; command2 Arch command1; command2 Open quick reference → && operator→command1 && command2 Quick reference Control Operators Run next command on success Runs the second command only if the first succeeds. Distro equivalents Debian/Ubuntu command1 && command2 Fedora command1 && command2 Arch command1 && command2 Open quick reference → || operator→command1 || command2 Quick reference Control Operators Run fallback command Runs the second command only if the first fails. Distro equivalents Debian/Ubuntu command1 || command2 Fedora command1 || command2 Arch command1 || command2 Open quick reference → %TEMP%→echo "${TMPDIR:-/tmp}" Quick reference Environment Variables Show temp directory Prints the temporary directory path. Distro equivalents Debian/Ubuntu echo "${TMPDIR:-/tmp}" Fedora echo "${TMPDIR:-/tmp}" Arch echo "${TMPDIR:-/tmp}" Open quick reference → %USERNAME%→echo "$USER" Quick reference Environment Variables Show username variable Prints the current username environment variable. Distro equivalents Debian/Ubuntu echo "$USER" Fedora echo "$USER" Arch echo "$USER" Open quick reference → %USERPROFILE%→echo "$HOME" Quick reference Environment Variables Show home directory variable Prints the current user home directory. Distro equivalents Debian/Ubuntu echo "$HOME" Fedora echo "$HOME" Arch echo "$HOME" Open quick reference → setx PATH→echo "export PATH="$PATH:/new/path"" >> ~/.bashrc Quick reference Environment Variables Persist PATH change Adds a PATH modification to a shell startup file. Distro equivalents Debian/Ubuntu echo "export PATH="$PATH:/new/path"" >> ~/.bashrc Fedora echo "export PATH="$PATH:/new/path"" >> ~/.bashrc Arch echo "export PATH="$PATH:/new/path"" >> ~/.bashrc Open quick reference → command /?→command --help Quick reference Help Show command help Prints built-in command help when supported. Distro equivalents Debian/Ubuntu command --help Fedora command --help Arch command --help Open quick reference → help command→man command Quick reference Help Open command manual Shows the manual page for a command. Distro equivalents Debian/Ubuntu man command Fedora man command Arch man command Open quick reference → for /r→find . -type f -exec command {} \; Quick reference Loops Loop files recursively Runs a command for each matching file under a tree. Distro equivalents Debian/Ubuntu find . -type f -exec command {} \; Fedora find . -type f -exec command {} \; Arch find . -type f -exec command {} \; Open quick reference → forfiles→find . -mtime +7 -exec rm {} \; Quick reference Loops Run command on matched files Finds files by criteria and runs a command on them. Distro equivalents Debian/Ubuntu find . -mtime +7 -exec rm {} \; Fedora find . -mtime +7 -exec rm {} \; Arch find . -mtime +7 -exec rm {} \; Open quick reference → dir | find→command | grep "pattern" Quick reference Pipelines Pipe output to search Sends command output to a text filter. Distro equivalents Debian/Ubuntu command | grep "pattern" Fedora command | grep "pattern" Arch command | grep "pattern" Open quick reference → 2> redirection→command 2> errors.log Quick reference Redirection Redirect stderr Writes error output to a file. Distro equivalents Debian/Ubuntu command 2> errors.log Fedora command 2> errors.log Arch command 2> errors.log Open quick reference → 2>&1 redirection→command > all.log 2>&1 Quick reference Redirection Merge stdout and stderr Writes normal and error output to the same file. Distro equivalents Debian/Ubuntu command > all.log 2>&1 Fedora command > all.log 2>&1 Arch command > all.log 2>&1 Open quick reference → > redirection→command > file Quick reference Redirection Redirect stdout Writes command output to a file. Distro equivalents Debian/Ubuntu command > file Fedora command > file Arch command > file Open quick reference → %* batch arguments→printf "%s\n" "$@" Quick reference Scripts All script arguments Expands all positional arguments safely. Distro equivalents Debian/Ubuntu printf "%s\n" "$@" Fedora printf "%s\n" "$@" Arch printf "%s\n" "$@" Open quick reference → %1 batch argument→echo "$1" Quick reference Scripts First script argument Reads the first positional parameter in a shell script. Distro equivalents Debian/Ubuntu echo "$1" Fedora echo "$1" Arch echo "$1" Open quick reference → %~dp0 script directory→cd "$(dirname "$0")" Quick reference Scripts Script directory Changes to the directory containing the script. Distro equivalents Debian/Ubuntu cd "$(dirname "$0")" Fedora cd "$(dirname "$0")" Arch cd "$(dirname "$0")" Open quick reference → call script.bat→source script.sh Quick reference Scripts Run script in current shell Sources a shell script so it can modify current shell state. Distro equivalents Debian/Ubuntu source script.sh Fedora source script.sh Arch source script.sh Open quick reference → choice→read -r -p "Continue? [y/N] " answer Quick reference Scripts Prompt for choice Reads an interactive answer from the user. Distro equivalents Debian/Ubuntu read -r -p "Continue? [y/N] " answer Fedora read -r -p "Continue? [y/N] " answer Arch read -r -p "Continue? [y/N] " answer Open quick reference → start cmd /c→bash -c "command" Quick reference Scripts Run command string Executes a command through Bash. Distro equivalents Debian/Ubuntu bash -c "command" Fedora bash -c "command" Arch bash -c "command" Open quick reference → timeout /nobreak→sleep 10 Quick reference Scripts Wait for seconds Pauses script execution for a number of seconds. Distro equivalents Debian/Ubuntu sleep 10 Fedora sleep 10 Arch sleep 10 Open quick reference → where /r→find /path -name "name" Quick reference Search Search recursively for file Finds files by name under a directory tree. Distro equivalents Debian/Ubuntu find /path -name "name" Fedora find /path -name "name" Arch find /path -name "name" Open quick reference → %errorlevel%→$? Expanded guide Terminal Check command success or failure exit code Reads the exit status of the last command. 0 means success; any non-zero value means failure. Distro equivalents Debian/Ubuntu $? Fedora $? Arch $? Open expanded guide → break→Ctrl+C Expanded guide Terminal Interrupt a running command Stops a currently running command or script. Ctrl+C sends SIGINT to the foreground process. Distro equivalents Debian/Ubuntu Ctrl+C Fedora Ctrl+C Arch Ctrl+C Open expanded guide → chcp→locale charmap Quick reference Terminal Show terminal encoding Displays the active character encoding. Distro equivalents Debian/Ubuntu locale charmap Fedora locale charmap Arch locale charmap Open quick reference → cls→clear Expanded guide Terminal Clear the terminal screen Clears all text from the terminal window. Distro equivalents Debian/Ubuntu clear Fedora clear Arch clear Open expanded guide → cmd /k (set title)→alias Expanded guide Terminal Create command shortcuts (aliases) Creates short nicknames for long commands. Add them to ~/.bashrc to make them permanent. Distro equivalents Debian/Ubuntu alias Fedora alias Arch alias Open expanded guide → color→printf "\033[32mgreen\033[0m\n" Quick reference Terminal Print colored terminal text Uses ANSI escape sequences for terminal color. Distro equivalents Debian/Ubuntu printf "\033[32mgreen\033[0m\n" Fedora printf "\033[32mgreen\033[0m\n" Arch printf "\033[32mgreen\033[0m\n" Open quick reference → doskey /history→history Expanded guide Terminal View command history Shows previously run commands. Linux keeps a much longer history than Windows. Distro equivalents Debian/Ubuntu history Fedora history Arch history Open expanded guide → echo→echo Expanded guide Terminal Print text to terminal Displays a line of text. Also used in scripts for variable output. Distro equivalents Debian/Ubuntu echo Fedora echo Arch echo Open expanded guide → exit→exit Expanded guide Terminal Exit the shell or return an exit code Closes the current shell session or exits a script, optionally with a numeric return code. Distro equivalents Debian/Ubuntu exit Fedora exit Arch exit Open expanded guide → for→for ... in ...; do ... done Expanded guide Terminal Loop over a list or range Repeats a block of commands for each item in a list, range, or set of files. Distro equivalents Debian/Ubuntu for ... in ...; do ... done Fedora for ... in ...; do ... done Arch for ... in ...; do ... done Open expanded guide → goto→functions / break / continue Expanded guide Terminal Control flow — replace GOTO with functions Bash has no GOTO. Use functions, break, continue, or restructure logic with loops and conditionals. Distro equivalents Debian/Ubuntu functions / break / continue Fedora functions / break / continue Arch functions / break / continue Open expanded guide → if→if [ condition ]; then ... fi Expanded guide Terminal Conditional branching in scripts Tests a condition and executes different code depending on whether it is true or false. Distro equivalents Debian/Ubuntu if [ condition ]; then ... fi Fedora if [ condition ]; then ... fi Arch if [ condition ]; then ... fi Open expanded guide → mode con→stty -a Quick reference Terminal Show terminal settings Displays terminal line discipline settings. Distro equivalents Debian/Ubuntu stty -a Fedora stty -a Arch stty -a Open quick reference → path→echo $PATH / export PATH Expanded guide Terminal View or modify the command search path Shows or modifies the list of directories the shell searches when you type a command. Distro equivalents Debian/Ubuntu echo $PATH / export PATH Fedora echo $PATH / export PATH Arch echo $PATH / export PATH Open expanded guide → pause→read -p Expanded guide Terminal Pause a script and wait for keypress Halts a script and waits for the user to press a key before continuing. Used frequently in batch files. Distro equivalents Debian/Ubuntu read -p Fedora read -p Arch read -p Open expanded guide → prompt→export PS1="\u@\h:\w\$ " Quick reference Terminal Set shell prompt Changes the shell prompt format. Distro equivalents Debian/Ubuntu export PS1="\u@\h:\w\$ " Fedora export PS1="\u@\h:\w\$ " Arch export PS1="\u@\h:\w\$ " Open quick reference → rem / ::→# Expanded guide Terminal Add comments to scripts Adds human-readable comments to shell scripts that are ignored during execution. Distro equivalents Debian/Ubuntu # Fedora # Arch # Open expanded guide → set→export / env Expanded guide Terminal View or set environment variables Lists or modifies environment variables available in the current session. Distro equivalents Debian/Ubuntu export / env Fedora export / env Arch export / env Open expanded guide → set /a (arithmetic)→$(( expression )) Expanded guide Terminal Perform arithmetic calculations Evaluates mathematical expressions in scripts or at the command line. Distro equivalents Debian/Ubuntu $(( expression )) Fedora $(( expression )) Arch $(( expression )) Open expanded guide → shift→shift Expanded guide Terminal Shift script argument positions Shifts positional parameters ($1, $2...) left by one. Used to process command-line arguments in scripts. Distro equivalents Debian/Ubuntu shift Fedora shift Arch shift Open expanded guide → start (open file/URL)→xdg-open Expanded guide Terminal Open files with default application Opens a file, folder, or URL with the appropriate default application — like double-clicking in the file manager. Distro equivalents Debian/Ubuntu xdg-open Fedora xdg-open Arch xdg-open Open expanded guide → title→echo -ne "\033]0;My Title\007" Expanded guide Terminal Set the terminal window title Changes the title text shown in the terminal emulator's title bar. Distro equivalents Debian/Ubuntu echo -ne "\033]0;My Title\007" Fedora echo -ne "\033]0;My Title\007" Arch echo -ne "\033]0;My Title\007" Open expanded guide → while (goto loop)→while [ condition ]; do ... done Expanded guide Terminal Loop while a condition is true Repeatedly executes commands as long as a condition remains true. Distro equivalents Debian/Ubuntu while [ condition ]; do ... done Fedora while [ condition ]; do ... done Arch while [ condition ]; do ... done Open expanded guide →