Debian Study Notes profile file interconnection, environment variable explanation

Source: Internet
Author: User
Debian learning notes profile file, environment variable explanation-Linux Release Technology-Debian information, the following is a detailed description. In the linux system, everyone will be exposed to the problem of environment variables. At the beginning, I felt a little difficult. After many verifications, I summarized some personal opinions, which should not be a problem.

1. Linux is a multi-user operating system. Each user logs on to the system and has a dedicated runtime environment. Generally, the default environment of each user is the same. The default environment is actually the definition of a set of environment variables. You can customize your running environment by modifying the corresponding system environment variables.

2. Modify the environment variables in the/etc/profile file. The modified content is effective for all users. The following operations will be performed in this file.

3. How to add environment variables.
For example, add "NAME = liheng".
Add the following content at the end of the profile file: export NAME = liheng
The variable value liheng can be enclosed in quotation marks or not, and the effect is the same.

4. The added or modified content in the profile file must be logged out of the system to take effect.

5. How to understand repeated variables.
It is often the definition of the path variable.
For example, in the peofile file, PATH variables are all set by default, generally, it is added to the last PATH of the profile file ). In the system, the identified PATH =, the post-write takes effect first (in general ). Everyone must pay attention to it.

6. special characters.
For example, if the profile contains the following content, use the following content to describe the usage of special symbols.

Export A =/q/jing: aaa/cc/ld
Export B =.:/liheng/wang
Export A =/cd/cdr: $

Note the red symbol:
: Represents the meaning of the parallel expression. For example, A variable has multiple values and is separated by A symbol.
. Indicates the current directory you are operating on. For example, the pap command looks for environment variable B.
Type the pap command in/home. The system first searches for the content about B in the/home Directory (that is, the current path), if the content about B is not found in the/liheng/wang directory.

$ Indicates the value before this definition. For example, $ A indicates/q/jing: aaa/cc/ld. That is to say
A =/cd/cdr:/q/jing: aaa/cc/ld

7. Use the env command to display all environment variables. Enter env at the command prompt. The set command displays all locally defined Shell variables.

8. Common Environment Variables
PATH: determines the directories to which shell will look for commands or programs.
HOME: HOME Directory of the current user
MAIL: refers to the MAIL storage directory of the current user.
SHELL: The Shell used by the current user.
HISTSIZE: the number of historical Command records.
LOGNAME: The Login Name of the current user.
HOSTNAME: indicates the host name. If a host name is used by many applications, it is usually obtained from this environment variable.
LANG/LANGUGE: it is a language-related environment variable. Users in multiple languages can modify this environment variable.
PS1: A Basic prompt. For root users, it is # And for common users, it is $.
PS2: A subsidiary prompt. The default value is "> ". You can modify this environment variable to modify the current command line. For example, the following command will change the prompt to the string "Hello, My NewPrompt :)". # PS1 = "Hello, My NewPrompt :)"

9. Use the modify. bashrc file to edit environment variables, which is only useful to the current user. Editing environment variables using the/etc/profile file is useful to all users. You must pay attention to the differences.

10. The profile file will be run when the system starts. You can add other commands in it, but you must add them correctly. Otherwise, the system will fail to start.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.