Learn › Linux Foundations
Bash Shell Environment
Variables, aliases, shell configuration, command lookups, expansions, and quoting. Master the shell itself.
Labs in this module
- Shell Variables vs Environment Variables - Two kinds of variable, one lesson. A plain shell variable is private to the shell you are in; an environment variable is one you exported, s
- printenv - Read the environment with printenv. Print the whole NAME=value list, look up one variable to get its bare value, learn why you pass the plai
- unalias - Take a shortcut back with unalias. Remove one alias by name, watch command not found prove it is gone, meet the not found message for a name
- .bash_profile - The startup file bash runs once at login. Why your aliases vanish over SSH, the sourcing block that pulls in ~/.bashrc, login versus non-log
- .bashrc - The ~/.bashrc file is your personal startup script: bash runs it for every new interactive terminal, so whatever you put there (aliases, exp
- Expansion Ordering - The capstone that ties the Bash Environment module together: the fixed order the shell applies expansions to a command line. Brace expansion
- Word Splitting - After the shell expands an unquoted variable or command substitution, it splits the result into separate words on IFS (space, tab, newline b
- Escape Characters - The backslash is the finest-grained quoting tool: it tells the shell to take the NEXT single character literally, switching off whatever spe
- Quoting - The rule that ties the Bash Environment module together: three quoting modes. Single quotes switch off all expansion (everything literal), d
- Glob Patterns - Act on many files with one short pattern using shell globs. Match any run of characters with , exactly one with ?, and one from a chosen set
- Command Substitution - Let one command find a value and drop it straight into your command line with $(command). Inline a command output into a sentence, capture i
- Tilde Expansion - The shell replaces a leading ~ with a home directory. Print your own home with ~, build a path with ~/Documents, reach another user home wit
- Brace Expansion - Turn one line into many with brace expansion. Build a comma list, glue fixed text around it, count a range with steps and zero padding, mult
- Bash Keyboard Shortcuts - Edit the command line at speed with readline keyboard shortcuts (default emacs mode). Ctrl-A and Ctrl-E jump to the ends, Alt-B and Alt-F mo
- source - Run a script in the CURRENT shell with source, so its variables, aliases, functions, and directory changes stick in your session. The heart
- .profile - Read the POSIX, shell-agnostic login file .profile: the banner that marks it a login file, the block that sources .bashrc only under bash, a
- Reverse Search (Ctrl-R) - Find any command you ran before with Ctrl-R, an incremental reverse search of your shell history. Learn the reverse-i-search frame, the four
- alias - Give a long command a short nickname with alias. Define a shortcut, list every alias in the current shell, look one up by name, and add a sa
- builtin - Force the shell to run its genuine built-in version of a name with builtin, skipping any function that shadowed it. The one-word fix for a w
- The $PATH Variable - PATH is the colon-separated list of directories the shell searches, left to right, to find the program for a bare command name. Read it with
- command - Reach past aliases and functions to the real tool with command. Run the genuine program with command CMD, ask how a name resolves with comma
- whereis - Find the full address of a command with whereis. Read the one-line answer (binary, manual page, and source or config), narrow it with -b, -m
- which - Turn a command name into the real file that runs it with which. Locate ls and interpreters for a script first line, use -a to see every copy
- type - Ask the shell what actually runs with type. It classifies a name as an alias, keyword, function, builtin, or file, and reports the winner in
- env - Meet the invisible list every program inherits, and the one command that both shows it and edits it. Print the whole environment with bare e
- export - Promote a private shell variable into the environment so child programs inherit it. Prove a plain variable is invisible to a child, then mak
- unset - Make a shell variable truly disappear with unset. The plain form, -v for variables and -f for functions, and the distinction that trips ever
- Mission Control: Operation Home Turf - The Bash Environment module capstone mission. Drill export, env/printenv, alias, type/which, command substitution, and brace expansion in on