Hands-on Lab·LPIC-1
Login shells and which file is read
Objective 105.1 is about customising the shell environment, and the part that catches people is which file is read when. This guide inserts a marker into every startup file, starts bash as a login shell, an interactive shell and a script, and reads back exactly which files each one loaded - then shows what a child process inherits and what it silently does not.
102: Shells and Scripting Guide 31 of 33 Intermediate
- OSUbuntu 26.04 LTS
- Kernel7.0.0-30-generic
- systemd259
- TimeAbout 26 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 when something works when you log in and fails from cron, a script or a systemd unit. This matters because a non-interactive shell reads none of the files you have been editing, and because an alias that works perfectly in your terminal does not exist anywhere else.
- naming the startup files a login shell reads, and in what order
- knowing that a non-interactive shell reads none of them
- recognising
BASH_ENVas the exception a script will honour - explaining why a Debian-family login shell also reads
~/.bashrc - telling an exported variable from a shell-local one by testing a child
- knowing that functions can be exported and aliases cannot
Before you start
- variables-scope-and-exit-status
-
Which shell is even running
-
Marking every file so it says when it was read
-
A login shell
-
An interactive shell that is not a login shell
-
The shell a script gets
-
What a child process inherits, and what it does not
-
Where PATH comes from and which file wins
-
Putting the account back