zoukankan      html  css  js  c++  java
  • Ubuntu 环境变量及 ADB 配置 (转载)

        转自:http://blog.csdn.net/ithomer/article/details/7307449

     

    同Windows一样,Ubuntu Linux系统包含两类环境变量:系统环境变量和用户环境变量。系统环境变量对所有系统用户都有效,用户环境变量仅仅对当前的用户有效。

    用户环境变量通常被存储在下面的文件中:

    • ~/.profile
    • ~/.bash_profile 或者 ~./bash_login
    • ~/.bashrc

    上述文件在Ubuntu 10.0以前版本不推荐使用。

    系统环境变量一般保存在下面的文件中:

    • /etc/environment
    • /etc/profile
    • /etc/bash.bashrc

    /etc/profile和 /etc/bash.bashrc在Ubuntu 10.0版本中不推荐使用。

    Ubuntu Linux 环境变量的优先级

    1. /etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件自动被执行。
    2. /etc/environment:在登录时操作系统使用的第二个文件,系统在读取你自己的profile前,设置环境文件的环境变量。
    3. ~/.bash_profile: 在登录时用到的第三个文件是.profile文件,每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认 情况下,他设置一些环境变量,执行用户的.bashrc文件。/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
    4. ~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取。
    5. /etc/bash.bashrc:当用户进入shell或桌面系统自动执行的脚本

    几个环境变量的优先级:1>2>3

     

    Ubuntu Linux中设置adb环境变量

    • 当前用户(homer)

    vi ~/.bashrc (root默认目录下的bashrc文件)

    在这个文件中加入:export PATH=/home/homer/android-sdk-linux/platform-tools/:$PATH
    重启或再次登陆后生效,如果想立即生效,则执行:source ~/.bashrc

    • 超级用户(root)
    su root
    vi ~/.bashrc (root默认目录下的bashrc文件)
    在这个文件中加入:export PATH=/home/homer/android-sdk-linux/platform-tools/:$PATH
    重启或再次登陆后生效,如果想立即生效,则执行:source ~/.bashrc

     

    • 全局设置(homer、root、sudo)
    1. 实现思路:
    在PATH默认的bin目录下,新建adb的软链接
     
    2. 查看sudo $PATH: echo 'echo $PATH' | sudo sh
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
     
    3. 进入sudo默认PATH:
    cd /usr/local/bin/
     
    4. 建立软链接:
    sudo ln -s /home/homer/android-sdk-linux/platform-tools/adb 
     
    5. 这样,在普通用户(homer)、超级用户(root)、sudo用户,都可以直接使用adb命令,因为这些用户的PATH环境变量都包含了目录/usr/local/bin

     

    Ubuntu Linux 无法识别手机

    homer@ubuntu:~$ adb devices
    List of devices attached 
    ???????????? no permissions

    Ubuntu Linux 启动手机识别

    homer@ubuntu:~$ sudo adb kill-server
    homer@ubuntu:~$ sudo adb start-server
    * daemon not running. starting it now on port 5037 *
    * daemon started successfully *
    homer@ubuntu:~$ adb devices
    List of devices attached 
    FM6111131707 device

    参考推荐:

    Linux 之 /etc/profile、~/.bash_profile 等几个文件的执行过程

    Ubuntu中设置环境变量的几种方式及区别

    android 真机调试 乱码(不识别手机)

  • 相关阅读:
    GO语言的进阶之路-Golang字符串处理以及文件操作
    将本地的代码推送到公网的github账号去
    GO语言的进阶之路-go的程序结构以及包简介
    Linux操作系统原理
    Linux安装-kickstart无人值守安装
    LVM逻辑卷管理
    Liunx软Raid实现
    parted分区工具用法
    高级Linux运维工程师必备技能(扫盲篇)
    H3C配置FTP服务器
  • 原文地址:https://www.cnblogs.com/lance-ehf/p/4267317.html
Copyright © 2011-2022 走看看