In this lesson, you will learn how the shell maintains an internal environment table and how specific commands modify this block for child processes.
What is the Environment Table?
Every process in Linux—including your Bash shell—carries a hidden list of key-value pairs known as the Environment Table. Think of this as a "bag of settings" that contains vital information like your username, your terminal type, and your default file paths. When you launch a new program, the shell makes a copy of its own environment table and passes it to the new process.
Modifying the Table
When you run an assignment command like export VAR=value, you are modifying the shell's active environment table. Because the shell is the "parent" process, any new processes (children) you spawn after this command will receive the updated value.
Consider this sequence:
# Set a variable in the shell environment
export MY_PROJECT="Alpha"
# Run a child process (like printenv)
# The child inherits the environment table containing MY_PROJECT
printenv MY_PROJECT
The "Fork" Connection
We previously learned about Shell Forking Behavior, where the shell creates a duplicate of itself to execute commands. When the shell performs a fork, it maps its internal environment table into the memory space of the new process.
Crucially, if a child process modifies its environment table, those changes do not reflect back to the parent shell. The parent and child each have their own independent copies. This is why you cannot change a shell's directory or environment variables from inside a script; the script runs as a child process and its changes vanish as soon as the script finishes, leaving the parent shell exactly as it was.
By modifying the environment table, you are essentially "pre-configuring" the context for everything your shell launches next. You are defining the sandbox that every subsequent command will live in.
Key Takeaway: The environment table is a set of inherited variables, and while a shell can pass its table to children, children cannot modify the environment of their parent.