o4-mini-2025-04-16· OpenAI
LMArena Human Preference 140K
source /etc/profile是在做什么?
- User
source /etc/profile是在做什么?
- Assistant
在 Linux/Unix 的 Bash(或类似 shell)环境下,执行下面命令:
source /etc/profile # 或者简写为 . /etc/profile大致是在做两件事:
- 读取并执行
/etc/profile中的所有 Shell 语句 - 在当前 shell 进程里生效(不会产生子 Shell)
/etc/profile 是什么
- 系统级的登录 shell初始化脚本
- 通常包含:
- 全局环境变量(PATH、LANG、umask……)
- 系统范围内的 alias、函数定义
- 如果存在
/etc/profile.d/目录,还会自动加载其中各个子脚本
Tip:登录 Shell(login shell)启动时会自动执行
/etc/profile,而普通的交互式非登录 Shell(interactive non-login shell)默认不会重新读取它。
为什么要手动
source /etc/profile - 读取并执行
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.