2022-10-05 22:34:56 +00:00
# Linux Environment Variables
2022-04-28 16:01:33 +00:00
2024-07-18 20:49:07 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > [**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > \
Learn & practice GCP Hacking: < img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > [**HackTricks Training GCP Red Team Expert (GRTE)**< img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > ](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-18 20:49:07 +00:00
< details >
2022-04-28 16:01:33 +00:00
2024-07-18 20:49:07 +00:00
< summary > Support HackTricks< / summary >
2024-02-02 12:19:57 +00:00
2024-07-18 20:49:07 +00:00
* Check the [**subscription plans** ](https://github.com/sponsors/carlospolop )!
2024-04-06 16:25:58 +00:00
* **Join the** 💬 [**Discord group** ](https://discord.gg/hRep4RUj7f ) or the [**telegram group** ](https://t.me/peass ) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live** ](https://twitter.com/hacktricks\_live )**.**
2024-07-18 20:49:07 +00:00
* **Share hacking tricks by submitting PRs to the** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) and [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github repos.
2022-04-28 16:01:33 +00:00
< / details >
2024-07-18 20:49:07 +00:00
{% endhint %}
2022-04-28 16:01:33 +00:00
2024-03-14 23:01:13 +00:00
**Try Hard Security Group**
2024-04-06 16:25:58 +00:00
< figure > < img src = "../.gitbook/assets/telegram-cloud-document-1-5159108904864449420.jpg" alt = "" > < figcaption > < / figcaption > < / figure >
2024-03-14 23:01:13 +00:00
{% embed url="https://discord.gg/tryhardsecurity" %}
***
2022-10-05 22:34:56 +00:00
## Global variables
2020-07-15 15:43:14 +00:00
2022-02-14 02:21:08 +00:00
The global variables **will be** inherited by **child processes** .
2020-07-15 15:43:14 +00:00
2021-10-30 12:23:41 +00:00
You can create a global variable for your current session doing:
2020-07-15 15:43:14 +00:00
```bash
export MYGLOBAL="hello world"
echo $MYGLOBAL #Prints: hello world
```
This variable will be accessible by your current sessions and its child processes.
You can **remove** a variable doing:
```bash
unset MYGLOBAL
```
2022-10-05 22:34:56 +00:00
## Local variables
2020-07-15 15:43:14 +00:00
The **local variables** can only be **accessed** by the **current shell/script** .
```bash
LOCAL="my local"
echo $LOCAL
unset LOCAL
```
2022-10-05 22:34:56 +00:00
## List current variables
2020-07-15 15:43:14 +00:00
```bash
set
env
printenv
cat /proc/$$/environ
cat /proc/`python -c "import os; print(os.getppid())"`/environ
```
2022-10-05 22:34:56 +00:00
## Common variables
2020-07-15 15:43:14 +00:00
From: [https://geek-university.com/linux/common-environment-variables/ ](https://geek-university.com/linux/common-environment-variables/ )
* **DISPLAY** – the display used by **X** . This variable is usually set to ** :0.0**, which means the first display on the current computer.
* **EDITOR** – the user’ s preferred text editor.
* **HISTFILESIZE** – the maximum number of lines contained in the history file.
2023-09-25 19:16:51 +00:00
* **HISTSIZE** – Number of lines added to the history file when the user finish his session
2020-07-15 15:43:14 +00:00
* **HOME** – your home directory.
* **HOSTNAME** – the hostname of the computer.
* **LANG** – your current language.
* **MAIL** – the location of the user’ s mail spool. Usually ** /var/spool/mail/USER**.
* **MANPATH** – the list of directories to search for manual pages.
* **OSTYPE** – the type of operating system.
* **PS1** – the default prompt in bash.
2023-09-25 19:16:51 +00:00
* **PATH** – stores the path of all the directories which holds binary files you want to execute just by specifying the name of the file and not by relative or absolute path.
2020-07-15 15:43:14 +00:00
* **PWD** – the current working directory.
2021-10-18 11:21:18 +00:00
* **SHELL** – the path to the current command shell (for example, ** /bin/bash**).
* **TERM** – the current terminal type (for example, **xterm** ).
2020-07-15 15:43:14 +00:00
* **TZ** – your time zone.
* **USER** – your current username.
2022-10-05 22:34:56 +00:00
## Interesting variables for hacking
2020-07-15 15:43:14 +00:00
2022-10-05 22:34:56 +00:00
### **HISTFILESIZE**
2020-07-15 15:43:14 +00:00
2021-11-05 20:59:42 +00:00
Change the **value of this variable to 0** , so when you **end your session** the **history file** (\~/.bash\_history) **will be deleted** .
2020-07-15 15:43:14 +00:00
```bash
export HISTFILESIZE=0
```
2022-10-05 22:34:56 +00:00
### **HISTSIZE**
2020-07-15 15:43:14 +00:00
2021-11-05 20:59:42 +00:00
Change the **value of this variable to 0** , so when you **end your session** any command will be added to the **history file** (\~/.bash\_history).
2020-07-15 15:43:14 +00:00
```bash
export HISTSIZE=0
```
2023-01-18 13:30:35 +00:00
### http\_proxy & https\_proxy
2020-07-15 15:43:14 +00:00
2023-01-18 13:30:35 +00:00
The processes will use the **proxy** declared here to connect to internet through **http or https** .
2020-07-15 15:43:14 +00:00
```bash
export http_proxy="http://10.10.10.10:8080"
2023-01-18 13:30:35 +00:00
export https_proxy="http://10.10.10.10:8080"
2020-07-15 15:43:14 +00:00
```
2023-01-18 13:30:35 +00:00
### SSL\_CERT\_FILE & SSL\_CERT\_DIR
2020-07-15 15:43:14 +00:00
2023-01-18 13:30:35 +00:00
The processes will trust the certificates indicated in **these env variables** .
2020-07-15 15:43:14 +00:00
```bash
2023-01-18 13:30:35 +00:00
export SSL_CERT_FILE=/path/to/ca-bundle.pem
export SSL_CERT_DIR=/path/to/ca-certificates
2020-07-15 15:43:14 +00:00
```
2022-10-05 22:34:56 +00:00
### PS1
2020-07-15 15:43:14 +00:00
Change how your prompt looks.
2024-02-05 02:28:59 +00:00
[**This is an example** ](https://gist.github.com/carlospolop/43f7cd50f3deea972439af3222b68808 )
2020-07-15 15:43:14 +00:00
Root:
2024-05-05 17:56:05 +00:00
![](< .. / . gitbook / assets / image ( 897 ) . png > )
2020-07-15 15:43:14 +00:00
Regular user:
2024-05-05 17:56:05 +00:00
![](< .. / . gitbook / assets / image ( 740 ) . png > )
2020-07-15 15:43:14 +00:00
One, two and three backgrounded jobs:
2024-05-05 17:56:05 +00:00
![](< .. / . gitbook / assets / image ( 145 ) . png > )
2020-07-15 15:43:14 +00:00
2021-10-30 12:23:41 +00:00
One background job, one stopped and last command didn't finish correctly:
2020-07-15 15:43:14 +00:00
2024-05-05 17:56:05 +00:00
![](< .. / . gitbook / assets / image ( 715 ) . png > )
2022-04-28 16:01:33 +00:00
2024-03-14 23:01:13 +00:00
**Try Hard Security Group**
2024-04-06 16:25:58 +00:00
< figure > < img src = "../.gitbook/assets/telegram-cloud-document-1-5159108904864449420.jpg" alt = "" > < figcaption > < / figcaption > < / figure >
2024-03-14 23:01:13 +00:00
{% embed url="https://discord.gg/tryhardsecurity" %}
2024-07-18 20:49:07 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > [**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)< img src = "/.gitbook/assets/arte.png" alt = "" data-size = "line" > \
Learn & practice GCP Hacking: < img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > [**HackTricks Training GCP Red Team Expert (GRTE)**< img src = "/.gitbook/assets/grte.png" alt = "" data-size = "line" > ](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-18 20:49:07 +00:00
< details >
2022-04-28 16:01:33 +00:00
2024-07-18 20:49:07 +00:00
< summary > Support HackTricks< / summary >
2024-02-02 12:19:57 +00:00
2024-07-18 20:49:07 +00:00
* Check the [**subscription plans** ](https://github.com/sponsors/carlospolop )!
2024-04-06 16:25:58 +00:00
* **Join the** 💬 [**Discord group** ](https://discord.gg/hRep4RUj7f ) or the [**telegram group** ](https://t.me/peass ) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live** ](https://twitter.com/hacktricks\_live )**.**
2024-07-18 20:49:07 +00:00
* **Share hacking tricks by submitting PRs to the** [**HackTricks** ](https://github.com/carlospolop/hacktricks ) and [**HackTricks Cloud** ](https://github.com/carlospolop/hacktricks-cloud ) github repos.
2022-04-28 16:01:33 +00:00
< / details >
2024-07-18 20:49:07 +00:00
{% endhint %}