LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1098|回复: 9

請教一個shell環境設定問題. 先謝過.

[复制链接]
发表于 2005-4-27 14:18:07 | 显示全部楼层 |阅读模式
各位好. 我的slackware登入是 shell prompt 是
  1. user:~$
复制代码

但當我source /etc/profile 後就會變成
  1. user@localhost:~$
复制代码

但?K不是系統一啟動就會自動運行/etc/profile的嗎? 但為什麼要手動才可以設定shell prompt呢? 當source /etc/profile 後, console都會出現?色, 但未做 source /etc/profile 時, 就沒有?色的呢?
請問如何可使系統啟動後能自動運行/etc/profile內的環境設定呢?
謝指教.
发表于 2005-4-27 14:48:14 | 显示全部楼层
你的初始shell可能是/bin/sh,这虽然是到/bin/bash的符号链接,但没有列在/etc/shells中,所以不是有效的login shell,因此不会source /etc/profile,把初始shell改为/bin/bash一定可以解决问题。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-28 12:48:41 | 显示全部楼层
Thanks.
現在再請教一下.
在 /etc/shells 內是這樣的呢

  1. /bin/bash
  2. /bin/tcsh
  3. /bin/csh
  4. /bin/zsh
复制代码


請問如何更改root或其他user的login shell呢, 謝謝. :thank
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-30 10:42:08 | 显示全部楼层
再請指教...thanks.
回复 支持 反对

使用道具 举报

发表于 2005-4-30 10:45:00 | 显示全部楼层
chsh是suid程序,用户可以改自己的shell,还可以让root用usermod改,但改的时候该用户不能登录。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-30 12:59:53 | 显示全部楼层
Post by troll
chsh是suid程序,用户可以改自己的shell,还可以让root用usermod改,但改的时候该用户不能登录。


Thanks. 明白, 試一下先.  
回复 支持 反对

使用道具 举报

发表于 2005-4-30 15:31:48 | 显示全部楼层
看看你是/etc/passwd里,初始shell是不是/bin/bash?
login shell和interactive和shell在启动时读取的启动脚本是不样的。
我的感觉是login shell只读/etc/profile,

这是bash manpage的两段内容:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists.
When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists. When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.
回复 支持 反对

使用道具 举报

发表于 2005-4-30 15:35:28 | 显示全部楼层
chsh − change login shell

bash作为login shell读取初始化文件的顺序是/etc/profile;~/.profile;~./bash_profile
回复 支持 反对

使用道具 举报

发表于 2005-4-30 15:41:51 | 显示全部楼层
我也遇到过类似的问题。
会不会是term类型的原因?
我在用cygwin上MV3.1的机器,从来都是黑白的。呵呵
回复 支持 反对

使用道具 举报

发表于 2005-4-30 15:45:33 | 显示全部楼层
我自我更正,起始文件的先后顺序是/etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile
回复 支持 反对

使用道具 举报

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

本版积分规则

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