Fundamentals 2 min read

Shell Environment Variables and Common System Variables

This article introduces Linux shell environment variables, demonstrates how to display common built‑in variables such as PWD, HOME, HOSTNAME, BASH_VERSION, BASH_VERSINFO, GROUPS, SHELL, and UID using echo commands, and explains the use of env to view all variables and export to set them.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Shell Environment Variables and Common System Variables

Shell environment variables are special variables that store system and user information for the shell.

Common built‑in variables include: echo $PWD – prints the current working directory, e.g., /root. echo $HOME – prints the home directory of the current user, e.g., /root. echo $HOSTNAME – prints the host name of the machine, e.g., node1. echo $BASH_VERSION – prints the version string of Bash, e.g., 4.2.46(1)-release. echo $BASH_VERSINFO – prints the major version number, e.g., 4. echo $GROUPS – prints the group IDs the user belongs to, e.g., 0. echo $SHELL – prints the path to the current shell executable, e.g., /bin/bash. echo $UID – prints the numeric user identifier, e.g., 0 for root.

Use the env command to list all current environment variables, and the export command to set or modify them.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Bash
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.