Chinaunix首页 | 论坛 | 博客
  • 博客访问: 23634
  • 博文数量: 20
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 207
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-26 09:51
文章分类

全部博文(20)

分类: LINUX

2013-08-27 19:32:32

With the purpose of adding '/usr/sbin' to $PATH.
1.Modify the value of $PATH for user account.

Firstly, check the value of $PATH as below, '/usr/sbin' is excluded.
  1. [sandy@localhost ~]$ echo $PATH
  2. /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/sandy/bin
Secondly, add the needed path in .bash_profile, the blue line is addition.
Before:
  1. [sandy@localhost ~]$ cat .bash_profile
  2. # .bash_profile
  3. # Get the aliases and functions
  4. if [ -f ~/.bashrc ]; then
  5. . ~/.bashrc
  6. fi
  7. # User specific environment and startup programs
  8. PATH=$PATH:$HOME/bin
  9. export PATH
  10. [sandy@localhost ~]$
After:

  1. [sandy@localhost ~]$ cat .bash_profile
  2. # .bash_profile
  3. # Get the aliases and functions
  4. if [ -f ~/.bashrc ]; then
  5. . ~/.bashrc
  6. fi
  7. # User specific environment and startup programs
  8. PATH=$PATH:$HOME/bin:/usr/sbin
  9. export PATH
  10. [sandy@localhost ~]$
And thirdly, re-import the file .bash_profile or relogin the session, the last step is confirming the value of $PATH.

  1. [sandy@localhost ~]$ source .bash_profile
  2. [sandy@localhost ~]$ echo $PATH
  3. /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/sandy/bin:/home/sandy/bin:/usr/sbin
  4. [sandy@localhost ~]$
As above, $PATH is reset only for account 'sandy', let's take a look at the value of $PATH for account 'rock' as follow '/usr/sbin' is excluded.
 ex
  1. [rock@localhost ~]$ echo $PATH
  2. /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/rock/bin
  3. [rock@localhost ~]$
2.Modify the value of $PATH for all accounts.

Login your session as root, then modify /etc/profile as we just have been done for .bash_profile.
Then you can find the '/usr/sbin' is added into $PATH for all accounts on this server. Also take 'rock' as an example to confirm.

  1. [rock@localhost ~]$ echo $PATH
  2. /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/sbin:/home/rock/bin
  3. [rock@localhost ~]$
阅读(284) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~