Environment Variables#
You've already seen a environment variable really, really recently. In the last section's challenge, you played a letting guessing game. The script that you copied used an environment variable - several in fact... $RANDOM
.
Environment variables are like little pieces of data stored in and around the environment you're using (hence the name.) They're sort of like having pieces of paper inside your pocket with information on - phone numbers, secret tokens, filenames, etc. - that move around with you as you go about your business, walking about.
But the moment you log out of that system and into another one (or change the garment you're wearing so the pockets change) the environment variables from the previous environment are gone and new ones come into your environment (pocket.)
Log into your VM and on at the shell prompt, type: env
. Here's what I get (some things are redacted because they're too long):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Notice how there's a pattern: SOME_KEY=some_value
? Environment variables consist of two components: a name, which is usually upper case; and a value, which can be just about anything.