# Today I've learned: 
The Basics of Environment Variables

## Environment variables in Linux

It’s a very important topic. There are two types of variables:

1. Shell
    
2. Environment
    

* Variables are KEY=value pairs.
    
* Multiple values looks like this: KEY=value1:value2
    

Simply speaking environment variables determines how the system looks, acts and feels.

To check the default **Environment variables** on your system, you can write this command in your terminal:

```bash
env
```

* Environment Variables are always uppercase
    

##### To see all of the environment variables in a “comfy” way. Use *set* and pipe it into the *more* command.

```bash
set | more
```

Then press *ENTER* and line by line you can see the output. Keep in mind that you can exit the view by hitting *q* key.

Of course there’s still lots of information. It would be nice to filter it. We can pipe the *set* to the *grep* and search for a HISTSIZE env variable. This variable contains the maximum number of commands your command history file will store. These are the commands which you can see with up/down key in your terminal. Default value is usually 1000.

```bash
set | grep HISTSIZE
```

#### Changing HISTSIZE variable

Sometimes we don’t want to leave any evidence on the target system. For that case we could set the *HISTSIZE* value to *0.*

Then system will not store any of your past commands.

```bash
HISTSIZE=0
```

Now try to press the UP key. Previous command won’t show.

Keep in mind that this method only applies to the **current terminal session**. When you close the terminal, changes are lost.

#### Changing the value permanently

Before changing the value permanently it’s always a good idea to save the current value if you’ll want to backup. For example:

```bash
echo $HISTSIZE > ~/valueofHISTSIZE.txt
```

Change your *HISTSIZE* value to *0* and you’ll apply it to all your environments.

```bash
HISTSIZE=0
export HISTSIZE
```

### FINISHING THOUGHTS

Interesting stuff. Thoughts that I have after learning about Environment Variables.

1. So I believe that it’s possible to set up even UI of your system using Environment Variables. For example I can change the Ubuntu appearance in one environment and then change it using other env variables. Nice. I’m not sure how to do it, but i believe that I’ll reach this case. Or some key information on how to do it.
    
2. It’s really nice that you can hide the evidence with *HISTSIZE* environment variable.
    
3. There are LOTS of environment variables that show when you enter the *set* command. I’m curious what other environment variables do.
    

## CREDITS

I’m learning using this book:

Linux Basics For Hackers by OCCUPYTHEWEB (MASTER OTP)
