定制 UNIX 环境:别名、选项与变量的使用指南
1. 启动文件与别名
在 UNIX 系统中, source 命令可执行指定文件中的命令,比如 .bash_profile 文件,其中包含你添加的所有命令。bash 为 .bash_profile 提供了两个同义词: .bash_login (源自 C shell 的 .login 文件)和 .profile (源自 Bourne shell 和 Korn shell 的 .profile 文件)。登录时,这三个文件中只有一个会被读取。若主目录中没有 .bash_profile ,bash 会查找 .bash_login ;若 .bash_login 也不存在,则查找 .profile 。
这种查找同义词的能力有个优点,比如你之前使用 Bourne shell,可保留 .profile 文件。若需添加 bash 特定命令,可将其放在 .bash_profile 中,并在后面添加 source .profile 命令。登录时,所有 bash 特定命令会先执行,然后 bash 会执行 .profile 中的剩余命令。若要切换回 Bourne shell,无需修改现有文件。不过,对于 .bash_log
超级会员免费看
订阅专栏 解锁全文
5

被折叠的 条评论
为什么被折叠?



