GVKun编程网logo

bash – GNOME,Scientific Linux 6.1中的环境变量(bash设置环境变量)

19

在这里,我们将给大家分享关于bash–GNOME,ScientificLinux6.1中的环境变量的知识,让您更了解bash设置环境变量的本质,同时也会涉及到如何更有效地GNUScientificLi

在这里,我们将给大家分享关于bash – GNOME,Scientific Linux 6.1中的环境变量的知识,让您更了解bash设置环境变量的本质,同时也会涉及到如何更有效地GNU Scientific Library 2.0 发布、linux – 在bash中设置带有前导数字的环境变量、Linux的环境变量.bash_profile .bashrc profile文件、RHEL 5/Cent OS Linux 5/Scientific Linux 5 生命周期即将结束的内容。

本文目录一览:

bash – GNOME,Scientific Linux 6.1中的环境变量(bash设置环境变量)

bash – GNOME,Scientific Linux 6.1中的环境变量(bash设置环境变量)

我正在使用Scientific Linux 6.1.要运行程序(DS9),我需要设置此环境变量:

export XPA_METHOD=local

所以我把它保存在.bashrc中,当我从bash终端运行程序时没有问题.但是当我在GUI中运行它时(例如通过点击nautilus中的“使用ds9打开”),无法识别此变量.

如果有人能帮助我在GNOME中设置环境变量,我将非常感激.

解决方法

将其添加到〜/ .profile而不是.bashrc

编辑:注销然后再次打开以使更改生效.

GNU Scientific Library 2.0 发布

GNU Scientific Library 2.0 发布

GNU Scientific Library 2.0 发布,值得关注的改进:

* 稀疏矩阵
* 正则化最小二乘
* 2D 插值
* 新的非线性最小二乘解

下载:

ftp://ftp.gnu.org/gnu/gsl/gsl-2.0.tar.gz 
ftp://ftp.gnu.org/gnu/gsl/gsl-2.0.tar.gz.sig 
==================
gsl-2.0 改进列表

** fixed bug #43258 for hypergeometric functions (Raymond Rogers)

** added L-curve analysis routines for linear Tikhonov regression

** add running statistics module

** added bilinear and bicubic interpolation (David Zaslavsky)

** added function gsl_multifit_robust_residuals to compute robust
   fit residuals

** added Steffen monotonic interpolation method (Jean-François Caron)

** added new nonlinear least squares solver ''lmniel'' suitable for
   systems with large numbers of data

** nonlinear least squares solver now tracks the number of function
   and Jacobian evaluations, see example program for details

** the ''fdf'' field of gsl_multifit_function_fdf is now deprecated
   and does not need to be specified for nonlinear least squares
   problems

** added extensive test suite to nonlinear least squares module,
   resulting in a few minor bug fixes; the routine
   gsl_multifit_fdfsolver_driver has been rewritten (with API change)
   to handle the various error codes of the lmsder iterate
   routine, resulting in a high level caller which is highly robust
   for a wide class of problems

** added support for sparse matrices, including a GMRES
   iterative linear solver

** added routines gsl_linalg_givens and gsl_linalg_givens_gv
   for Givens rotations

** added Tikhonov (ridge) regularization to least squares module
   (linear and nonlinear)

** removed unused argument ''n'' from gsl_sf_ellint_D

** merged bspline_deriv_workspace into bspline_workspace to simplify
   bspline API; the functions
     gsl_bspline_deriv_alloc
     gsl_bspline_deriv_free
   are now deprecated and will be removed in a future release.

** merged ALF extension into GSL for associated Legendre functions;
   api has changed; consequently the functions:
     gsl_sf_legendre_Plm_array
     gsl_sf_legendre_Plm_deriv_array
     gsl_sf_legendre_sphPlm_array
     gsl_sf_legendre_sphPlm_deriv_array
     gsl_sf_legendre_array_size
   are now deprecated and will be removed in a future release.

** added function gsl_multifit_robust_weights to allow user to
   access the various weighting functions

GNU Scientific Library (GSL) 是一个用于科学计算的 C 语言类库。有超过1000个函数。

该类库提供了关于数学计算的很多方面,包括:

Complex Numbers Roots of Polynomials Special Functions Vectors and Matrices Permutations Sorting BLAS Support Linear Algebra Eigensystems Fast Fourier Transforms Quadrature Random Numbers Quasi-Random Sequences Random Distributions Statistics Histograms N-Tuples Monte Carlo Integration Simulated Annealing Differential Equations Interpolation Numerical Differentiation Chebyshev Approximation Series Acceleration Discrete Hankel Transforms Root-Finding Minimization Least-Squares Fitting Physical Constants IEEE Floating-Point Discrete Wavelet Transforms Basis splines


