Arch Linux Environment Variables - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Arch Linux Environment Variables Guide
Complete beginner-friendly guide to environment variables on Arch Linux, including setting variables, PATH configuration, and environment management.
Table of Contents
- Understanding Environment Variables
- Setting Variables
- PATH Configuration
- Common Variables
- Troubleshooting
Understanding Environment Variables
What are Environment Variables?
Environment variables store system configuration.
Common variables:
PATH: Command search pathHOME: User home directorySHELL: Default shellLANG: Language setting
Setting Variables
Temporary Setting
Set for session:
# Set variable
export VARIABLE_NAME=value
# Check
echo $VARIABLE_NAME
Permanent Setting
Set in shell config:
# Bash
vim ~/.bashrc
export VARIABLE_NAME=value
# Zsh
vim ~/.zshrc
export VARIABLE_NAME=value
System-wide
Set for all users:
# Edit profile
sudo vim /etc/profile
# Or environment
sudo vim /etc/environment
PATH Configuration
Add to PATH
Add directory:
# Add to PATH
export PATH=$PATH:/path/to/directory
# Or in bashrc
echo 'export PATH=$PATH:/path/to/directory' >> ~/.bashrc
Check PATH
View PATH:
# Show PATH
echo $PATH
# List directories
echo $PATH | tr ':' '\n'
Common Variables
Language
Set language:
# Set locale
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Editor
Set editor:
# Set default editor
export EDITOR=vim
export VISUAL=vim
Java
Set JAVA_HOME:
# Set Java home
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
export PATH=$PATH:$JAVA_HOME/bin
Troubleshooting
Variable Not Set
Check configuration:
# Check if set
echo $VARIABLE_NAME
# Reload shell config
source ~/.bashrc
Summary
This guide covered environment variables, PATH, common variables, and troubleshooting.
Next Steps
- Arch Linux System Configuration - System setup
- Arch Linux Shell Configuration - Shell setup
- ArchWiki Environment Variables: https://wiki.archlinux.org/title/Environment_variables
This guide is based on the ArchWiki. For the most up-to-date information, always refer to the official ArchWiki.