Linux environment variables

Source: Internet
Author: User

Ubuntu Linux contains two types of environment variables: system environment variables and user environment variables. System environment variables are valid for all system users. USER environment variables are only valid for current users.
USER environment variables are usually stored in the following files:
~ /. Profile
~ /. Bash_profile or ~. /Bash_login
~ /. Bashrc
The above files are not recommended in versions earlier than Ubuntu 10.0.

System environment variables are generally stored in the following files:
/Etc/environment)
/Etc/profile
/Etc/bash. bashrc
Later versions are not recommended in Ubuntu 10.0.

Priorities of environment variables in Ubuntu Linux
/Etc/profile: The first file used by the operating system to customize the user environment during login. This file sets environment information for each user in the system. When the user logs on for the first time, the file is automatically executed.
/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.
~ /. Bash_profile: The third file used for logon is. 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/bashrc: execute this file for every user running bash shell. When bash shell is opened, this file is read ~ /. 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.
/Etc/bash. bashrc: script automatically executed when a user enters the shell or desktop system
Priorities of Several environment variables: 1> 2> 3

In ubuntu, ADB is not an internal command, so if it is not in its directory, if you want to use ADB, it will report an error, command not found; at this time, you need to modify the environment variable, add the directory where ADB is located to the environment variable.

Suppose ADB is in the/home/MLB/Android/ICs/out/host/linux-x86/bin/directory (ask the reader to find the correct directory of the ADB tool in his environment)
Set a variable jdk_home =/home/MLB/Android/ICs/out/host/linux-x86/bin/

1. Current User
Sudo gedit. bashrc
Add:
Jdk_home =/home/MLB/Android/ICs/out/host/linux-x86/bin/

Export Path = $ path: jdk_home
It takes effect after restarting or logging on again. If you want to take effect immediately, run the following command:
Sudo source. bashrc
2. Global settings
Sudo gedit/etc/profile
Add:
Jdk_home =/home/MLB/Android/ICs/out/host/linux-x86/bin/

Export Path = $ path: jdk_home
It takes effect after restarting or logging on again. If you want to take effect immediately, run the following command:
Sudo source/etc/profile
3. system settings
Sudo gedit/etc/Enviroment
Add:
Jdk_home =/home/MLB/Android/ICs/out/host/linux-x86/bin/

Export Path = $ path: jdk_home
It takes effect after restarting or logging on again. If you want to take effect immediately, run the following command:
Sudo source/etc/Enviroment


If you want other users in the system to use ADB, you can create a soft link:
Sudo ln-S/home/[username]/Android-sdks/platform-tools/ADB/usr/bin/ADB

 

4. Check whether the path is added to the path:
# Echo $ path

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.