DEV Community

Josh
Josh

Posted on

Linux Environment Variables

Environmental Variables: Variables that are available to your shell. they can be used in scripts that are run from the shell.



# View list of all your environment variables.
env

# This shows paths for all executable programs:
echo $PATH

# Create your own environmental variable:
export MY_ENV_VAR="My custom environmental var"
# Check if it worked using grep:
env | grep MY_ENV_VAR

# Make permanent variables
vi ~/.zshrc
# Now add your custom variables in
export MY_ENV_VAR="My custom environmental var"
export PATH="$PATH:$HOME/bashscripts"
# Then run this to take affect instead of restarting your terminal
source ~/.zshrc

# Remove variable
unset MY_VAR
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay