Hands-on Lab·LPIC-1
Variables, scope and exit status
Objective 105 is shell customisation and scripting, and two ideas carry most of it: a script runs in a child process unless you source it, and the only thing a caller learns is the exit status. This guide demonstrates both by running the same script three ways and watching whether a change escapes.
102: Shells and Scripting Guide 13 of 33 Beginner
- OSUbuntu 26.04 LTS
- Kernel7.0.0-30-generic
- systemd259
- TimeAbout 19 min
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| LPIC1-A01 | 192.168.0.76 | Ubuntu 26.04 LTS | Debian-family host - dpkg and apt, which objective 102.4 names | 2 Core | 4 GB | 50 GB |
This guide includes
Use this for the two ideas that carry the scripting objective. This matters because the shebang decides which shell runs your script - not the one you logged in with, which on these hosts is zsh.
- finding that the shebang decides, not your login shell
- demonstrating scope three ways, from one script
- using exit status, which is the only thing a caller sees
Before you start
-
The shebang decides, not your login shell
-
Scope, demonstrated three ways
-
Exit status is the only thing a caller sees