← All commands
Topic hub Terminal & Shell Scripting
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
Debian/Ubuntu same command
export / env
Fedora same command
export / env
Arch same command
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 optionUse
envList all current environment variables
printenv VARPrint a specific variable's value
export VAR=valueSet a variable for this session
echo $VARDisplay a variable's value
unset VARRemove 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.

DistributionPackage manager / baseEquivalent commandDifference 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

Related Terminal & Shell Scripting commands