Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux environment variable settings methods and differences     - Linux automatic installation and implementation (Linux)

- GNU / Linux system, how to clean up memory space (Linux)

- Linux Shell Understanding and Learning (Linux)

- Use Linux built-in firewall to improve network access control (Linux)

- Linux command line to put on your coat GUI (Linux)

- GitLab Guide installation under Ubuntu 14.04 (Server)

- TOAST function in PostgreSQL (Database)

- Smack 4.1.x Upgrade Guide (Linux)

- Linux ln command - create a file / directory link (Linux)

- How to manage the time and date at systemd Linux systems (Linux)

- The AWK use Cygwin tools mysql binlog log viewer (Database)

- Oracle to read and modify the data block process (Database)

- 8 Docker knowledge you may not know (Server)

- Java foundation comb: Array (Programming)

- 11G ASM disk group does not automatically handle MOUNT (Database)

- Ubuntu arm-none-eabi-gcc compiler treated with STM32F10x (Linux)

- Linux 6 install Oracle 11g (64bit) (Database)

- Add local search to your Android app (Programming)

- RHEL7 Apache MPM configuration (Server)

- Windows Remote Desktop Management CentOS 6.4 (Linux)

 
         
  Linux environment variable settings methods and differences
     
  Add Date : 2017-08-31      
         
         
         
  Linux environment variable settings can export realization to be achieved by modifying a few files, it is necessary to clarify the difference between these two methods as well as several documents.

Linux environment variable settings through the file

The first is to set global environment variables, enter into force for all users:

etc / profile: This document set the environment information for each user's system. When a user logs in, the file is executed once, and collect shell settings from the configuration file /etc/profile.d directory. Usually used to set global variables for all users.
/ Etc / bashrc: When bash shell is opened, the file is read. That is, every time you open a new terminal shell, the file will be read.
Followed by the above-mentioned two documents and correspondence, but only takes effect on the individual user:

~ / .bash_profile Or ~ / .profile: take effect only for a single user, when the user logs in the file only once. Users can use this file to add shell variable information for their own use. Also in different LINUX operating system, this file may be different, it may be ~ / .bash_profile, ~ / .bash_login or ~ / .profile wherein one or more of the order if there are several, then executed It is: ~ / .bash_profile, ~ / .bash_login, ~ / .profile. For example, Ubuntu system is generally ~ / .profile file.
~ / .bashrc: Take effect only for a single user, login, and when every time you open a new shell, the file is read.
 

In addition, modify / etc / environment This file can also be achieved for setting environment variables. / Etc / environment is set up global variables from the file itself for action, / etc / environment is set up the entire system environment, and / etc / profile is set all the user's environment. There are several points to note:

The system first reads etc / profile and then read the / etc / environment (or vice versa?)
Information / etc / environment can not contain commands that directly VAR = "..." set, do not use export.
Use source / etc / environment variable settings can take effect immediately in the current window, the need to logout / restart after the order takes effect for each new terminal window.
Modify the Linux environment variable instances

In Ubuntu, for example, to modify the ~ / .profile file:

vim ~ / .profile
If the file exists, then the file was last seen the following code, the value of the PATH variable with a colon (:) separated:

# Set PATH so it includes user's private bin if it exists
if [-d "$ HOME / bin"]; then
PATH = "$ HOME / bin: $ PATH"
fi
Add the final Code PATH = "$ PATH: / usr / local / Hadoop / bin", pay attention to the equal sign (=) with no spaces on either side, namely:

# Set PATH so it includes user's private bin if it exists
if [-d "$ HOME / bin"]; then
PATH = "$ HOME / bin: $ PATH"
fi
PATH = "$ PATH: / usr / local / hadoop / bin"
Because the file is in the user login is only read once, so you need to restart to take effect (modify / etc / profile, / etc / environment is also true). But you can use the command source ./.profile to take effect immediately. You can see the value of the variable modified by the echo $ PATH:

source ./.profile
echo $ PATH
Modify the Linux environment variables Shell commands export

Another way to modify the Linux environment variable is through the Shell command export, do not pay attention to the variable name has a dollar sign $ assignment statement only needs to have:

export PATH = $ PATH: / usr / local / hadoop / bin
export mode only for the current terminal Shell effective: using variable export settings, valid only for the current terminal Shell, which means that if you open a new terminal, then this variable is set in the new export terminal manipulation can not be read to. Suitable set up some temporary variables.

According to the desired variable, select Settings mode, for example JAVA_HOME variable such, it is suitable to set a global variable can be set in / etc / environment in.
     
         
         
         
  More:      
 
- Docker ecosystem security is gradually maturing (Server)
- Redis logging system (Database)
- Linux system Perl Lite netstat (Linux)
- Linux System Getting Started Learning: The Linux log (Linux)
- Linux directory permissions to read and execute permissions difference (Linux)
- Linux kernel TCP / IP parameters analysis and tuning (Linux)
- Ubuntu 14.04.1 LTS compile and install the new kernel (Linux)
- Arronax allows you to easily create desktop startup file (Linux)
- Java string equal size comparison (Programming)
- sqlplus connect to Oracle (Database)
- Java implementation of stacks and queues (Programming)
- Java interface and inheritance (Programming)
- Java heap (Heap) and stack difference (Programming)
- Ubuntu modify locale problem solving (Linux)
- You need to know 12 Git High Command (Linux)
- Bug tracking library after FastJson omitted the decimal point 0 (Programming)
- Dalvik heap memory management and recycling (Linux)
- Replace element and non-replaced elements of learning (Programming)
- Linux print file and send mail (Linux)
- Linux security concerns again (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.