Windows
Linux
Terminal & Shell Scripting
Terminal
Windows set equivalent in Linux
Lists or modifies environment variables available in the current session.
Windows
→
set
Linux equivalents
export / env
export / env
export / env
Overview
What this command does
Lists or modifies environment variables available in the current session.
Migration tip: Variables set with
export are only available for that session. To make them permanent, add the export line to ~/.bashrc or ~/.profile.Practical tasks
Common use cases
View or set environment variables
Lists or modifies environment variables available in the current session.
env
List all current environment variables
printenv VAR
Print a specific variable's value
export VAR=value
Set a variable for this session
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
env
printenv HOME
export MYVAR="hello"
echo $MYVAR
echo 'export MYVAR="hello"' >> ~/.bashrc
Walkthrough
Examples with explanations
# Windows: set (list all variables)
env # list all environment variables
printenv HOME # show specific variable
# Windows: set MYVAR=hello
export MYVAR="hello" # set for this session
echo $MYVAR # use it
# Permanent — add to ~/.bashrc:
echo 'export MYVAR="hello"' >> ~/.bashrc
Reference
Common options and variations
| Command or option | Use |
|---|---|
env | List all current environment variables |
printenv VAR | Print a specific variable's value |
export VAR=value | Set a variable for this session |
echo $VAR | Display a variable's value |
unset VAR | Remove a variable |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | export / env |
Same command on this distribution. |
| Fedora | same command | export / env |
Same command on this distribution. |
| Arch | same command | export / env |
Same command on this distribution. |
Keep learning