Linux Profile (reproduced)

Source: Internet
Author: User

Original address: http://www.cnblogs.com/mmfzmd517528/archive/2012/07/05/2577988.html

Mark Yellow is a personal endorsement.

environment variable is a system variable, the system configures a key-value, then other program can read to this key-value, as configuration.

Linux/etc/profile file changes will involve the environment of the system, that is, about the Linux environment variables, learning Linux to understand the Linux profile related principles, here is the file for specific analysis. This modification will work for all users.

1, Linux is a multi-user operating system. After each user logs on to the system, there is a dedicated runtime environment. Typically, the default environment for each user is the same, and the default environment is actually the definition of a set of environment variables. Users can customize their own operating environment by modifying the appropriate system environment variables.

2, often in the/etc/profile file to modify the environment variables, where the content is modified for all users to work. The following main actions will be made in this file.

3, how to add environment variables.

For example, add "Name=liheng". At the end of the profile file, add the following: Export Name=liheng

Variable value Liheng can be quoted or not added, the same effect.

4, the content added or modified in the profile need to log off the system to take effect.

5. How to understand the repeated definition of variables.

A common occurrence is the definition of the path variable.

For example: In the Peofile file default to the path variable is set Path=¥¥¥¥¥¥¥ (remember), in the future may be in the path setting, usually added to the profile file at the end path= (an analogy). And the path= identified in the system ¥¥¥¥¥¥¥¥¥, that is, the environment variable of the same name, which is the first function of the post-write (in layman's words). We must pay attention to it.

6. Introduction of special characters.

For example, in profile, the use of special symbols is explained by the following:

Export A=/Q/JING:AAA/CC/LD

Export b=.:/ Liheng/wang Export A=/CD/CDR: $A

Everyone notice the red symbol:

: Indicates a side-by-side meaning, for example a variable value has multiple, separated by: symbol.

. Represents the current directory you are manipulating. For example, the PAP command looks for a B environment variable.

At/home Type the PAP command, the system first looks at the contents of B in the/home directory (i.e. the current path), linuxidc.com ">www.linuxidc.com if there is no content found in the/liheng/wang directory about B. $ represents the value before the variable is defined this time, for example, $ A represents/q/jing:aaa/cc/ld. Which means a=/cd/cdr:/q/jing:aaa/cc/ld.

7. Use the ENV command to display all environment variables. You can type env at the command prompt.

The SET command displays all locally defined shell variables.

8. Common environment variables

PATH: Determines to which directories the shell will look for commands or programs

Home: Current User home Directory

Mail: Refers to the current user's message store directory.

Shell: Refers to what kind of shell is used by the current user.

Histsize: Refers to the number of records in which history commands are saved.

LOGNAME: Refers to the login name of the current user.

HOSTNAME: Refers to the name of the host, and many applications are usually obtained from this environment variable if they want to use the host name.

Lang/languge: is a language-related environment variable that users of multiple languages can modify.

PS1: Is the basic prompt, for the root user is #, for the average user is $.

PS2: is a secondary prompt, the default is ">". You can modify the current command by modifying this environment variable, such as the following command to modify the prompt to a string "hello,my newprompt:) "。

# ps1= "Hello,my newprompt:) "

9. Edit the environment variables using the modified. bashrc file (in the user's home directory), which is only useful for the current user. Editing the environment variables using the Modify/etc/profile file is useful for all users. We must pay attention to the difference.

10. The Linux profile will be run when the system is started. You can add other commands inside, but be sure to add them correctly, otherwise the system will not start up.

There is another way:

Console settings, not in favor of this way, because he only works on the current shell, and changing a shell setting is invalid:

$PATH = "$PATH":/new_path (Close shell path reverts to the original path)

Linux Profile (reproduced)

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.