Linux下设置环境变量,我是在配置ant、android sdk 时 用到的,自己对linux的一些东西 还是不很了解,简单记录一下,配置环境 Mac。
1.使用env命令显示所有的环境变量
env
2.使用命令echo显示环境变量
echo $PATH
scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的。可能会稍微影响一下速度。
这个链接讲的很详细:http://www.vpser.net/manage/scp.html
1. vim ~/.bash_profile
2. export PATH=${PATH}:/Applications/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:/Applications/adt- bundle-mac-x86_64-20140321/sdk/tools:/Users/wuyunfeng/Downloads/apache-ant-1.9.4/bin
export ANDROID_HOME=${ANDROID_HOME}:/Applications/adt-bundle-mac-x86_64-20140321/sdk
3. source ~/.bash_profile
source命令:
source命令也称为“点命令”,也就是一个点符号(.)。source命令通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录。
用法:
source filename 或 . filename
就可以使用配置好的环境变量咯
Linux 下scp 命令 ,用于linux之间复制文件和目录
scp [可选参数] source_file target_file
从本地复制到远程
scp local-file remote_username@remote_ip:remote_folder
下面这个命令是我把2.2.2下所有的所有的文件上传至服务器中,注意此2.2.2下传不了 嵌套的文件夹
scp 2.2.2/* xxxx.wu@trac.xx.xx:/home/xxxx.wu/android/
/etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.
并从/etc/profile.d目录的配置文件中搜集shell的设置.
/etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
~/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该
文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该
该文件被读取.
~/.bash_logout:当每次退出系统(退出bash shell)时,执行该文件.
另外,/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量,他们是"父子"关系.
~/.bash_profile 是交互式、login 方式进入 bash 运行的
~/.bashrc 是交互式 non-login 方式进入 bash 运行的
摘抄:
在登录Linux时要执行文件的过程如下:
在刚登录Linux时,首先启动 /etc/profile 文件,然后再启动用户目录下的 ~/.bash_profile、 ~/.bash_login或 ~/.profile文件中的其中一个,
执行的顺序为:~/.bash_profile、 ~/.bash_login、 ~/.profile。
如果 ~/.bash_profile文件存在的话,一般还会执行 ~/.bashrc文件。
因为在 ~/.bash_profile文件中一般会有下面的代码:
if [ -f ~/.bashrc ] ; then
. ./bashrc
fi
~/.bashrc中,一般还会有以下代码:
if [ -f /etc/bashrc ] ; then
. /etc/bashrc
fi
所以,~/.bashrc会调用 /etc/bashrc文件。最后,在退出shell时,还会执行 ~/.bash_logout文件。
执行顺序为: /etc/profile -> (~/.bash_profile | ~/.bash_login | ~/.profile) -> ~/.bashrc -> /etc/bashrc -> ~/.bash_logout