| name | linux-environment-variables |
| description | How to manage, configure, and secure Linux environment variables. Use this skill whenever the user needs to set, modify, or understand environment variables on Linux systems, configure proxies, hide command history, manage SSL certificates, customize prompts, or troubleshoot variable inheritance issues. Trigger for any task involving export, unset, PATH, proxy settings, HISTCONTROL, or environment variable security. |
Linux Environment Variables
A skill for managing Linux environment variables, including security hardening, proxy configuration, and system customization.
When to Use This Skill
Use this skill when you need to:
- Set or modify environment variables (global or local)
- Configure proxy settings for network tools
- Hide or control command history for security
- Manage SSL certificate paths
- Customize bash prompts (PS1)
- Debug variable inheritance issues
- Understand what common environment variables do
Core Concepts
Global vs Local Variables
Global variables are inherited by child processes:
export MYVAR="value"
echo $MYVAR
unset MYVAR
Local variables only exist in the current shell:
LOCAL="value"
echo $LOCAL
Listing Variables
set
env
printenv
cat /proc/$$/environ
cat /proc/$(python -c "import os; print(os.getppid())")/environ
Common Environment Variables
| Variable | Purpose |
|---|
DISPLAY | X display (usually :0.0) |
EDITOR | Preferred text editor |
HOME | User's home directory |
HOSTNAME | Computer hostname |
LANG | Current language |
PATH | Directories containing executables |
PWD | Current working directory |
SHELL | Current shell path (e.g., /bin/bash) |
TERM | Terminal type (e.g., xterm) |
USER | Current username |
TZ | Time zone |
Security & Hardening
Hiding Command History
Prevent commands from being saved to ~/.bash_history:
export HISTFILESIZE=0
export HISTSIZE=0
export HISTCONTROL=ignorespace
Usage: Commands prefixed with a space won't be saved:
$ echo "this saves"
$ echo "this does not save"
Proxy Configuration
Set HTTP/HTTPS proxies:
export http_proxy="http://10.10.10.10:8080"
export https_proxy="http://10.10.10.10:8080"
Set SOCKS proxy for all protocols:
export all_proxy="socks5h://10.10.10.10:1080"
Bypass proxy for specific hosts:
export no_proxy="localhost,127.0.0.1,.corp.local,10.0.0.0/8"
Note: Both lowercase and uppercase variants work (http_proxy/HTTP_PROXY).
SSL Certificate Configuration
Point tools to custom CA certificates:
export SSL_CERT_FILE=/path/to/ca-bundle.pem
export SSL_CERT_DIR=/path/to/ca-certificates
Customizing Your Prompt (PS1)
The PS1 variable controls your bash prompt appearance. Common elements:
\u - username
\h - hostname
\w - current directory
\$ - # for root, $ for users
\! - command number
\d - date
\t - time
Example prompt:
export PS1="\u@\h:\w\$ "
Scripts
Use the bundled scripts for common tasks:
scripts/list-variables.sh - Display all environment variables in a formatted table
scripts/hide-history.sh - Configure history hiding for security
scripts/set-proxy.sh - Configure proxy settings with validation
Troubleshooting
Variable not persisting
If a variable disappears after closing the terminal, add it to your shell config:
echo 'export MYVAR="value"' >> ~/.bashrc
source ~/.bashrc
Child process not seeing variable
Make sure you used export:
MYVAR="value"
export MYVAR="value"
PATH issues
Check if a command is in your PATH:
which command_name
hash -r
Best Practices
- Use
export for variables child processes need
- Set
HISTCONTROL=ignorespace for sensitive work
- Validate proxy URLs before setting them
- Document custom variables in your shell config
- Use
printenv to verify variables are set correctly
- Be careful with
PATH modifications - they affect all commands