Overview
Theenv command displays all environment variables currently set in the Nash shell session. Each variable is printed in KEY=VALUE format, one per line.
Syntax
Description
Theenv command takes no arguments and lists all environment variables in the current shell context. This includes:
- Default Nash environment variables (USER, HOME, PATH, etc.)
- Variables set with
export - Variables passed via
-Eflag at Nash startup - Variables inherited from parent environment
Options
The Nash
env command does not accept any options or arguments. It always displays all environment variables.Examples
Display All Variables
Filter Specific Variables
Count Variables
Search for Variable Pattern
Sort Variables Alphabetically
Practical Use Cases
Debug Environment Issues
Export Environment Snapshot
Compare Environments
Verify Path Configuration
Check User Context
Default Environment Variables
Nash sets these standard Unix environment variables by default:Current username (set via
-U flag or defaults to user)Same as USER - login name
User’s home directory (
/home/<username>)Current shell (
nash)Terminal type (
xterm-256color)System language (
en_US.UTF-8)Locale setting (
en_US.UTF-8)Executable search path (
/usr/local/bin:/usr/bin:/bin)Current working directory (updated by
cd)Previous working directory (used by
cd -)System hostname (
nash)Shell nesting level (starts at
1)Output Format
Each environment variable is printed as:- No spaces around the
=sign - One variable per line
- No special formatting or quoting
- Order is not guaranteed
Notes
- Variables with empty values are shown as
KEY= - The output includes all variables, not just exported ones
- Variable values may contain special characters or spaces
- Use
exportto modify variables andunsetto remove them
Exit Status
Theenv command always returns exit code 0 (success).
