`

bash profile

阅读更多

As we know, suse does not create .bash_profile when add a new user. But redhat does.

But if our program need some command from the profile, it is an issue.

 

So, we need to add this file when add the new user in script. And we need think about update the program.

 

if [ -f /etc/SuSE-release ] ; then #if the os is suse
      if [ ! -f %rvhome/.bash_profile ] ; then #if the file is not exist
        touch %rvhome/.bash_profile
        echo 'PATH=$PATH:$HOME/bin' >> %rvhome/.bash_profile
        echo 'export PATH' >> %rvhome/.bash_profile
        echo 'unset USERNAME' >> %rvhome/.bash_profile
    else #if the file is exist
      grep 'export PATH' %rvhome/.bash_profile > /dev/null #test the file has the key word 
      if [ $? -eq 0 ] ; then #$? means last output [0:exist 1:not exist]
            #echo 'export PATH is Exist.'
      else
            echo '' >> %rvhome/.bash_profile #if the file is empty, it needed add first line

            #search the key word line number
            LINE=`grep -n 'PATH=' %rvhome/.bash_profile | awk -F : '{print $1}'`

            ((LINE++)) #plus the line number
            sed -i "$LINE i export PATH" %rvhome/.bash_profile #insert string at the line into the file
            ((LINE++))
            sed -i "$LINE i unset USERNAME" %rvhome/.bash_profile
            sed -i "1 i PATH=\$PATH:$HOME/bin" %rvhome/.bash_profile
      fi
   fi

fi

 

result:

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

 

2011.6.1

ubuntu

~/.bashrc  /etc/bash.bashrc

alias py='python'
0
0
分享到:
评论

相关推荐

    bashprofile与bashrc.doc

    `bashprofile`和`bashrc`是两个主要的bash shell配置文件,它们定义了用户登录和使用bash shell时的环境。接下来,我们将深入探讨这两个文件的作用、区别以及它们如何协同工作。 1. `/etc/profile` `/etc/profile`...

    profile\bashrc\bash_profile之间的区别和联系

    在Linux系统中,环境变量和命令的设置是通过配置文件来完成的,这些配置文件包括`/etc/profile`, `/etc/bashrc`, `~/.bash_profile`以及`~/.bashrc`。理解它们的区别和联系对于优化用户环境和个性化设置非常重要。 ...

    linux-bashfullofcolors高级bashrc和bashprofile并拥有彩色输出

    `.bashrc`和`.bash_profile`是两个非常重要的配置文件,它们用于定制Bash shell的行为。本文将深入探讨这两个文件的功能,以及如何通过它们实现彩色输出,提升命令行的可读性和用户体验。 首先,`.bashrc`文件是每...

    oracle用户下.bash_profile文件修改

    安装Oracle之后,需要为oracle用户配置环境变量,这些环境变量存储在用户的.bash_profile文件中。.bash_profile文件位于用户的主目录下,用于设置环境变量和启动程序。本文档即为在安装Oracle时,对oracle用户下的....

    Linux中profile、bashrc、bash_profile之间的区别和联系

    其中.bash_profile是最重要的一个配置文件,它在用户每次登录系统时被读取,里面的所有命令都会被bash执行。.profile(由Bourne Shell和Korn Shell使用)和.login(由C Shell使用)两个文件是.bash_profile的同义词,...

    .bash_profile和.bashrc的什么区别

    ".bash_profile和.bashrc的区别" .bash_profile和.bashrc是两个非常重要的配置文件,在Linux系统中扮演着非常关键的角色。这两个文件都是 Bash shell 的配置文件,但是它们之间存在着很大的区别。 首先,让我们...

    bash_profile-master.zip

    macOS bash_profile 描述文件, 可下载解压后直接替换(including files:.bash_profile, .bash_profile_colors, .bash_profile_git, .bash_profile_svn, .bash_profile_utility, .gitgnore,若看不见以上文件,请按...

    linux .bash_profile和.bashrc的什么区别

    Linux 中的 .bash_profile 和 .bashrc 的区别 Linux 操作系统中,有两个重要的配置文件:`.bash_profile` 和 `.bashrc`。这两个文件都是 Bash shell 的配置文件,但它们的作用和应用场景却有所不同。本文将详细分析...

    bash_profile_tuxedo+oracle

    bash_profile_tuxedo+oracle bash_profile_tuxedo+oracle bash_profile_tuxedo+oracle bash_profile_tuxedo+oracle

    解决Mac 进程已停止

    MAC 进程已停止。 原因一般是:.bash_profile文件里面的配置出问题,可是.bash_profile是隐藏的,无法找到。安装这个软件后可以在用户的文件下出现.bash_profile,删掉或者重新编辑即可恢复。

    bash_profile:简单而有用的 bash_profile

    bash_profile 简单而有用的 bash_profile如何使用它? 复制bash_profile.txt的内容,并将其添加到主文件夹中的.bash_profile中(通常,您可以使用vim ~/.bash_profile打开)。 或者您应该将它添加到您的主文件夹下的...

    dotfiles:蒂姆的bash_profile

    点文件我的.bashprofile:基于要将其用作bashprofile并在github中进行维护时,请使用fork,然后将到fork ln -s ~ /bin/dotfiles/bash_profile.sh ~ /.bash_profilels -la ~ | more # just to check 现在......

    浅析linux 下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc

    ### 浅析Linux下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc 在Linux系统中,为了方便管理和配置用户的Shell环境,系统提供了多种不同的配置文件。这些配置文件按照一定的规则来确定何时加载及加载...

    bash_profile:Mac OS X 的 .bash_profile 中有用的东西

    在Mac OS X系统中,`.bash_profile`是一个非常重要的配置文件,它位于用户的Home目录下(通常是`~/.bash_profile`)。这个文件是Bash shell启动时读取的配置脚本,用于设置环境变量、别名、路径以及执行一些自定义的...

    bash-profile:我自己的自定义 .bash_profile 文件

    bash-profile 自定义 .bash_profile 自定义终端的外观。 在您的机器上导航时,它可以简单地读出您的身份和位置。 大多数着色是从其他地方获取的,但我真的不知道从哪里得到代码,因为我从朋友那里得到了代码。 ...

    mac 安装omyzsh后不执行~/.bash_profile、~/.bashrc的完美解决办法

    terminal init的时候并不会执行~/.bash_profile、~/.bashrc等脚本了, 这是因为其默认启动执行脚本变为了~/.zshrc。 解决办法就是修改~/.zshrc文件,在其中添加: source ~/.bash_profile、~/.bashrc等脚本文件...

    修复bash漏洞的bash-4.4.tar.gz源码包

    linux 服务器GNU Bash小于版本4.3有操作系统命令注入漏洞,需要对bash升级,下载解压 #tar zxvf bash-4.4.tar.gz #cd bash-4.4 #./configure (如果centos7编译失败,请先安装#yum install gcc) #make #make ...

    Linux CentOS下shell显示-bash-4.1$不显示用户名路径.docx

    .bash_profile 文件是 bash shell 的配置文件,它可以用来配置 shell 的行为。通过在这个文件中添加配置信息,可以让 shell 显示用户名路径。 PS1 变量 在上面的解决方案中,我们使用了 PS1 变量来配置 shell 显示...

    AIX 6.1 bash包及安装

    同时,根据需要更新.bashrc和.bash_profile文件以定制用户环境。 通过以上步骤,你可以在AIX 6.1系统上成功安装并使用bash 4.2版本。记住,更新shell后,系统管理员应确保所有脚本和程序都能与新版本兼容,因为不同...

    linux bash配置文件

    标题中的“linux bash配置文件”指的就是用户的Bash初始化脚本,通常位于`~/.bashrc`或`~/.bash_profile`路径下。这两个文件都是Bash启动时读取的,但它们各有侧重:`.bashrc`适用于交互式登录会话和非交互式终端,...

Global site tag (gtag.js) - Google Analytics