Ubuntu12.04 LTS下环境变量设置

原文网址:http://blog.chinaunix.net/uid-26963688-id-3221439.html

1.设置当前用户环境变量(对root用户无效)

打开终端输入:
light@chaozang:~$ sudo gedit ~/.bashrc
[sudo] password for light:

末尾添加:
export PATH=/opt/EmbedSky/4.3.3/bin:$PATH
,其中/opt/EmbedSky/4.3.3/bin为你自己需要设置的环境变量路径。

使其立即生效,在终端执行:
light@chaozang:~$ source ~/.bashrc
或重启电脑。
技术分享

2.设置系统环境变量(对root用户生效)

打开终端输入:
light@chaozang:~$ sudo gedit /etc/environment
[sudo] password for light:

在PATH="....“中末尾处添加    ”冒号:“加上 ”你的环境变量路径“。

使其立即生效,在终端执行:
light@chaozang:~$ source /etc/environment
或重启电脑。
技术分享

--------------------------------------------------------------------------------------------

例如:

root@chaozang:~# arm-linux-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/julian/lite-respin/linux/src/gcc-4.3/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion=‘Sourcery G++ Lite 2008q3-72‘ --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/julian/lite-respin/linux/obj/host-libs-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/julian/lite-respin/linux/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) 
root@chaozang:~#
-------------------------------------------------------------------------------------------
root@chaozang:~# vim /etc/environment
显示如下:
#PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.3.2/bin"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/work/tools/gcc-3.4.5-glibc-2.3.6/bin"
~                                                                               
~                                                                                  
~                                                                               
"/etc/environment" 2L, 222C                                   1,1           All
-------------------------------------------------------------------------------------------

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。