Environment variable modification method

Source: Internet
Author: User
Environment variable modification method 1./etc/profile: the first file used by the operating system to customize the user environment during logon. this file sets environment information for each user of the system, this file is executed when the user logs on for the first time. 2./etc/environment: The second type used by the operating system during logon... environment variable modification method 1./etc/profile: the first file used by the operating system to customize the user environment during logon. this file sets environment information for each user of the system, this file is executed when the user logs on for the first time. 2./etc/environment: the second file used by the operating system during logon. before the system reads your own profile, it sets the environment variable of the environment file. 3 ,~ /. Bash_profile: The third file used for logon is. bash_profile file. each user can use this file to input shell Information dedicated to their own use. when a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file. /Etc/bash. bashrc: execute this file for every user running bash shell. When bash shell is opened, the file is read. 4 ,~ /. Bashrc: This file contains bash information dedicated to your bash shell. This file is read when you log on and every time you open a new shell. Priorities of several files: 1> 2> 3. in linux, if the file is in the bash environment, the user reads the set file in the order of/etc/profile --> ~ /. Bash_profile --> ~ /. Bashrc -->/etc/bash. bashrc. Note that ~ /. Bash_profile, if no ~ /. Bash_profile, the default read ~ /. Bash_login. If no ~ /. Bash_login to read ~ /. Profile. Based on the release version, there are two basic system-level configuration files:/etc/bash. bashrc and/etc/profile. These configuration files contain two different variables: shell variables and environment variables. The former is only fixed in a specific shell (such as bash), and the latter is fixed in different shells. Shell variables are local, while environment variables are global. Note: avoid modifying the environment variable configuration file of the root user as much as possible, because this may cause potential risks. It is recommended that you do not put the current PATH "./" in the PATH, which may cause unexpected attacks. Usage: give the set environment variables to all users:/etc/bashrc; /etc/profile modify the global environment variable in/etc/profile modify the environment variable of a user in/home/user name /. bash_profile: execute the script with sh *. sh file, where *. sh contains the declare variable declaration, but the reality is not found declare, using chmod 755 *. sh, and then. /*. the sh script runs normally or directly bash *. sh can also run, because sh is linked to dash, not bash. During Ubuntu installation, dash is faster and more compatible than bash! But some sh that can run normally in bash cannot be used in dash, causing some trouble. To solve this problem, Type sudo dpkg-reconfigure dash, reconfigure dash, and select "no", that is, no dash is used. Check whether dash or bash use the following command: ls-al/bin/sh #. whether bash or dash is displayed. if it is bash: lrwxrwxrex 1 root 4 xxxx-xx: xx/bin/sh-> bash # A soft link points to bash if it is dash: lrwxrwxrex 1 root 4 xxxx-xx: xx/bin/sh-> dash # A soft link points to dash
Related Article

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.