Users, groups and environment
Explain shell variables and exported environment variables, inspect PATH, and configure a temporary project variable safely.
Explanation
Variables and child processes
A shell variable exists in the current shell. export places it in the environment inherited by commands started from that shell. This is how EDA setup scripts provide paths and license or tool settings to simulators.
PATH is an ordered list of directories searched for executable commands. Use command -v tool to see what will run. Do not place the current directory or an untrusted writable directory before trusted system directories.
Commands you will use
| Command | What it does | Example |
|---|---|---|
env |
Prints exported environment variables. | env |
printenv |
Prints one exported value. | printenv PATH |
export |
Exports a variable to child processes. | export PROJECT_HOME="$HOME/project" |
unset |
Removes a variable from the current shell. | unset PROJECT_HOME |
command -v |
Shows the executable selected through PATH. |
command -v python3 |
type |
Explains whether a name is an executable, alias, function, or built-in. | type cd |
source |
Runs a trusted setup file in the current shell. | source tools/setup.sh |
alias |
Defines an interactive shortcut. | alias ll='ls -lh' |
Startup files such as .bash_profile and .bashrc can make settings persistent. Test a setting in the current shell before changing a startup file. Never store passwords or tokens in shell history or course evidence.
Worked example
mkdir -p "$HOME/asic-linux-practice/project"
PROJECT_HOME="$HOME/asic-linux-practice/project"
printf 'current shell: %s\n' "$PROJECT_HOME"
sh -c 'printf "before export: %s\n" "$PROJECT_HOME"'
export PROJECT_HOME
sh -c 'printf "after export: %s\n" "$PROJECT_HOME"'
command -v bash
type cd
unset PROJECT_HOME
Expected result: the first child shell sees an empty value; after export, the next child shell receives the project path.
Common mistakes
- Writing a change to
.bashrcbefore testing it. - Appending the same directory to
PATHevery time a setup script runs. - Sourcing an unknown script.
- Printing secrets while collecting environment evidence.
- Using a broad
LD_LIBRARY_PATHchange instead of identifying the required library.
Check yourself
Why can a child process read an exported variable but not an ordinary shell variable?
Practice: Users, groups and environment
Export PROJECT_HOME, start a child Bash process that prints it, then unset it. Record the executable path and version of one available engineering tool.
Practice work is non-certified and is not stored by ASIC Campus.