Chapter 21
What's In Your Environment (env, echo, Env:)

21.1 Do This


Source 39: Linux/Mac OSX Exercise 21
  $ env
  TERM_PROGRAM=Apple_Terminal
  TERM=xterm
  SHELL=/bin/bash
  OLDPWD=/Users/zed/temp
  USER=zed
  COMMAND_MODE=unix2003
  PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
  PWD=/Users/zed/
  LANG=en_US.UTF-8
  PS1=$ 
  SHLVL=1
  HOME=/Users/zed
  LOGNAME=zed
  _=/usr/bin/env
  $ env | grep zed
  OLDPWD=/Users/zed//temp
  USER=zed
  PWD=/Users/zed/
  HOME=/Users/zed
  LOGNAME=zed
  $ echo $USER
  zed
  $ echo $PWD
  /Users/zed/
  $ export TESTING="1 2 3"
  $ echo $TESTING
  1 2 3
  $ env | grep TESTING
  TESTING=1 2 3
  $


Source 40: Windows Exercise 21
  > get-childitem Env:
  
  Name                           Value
  ----                           -----
  ALLUSERSPROFILE                C:\ProgramData
  APPDATA                        C:\Users\zed\AppData\Roaming
  ...
  
  
  > $env:PROMPT
  $P$G
  > $env:TEMP
  C:\Users\zed\AppData\Local\Temp
  > $env:OS
  Windows_NT
  >

21.2 You Learned This

Your shell has these "hidden variables" that can change how other programs work. In this exercise I first print out my environment, just dumping it to the screen. Then I do it again but pipe it through grep to find only the variables with my username in them. Finally, I set an environment variable TESTING to "1 2 3".

You may not run into this too often, but sometimes to get something configured you have to change these. A good example is the PATH variable, which determines the search order for other commands. Changing your PATH is going to be one of your exercises.

21.3 Do More

  1. I want you to go online and research how you change your PATH for your computer. Try to do it entirely from the CLI.


Online Video Course + PDF For $9

For the price of most other course's PDFs only, you can get the full PDF for this class and 2 videos demonstrating the whole book for both Unix/OSX Terminal and Windows PowerShell. The course is self-paced so you can go through it any time you want, as many times as you want.


Signup Now At Udemy.com For $9