Linux Classroom Series – 20/Jul/2020


  • Shell maintains lot of information during our shell session called the environment
  • Programs/applications can use the data stored in this environment to determine info about system’s configuration.
  • In this series
    • printenv
    • set
    • export
    • alias

What gets stored in Environment?

  • Two types of data gets stored in the environment
    • environment variables
    • shell variables
  • In addition to above mentioned variables shell stores
    • aliases
    • shell functions

Examine the Environment

  • Execute the following command
printenv USER
printenv PATH

Preview Preview

  • Now lets execute one more comand
set | less
echo $HOME


  • printenv command shows only environmental variables where set command displays both environment and shell variables
  • we can print variables by adding $ to the varaible name Preview
  • Neither printenv nor set commands show aliases for that we need use command alias Preview

Some Interesting Variables

  • SHELL: The name of your shell program
  • HOME: The path of your home directory
  • LANG: Defines the character set
  • OLDPWD: Previous working directory
  • PATH: A colon-separated list of directories that are searched when you enter the name of a executable program
  • USER: Your username

How is this Environment established

  • When we login into linux system, bash program starts and reads series of configuration scripts called as start up files
  • The exact sequence of files depends on type of shell you have started. There are two types
    • Login shell session: This is the one in which we are prompted for username & password (ssh) Preview
    • A non-login shell: This generally occurs when we launch a terminal in GUI. Preview

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin