Certainly! Here are some commonly used environment variables in Unix-like operating systems, along with their purposes:
1. HOME
- Description: Represents the current user's home directory.
- Usage: Used to navigate to the user's personal files and directories.
- Example:
$HOMEmight expand to/home/user.
2. USER
- Description: Contains the username of the currently logged-in user.
- Usage: Useful for scripts that need to customize behavior based on the user.
- Example:
$USERmight returnuser.
3. SHELL
- Description: Indicates the path to the current user's default shell.
- Usage: Useful for scripts that need to know which shell to use.
- Example:
$SHELLmight return/bin/bashor/bin/zsh.
4. PWD
- Description: Stands for "Print Working Directory" and contains the current directory path.
- Usage: Useful for scripts that need to know the current directory.
- Example:
$PWDmight return/home/user/projects.
5. LANG
- Description: Defines the locale and language settings for the user.
- Usage: Affects how programs display text, including language and character encoding.
- Example:
$LANGmight returnen_US.UTF-8.
6. EDITOR
- Description: Specifies the default text editor for command-line applications.
- Usage: Programs like
gitorcrontabwill use this editor for editing files. - Example:
$EDITORmight be set tonanoorvim.
7. PATH
- Description: As discussed earlier, it specifies directories where executable files are located.
- Usage: Allows the shell to find commands without needing the full path.
8. TEMP or TMP
- Description: Points to the directory where temporary files are stored.
- Usage: Used by applications to store temporary data.
- Example:
$TEMPmight return/tmp.
Summary
These environment variables help customize the user experience and control the behavior of applications and scripts. You can view all environment variables in your current session by running the command:
printenv
or
env
If you want to learn more about specific environment variables or their usage in scripts, feel free to ask!