linux – 在bash中设置带有前导数字的环境变量

linux – 在bash中设置带有前导数字的环境变量

我需要在bash中设置一个名为“64bit”的环境变量(即带有前导数字).但是,bash变量名称不允许带有前导数字的变量.我知道在调用bash时设置它的方法:
env 64bit=1 /usr/bin/bash

但是,我正在寻找一种在当前运行的shell中更改它的方法,即不是通过启动新shell.我也知道csh允许变量以数字开头,但我需要使用bash.

有没有办法实现这个目标?

解决方法

您还可以绕过bash解释器并使用bash内部函数直接定义变量:
$gdb --batch-silent -ex "attach $$"                              \
    -ex 'set bind_variable("64bit","1",0)'                      \
    -ex 'set *(int*)(find_variable("64bit")+sizeof(char*)*5) = 1' \
    -ex 'set array_needs_making = 1'

$env | grep 64
64bit=1

Linux的环境变量.bash_profile .bashrc profile文件

Linux的环境变量.bash_profile .bashrc profile文件

Shell变量有局部变量、环境变量之分。局部变量就是指在某个Shell中生效的变量,只在此次登录中有效。环境变量通常又称“全局变量”,虽然在Shell中变量默认就是全局的,但是为了让子Shall继承当前Shell的变量,需要使用export内建命令将其导出为环境变量。

一、linux系统变量的类型

 

按变量的生存周期划分:

 

永久的:需要修改配置文件,变量永久生效。
临时的:使用export命令声明即可,变量在关闭shell时失效。

 

 

在配置永久的环境变量时,又可以按照作用范围分为:

用户环境变量
系统环境变量。
系统环境变量对所有系统用户都有效,用户环境变量仅仅对当前的用户有效。

 

二、设置环境变量

1. 直接运行export命令定义变量
       在shell的命令行下直接使用[export 变量名=变量值] 定义变量。该变量只在当前的shell(BASH)或其子shell(BASH)下是有效的,shell关闭了,变量也就失效了,再打开新shell时就没有这个变量,需要使用的话还需要重新定义。

 

2. 修改系统环境变量
系统环境变量一般保存在下面的文件中

/etc/profile

全局(公有)配置,不管是哪个用户,登录时都会读取该文件。

 

/etc/bash.bashrc

它也是全局(公有)的 bash执行时,不管是何种方式,都会读取此文件。

 

 

 

/etc/environment

 

不要轻易修改此文件

3. 修改用户环境变量

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

 

 

~/.profile

 

若bash是以login方式执行时,读取~/.bash_profile,若它不存在,则读取~/.bash_login,若前两者不存在,读取~/.profile。

 

~/.bash_profile 或者~./bash_login

若bash是以login方式执行时,读取~/.bash_profile,若它不存,则读取~/.bash_login,若前两者不存在,读取 ~/.profile。
只有bash是以login形式执行时,才会读取.bash_profile,Unbutu默认没有此文件,可新建。 通常该配置文件还会配置成去读取~/.bashrc。

 

~/.bashrc

当bash是以non-login形式执行时,读取此文件。若是以login形式执行,则不会读取此文件。

 

~/.bash_profile是交互式、login 方式进入 bash 运行的 
~/.bashrc 是交互式 non-login 方式进入 bash 运行的通常二者设置大致相同,所以通常前者会调用后者。

 

4. 修改环境变量配置文件

如想将一个路径加入到环境变量(例如$PATH)中,可以像下面这样做(修改/etc/profile): 
sudo vi /etc/profile 
以环境变量PATH为例子,环境变量的声明格式:

 

 

PATH=$PATH:PATH_1:PATH_2:PATH_3:------:PATH_N 
export PATH

 

你可以自己加上指定的路径,中间用冒号隔开。环境变量更改后,在用户下次登陆时生效,如果想立刻生效,则可执行下面的语句:

 

 

$source /etc/profile

 

 

三、环境配置文件的区别

1. profile、 bashrc、.bash_profile、 .bashrc介绍

bash会在用户登录时,读取下列四个环境配置文件:

全局环境变量设置文件:/etc/profile、/etc/bashrc。 
用户环境变量设置文件:~/.bash_profile、~/.bashrc。

