Transferred from: http://blog.csdn.net/ithomer/article/details/7307449
Like Windows, Ubuntu Linux systems contain two types of environment variables: system environment variables and user environment variables. The system environment variable is valid for all system users, and the user environment variable is only valid for the current user.
User environment variables are typically stored in the following file:
- ~/.profile
- ~/.bash_profile or ~./bash_login
- ~/.bashrc
The above files are not recommended for use in previous versions of Ubuntu 10.0.
The system environment variables are generally stored in the following file:
- /etc/environment
- /etc/profile
- /etc/bash.bashrc
/etc/profile and/ETC/BASH.BASHRC are not recommended for use in Ubuntu version 10.0.
Priority for Ubuntu Linux environment variables
- /etc/profile: The first file that is used when the operating system customizes the user environment at logon, which sets the environment information for each user of the system, which is automatically executed when the user logs on for the first time.
- /etc/environment: The second file used by the operating system at logon, the system sets environment variables for environment files before reading your own profile.
- ~/.bash_profile: The third file that is used to log on is the. profile file, which each user can use to enter shell information that is specific to their own use, which is executed only once when the user logs on. By default, he sets some environment variables, Executes the user's. bashrc file. /ETC/BASHRC: Executes this file for each user running the bash shell. When the bash shell is opened, the file is read.
- ~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell.
- /ETC/BASH.BASHRC: Scripts that are automatically executed when a user enters a shell or desktop system
Priority of several environment variables: 1>2>3
setting ADB environment variables in Ubuntu Linux
VI ~/.BASHRC (BASHRC file in root default directory)
In this file, add: Export path=/home/homer/android-sdk-linux/platform-tools/: $PATH restart or re-login to take effect, if you want to take effect immediately, then execute: source ~/.BASHRC
Su rootvi ~/.BASHRC (bashrc file in the root default directory) is included in this file: Export path=/home/homer/android-sdk-linux/platform-tools/:$ Path restarts or re-login to take effect, if you want to take effect immediately, then execute: source ~/.BASHRC
- Global Settings (Homer, Root, sudo)
1.Implementation of the idea: in the path default bin directory, the new ADB soft link
2.View sudo $PATH: Echo ' echo $PATH ' | sudo sh/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/x11r6/bin
3.Go to sudo default path:cd/usr/local/bin/
4.Create a soft link: sudo
ln-s/home/homer/android-sdk-linux/platform-tools/adb
5.In this way, the ADB command can be used directly in the normal user (Homer), Superuser (root), sudo user, as these users ' path environment variables contain directories
/usr/local/bin
Ubuntu Linux does not recognize the phone
[Email protected]:~$ ADB devices
List of devices attached
???????????? No permissions
Ubuntu Linux Startup phone recognition
[Email protected]:~$ sudo adb kill-server
[Email protected]:~$ sudo adb start-server
* Daemon not running. Starting it now on Port 5037 *
* Daemon started successfully *
[Email protected]:~$ ADB devices
List of devices attached
FM6111131707Device
Reference recommendation:
Linux/etc/profile, ~/.bash_profile, and several other files of the implementation process
Several ways and differences of setting environment variables in Ubuntu
Android Real Computer debugging garbled (not recognized phone)
Ubuntu environment variables and ADB configuration (reprint)