KandZ – Tuts

We like to help…!

Linux CLI 23 🐧 printenv and export commands

printenv → is used to display all environment variables 
printenv USER → displays the username
you can also print the variables using echo $variable
echo $USER → displays the user variable
common environment variables:
HOME → user's home directory USER → current username
PATH → list of directories the system looks for commands PWD → Present working directory
LANG → default language setting HOSTNAME → name of the computer
DISPLAY → default :0 the first display generated SHELL → current shell program

set is used to set and unset environment variables but...
if you use it with no arguments prints environment and shell variables and functions
export → displays all the exported variables
export -p → displays all exported variables on current shell
export -f functionName → exports a function
export test="kronos" → set environment variable temporarily
if you want to permanently set it, then → echo "export VAR_NAME='value'" ~/.bashrc
and then → source ~/.bashrc

Leave a Reply