读取顺序:① /etc/profile、② ~/.bash_profile、③ ~/.bashrc、④ /etc/bashrc。

① /etc/profile:此文件为系统的每个用户设置环境信息,系统中每个用户登录时都要执行这个脚本,如果系统管理员希望某个设置对所有用户都生效,可以写在这个脚本里,该文件也会从/etc/profile.d目录中的配置文件中搜集shell的设置。 
② ~/.bash_profile:每个用户都可使用该文件设置专用于自己的shell信息,当用户登录时,该文件仅执行一次。默认情况下,他设置一些环境变量,执行用户的.bashrc文件。 
③ ~/.bashrc:该文件包含专用于自己的shell信息,当登录时以及每次打开新shell时,该文件被读取。 
④ /etc/bashrc:为每一个运行bash shell的用户执行此文件,当bash shell被打开时,该文件被读取。

 


2 .bashrc和.bash_profile的区别

       .bash_profile会用在登陆shell, .bashrc 使用在交互式非登陆 shell 。简单说来,它们的区别主要是.bash_profile是在你每次登录的时候执行的;.bashrc是在你新开了一个命令行窗口时执行的。
       当通过控制台进行登录(输入用户名和密码):在初始化命令行提示符的时候会执行.bash_profile 来配置你的shell环境。但是如果已经登录到机器,在Gnome或者是KDE也开了一个新的终端窗口(xterm),这时,.bashrc会在窗口命令行提示符出现前被执行。当你在终端敲入/bin/bash时.bashrc也会在这个新的bash实例启动的时候执行。

3. 建议
       大多数的时候你不想维护两个独立的配置文件,一个登录的一个非登录的shell。当你设置PATH时,你想在两个文件都适用。可以在.bash_profile中调用.bashrc,然后将PATH和其他通用的设置放到.bashrc中。
       要做到这几点,添加以下几行到.bash_profile中:

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

 现在,当你从控制台登录机器的时候,.bashrc就会被执行。

四、常用的环境变量
BASH Bash Shell的全路径
CDPATH       用于快速进入某个目录。
PATH       决定了shell将到哪些目录中寻找命令或程序
HOME       当前用户主目录
HISTSIZE       历史记录数
LOGNAME       当前用户的登录名
HOSTNAME       指主机的名称
SHELL       当前用户Shell类型
LANGUGE       语言相关的环境变量,多语言可以修改此环境变量
MAIL       当前用户的邮件存放目录
PS1       基本提示符,对于root用户是#,对于普通用户是$

Reference
[1] /etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc
http://blog.chinaunix.net/uid-26435987-id-3400127.html
[2] Linux如何修改env看到的环境变量? .bashrc和.bash_profile区别
http://blog.csdn.net/xifeijian/article/details/13355031
[3] linux环境变量,bashrc与bashprofile
http://blog.sina.com.cn/s/blog_43e5ad4e0101ei43.html

 

RHEL 5/Cent OS Linux 5/Scientific Linux 5 生命周期即将结束

RHEL 5/Cent OS Linux 5/Scientific Linux 5 生命周期即将结束

三大旧版本的 Linux GNU 桌面环境在近期结束生命周期支持,包括 Red Hat Enterprise Linux (RHEL) 5/CentOS 5 和 Scientific Linux 5。


请用户尽快更新到最新的系统桌面环境版本,Red Hat 称 RHEL 5 版本系统将于 4 月 3 日向用户全面推送中止支持通知,3 月 31 日开始 Red Hat 已经向用户推送将中止对系统活跃支持的通知,不过 Red Hat 将会向不愿升级的用户提供特殊的延迟周期支持插件( Extended Life Cycle Support),能够获得额外 3.5 年的关键性安全修复和紧急优先级修复补丁。

CentOS Linux 5 也将在 4 月 3 日迎来生命周期中止,标志着 CentOS 5 时代的过去,而 Scientific Linux 5 已经在 3 月 31 日迎来生命周期中止。Fermilab 未提供如何延长性周期支持服务,希望用户尽快更新到最新版本的桌面环境。

来自:cnBeta.COM

关于bash – GNOME,Scientific Linux 6.1中的环境变量bash设置环境变量的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于GNU Scientific Library 2.0 发布、linux – 在bash中设置带有前导数字的环境变量、Linux的环境变量.bash_profile .bashrc profile文件、RHEL 5/Cent OS Linux 5/Scientific Linux 5 生命周期即将结束等相关知识的信息别忘了在本站进行查找喔。

本文标签: