Pcornel
Linux · Linux Fundamentals

Shell

Cheat sheet · https://pcornel.dk/topic.php?topic=2654

Back to the Topic

Answer

The shell is the command interpreter: it reads commands, expands variables, globs and substitutions, sets up pipes and redirection, and starts programs. Bash is the common default; sh (dash on Debian) is a smaller POSIX shell.

Remember

Scripts run by sh do not support Bash features ([[ ]], arrays) — use #!/bin/bash. Login, interactive and non-interactive shells read different startup files, so aliases and PATH changes may be missing in scripts and cron.

First checks

  • echo $0; ps -p $$ -o comm= — shell currently running
  • getent passwd $USER | cut -d: -f7 — login shell
  • type <name> — alias, function, builtin or file
  • bash -x script.sh — trace each command as it runs

Commands

sudo -i

Verify in this order

shell started (login/interactive/non-interactive) → startup files read → command line expanded → program executed

Where it usually breaks

First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2654

Confirmation

Confirm action

Continue?