Inspect and modify environment variables to troubleshoot user issues caused by misconfigured session state. Validate PATH, enumerate the current environment, create and verify a custom variable, persist it via shell startup files, and remove it cleanly.
You are troubleshooting a user issue related to PATH and custom environment variables. The user reports “commands not found” behavior and inconsistent application paths between sessions. Your job is to inspect the current environment, validate PATH, add a project variable for a deployment directory, make it persistent, then remove it safely.
Environment variables influence process behavior, command lookup, and tool defaults. A clean, repeatable workflow is to validate current state, apply a minimal change, verify it immediately, then persist it only if required.
PROJECT_DIR.
~/.bashrc.echo.
env
or
printenv
.
export
.
~/.bashrc).
unset.
echo $PATH
PATH
controls where the shell searches for executables. If a user
reports “command not found,” validate PATH early to confirm
the expected directories are present and ordered correctly.
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
printenv
# OR
env
printenv
and
env
provide a snapshot of session state. This helps you catch
unexpected overrides and confirms what values are actually
inherited by processes launched from the shell.
SHELL=/bin/bash
USER=lab
LOGNAME=lab
HOME=/home/lab
PWD=/home/lab
HOSTNAME=env-lab
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LANG=en_US.UTF-8
...
export PROJECT_DIR=/srv/app
export
sets the variable in the current shell and ensures child
processes inherit it. This is the standard pattern when you
need an application or script to see a session-level value.
echo $PROJECT_DIR
Verify immediately after you set the variable. This confirms there were no typos and the shell is holding the expected value.
/srv/app
echo 'export PROJECT_DIR=/srv/app' >> ~/.bashrc
Appending to ~/.bashrc ensures the variable is
set each time an interactive shell starts. This is useful
when a user relies on the variable for daily workflow.
unset PROJECT_DIR
unset
removes the variable from the current shell session. This is
useful when testing behavior and verifying whether a value
is being pulled from startup files or set dynamically.
echo $PATH
: Prints the current PATH value used for command lookup.
printenv
: Prints environment variables for the current session.
env
: Displays the current environment; also commonly used to
run a command with a modified environment.
export NAME=value
: Sets a variable in the current shell and exports it to
child processes.
echo $NAME
: Prints the current value of an environment variable.
echo 'export NAME=value' >> ~/.bashrc
: Appends a variable export to ~/.bashrc so it
is set automatically in new interactive shells.
>>
appends to the file without overwriting existing
content.
unset NAME
: Removes a variable from the current shell session.