Windows set equivalent in Linux
Lists or modifies environment variables available in the current session.
set
export / env
export / env
export / env
Overview
What this command does
On Windows, "set" is used to view or set environment variables. On Linux, the closest practical mapping shown here is "export / env". Lists or modifies environment variables available in the current session. This reference is grouped under Terminal & Shell Scripting → Terminal.
Windows → Linux context
What changes when you use this on Linux?
Equivalent task, different tool
Windows set maps to export / env for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.
Portable across the compared distros
The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.
For the broader concept behind this mapping, read Linux command-line basics.
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
Debian/Ubuntu, Fedora and Arch all use "export / env" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.
| 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