Menu
“Customizing the shell environment and writing your own Bash scripts.”
Topic 105 is the first topic of the LPIC-1 102-500 exam. It’s about the shell you spend your day in: how Bash sets itself up when it starts, and how to turn the commands you type into scripts that run on their own.
You’ll start with the startup files, variables, PATH, aliases and functions, then write real scripts with tests, loops and exit codes that can warn root when something goes wrong.
You’ll learn:
- Which startup files Bash reads for login and non-login shells, and how Debian and Red Hat chain them
- The difference between shell variables and environment variables, and how to set
PATHsafely - How to write aliases and functions, and give new users default files through
/etc/skel - How to write scripts with a shebang,
test,if,case,for,while,readandseq - How to use exit codes,
&&,||, command substitution andexec, mail root, and install scripts with the right owner and permissions
You’ll need: a Linux machine, a virtual machine or a container such as docker run -it --rm debian or docker run -it --rm ubuntu. Most examples work as a normal user. Editing /etc/skel, creating users and installing scripts into /usr/local/sbin need root or sudo (in a container you’re already root).
- 1 Customize and use the shell environmentWhich startup files Bash reads and when, how variables, PATH, aliases and functions work, and how /etc/skel sets up new users.
- 2 Customize or write simple scriptsWrite Bash scripts with the right shebang, tests, loops, read, seq and command substitution, check exit codes, mail root when something fails, and install scripts safely.

Byte card
The whole topic on one card
- Login shells read /etc/profile, then the first of ~/.bash_profile, ~/.bash_login, ~/.profile.
- Interactive shells read ~/.bashrc: the home of your aliases and functions.
- export puts a variable in the environment, so child processes inherit it.
- Exit status 0 means success: && runs on success, || on failure.
- A script needs a #! line, read and execute rights, and Linux ignores SUID on it.
Save it as a cheat sheet, or share it with someone who's learning this too.