LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: windrose

bash配置文件实验报告

[复制链接]
发表于 2007-1-19 12:41:00 | 显示全部楼层
希望windrose兄不要误会,我按你方法做的而且是肯定做了备份的。
就算没做,我用的也是个测试用的帐号,删掉再重建都可以。

不过,我想你那样做的时候发现这个变化:

[test@localhost ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATHHOME/binHOME/123:

export PATH
unset USERNAME
export LANG=en_US
echo "Hello from .bash_profile"
[test@localhost ~]$ echo 'hello from profile' > .bash_profile
[test@localhost ~]$ source .bash_profile
-bash: hello: command not found
[test@localhost ~]$exit

Last login: Fri Jan 19 13:46:02 2007
-bash: hello: command not found
-bash-3.00$ cat .bash_profile

“-bash: hello: command not found”所以,我才怀疑。。。
不过现在知道了是仍然可用的。
但是,为什么会出现这个呢?我实在搞不懂。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-1-19 14:32:49 | 显示全部楼层
Post by lxy_bhbh

[test@localhost ~]$ echo 'hello from profile' > .bash_profile


因为你少了一个 echo
回复 支持 反对

使用道具 举报

发表于 2007-1-19 18:07:26 | 显示全部楼层
。。。。
不好意思,太大意了。。。
回复 支持 反对

使用道具 举报

发表于 2009-5-16 15:07:35 | 显示全部楼层
Post by windrose;483987
举一个应用的例子。我一直是用init 3(文本模式)启动和登录系统的,但往往登录之后就启动X window,只是偶尔再回到文本界面。可能有兄弟会说,为什么不用init 4(图形登录)?我觉得如果用了init 4,假如想返回纯文本界面,还要再修改inittab,到底不是很方便。于是创建了 ~/.bash_profile,添加如下内容:

  1. if test x"$DISPLAY" = x""
  2. then
  3. startx
  4. fi
复制代码

这样,我从shell登录之后,直接就启动X window。假如想回到文本界面,只要退出X就可以了。


向你學了一招,很實用我也是int3預設起動.
我自己實際是寫如下,不然每次ctrl + alt + F2 - F6又啟動一次startx.


  1. test "$(tty)" = "/dev/vc/1" -a x"$DISPLAY" = x"" -a "$(pgrep startx)" = ""
  2. #X11不在且在vc1就跑
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表