NeD*_*ark 5 bash alias multiuser bashrc
我正在寻找一种为所有用户创建永久别名的简单方法。所以~/.bashrc或~/.bash_profile不是一个选项。
没有人为此创建了一个程序吗?我认为这应该是一个非常普遍的需求。如果没有,我总是可以创建自定义Bash脚本,但我需要知道是否有所有用户的 .bash_profile 等效文件。
就我而言,我使用的是 Mac OS X v10.9 (Mavericks) 和 Ubuntu 12.04 (Precise Pangolin),但我想要一种适用于主要 Unix 系统的方法。
更新:我想知道一个程序可以自动允许用户直接从命令行管理永久别名列表,而无需编辑文件。它将具有用于设置所有用户、目标用户、交互/登录 shell 等的选项。
更新 2:回复@jimmij 的回答
$ su -m
Password:
# cat /etc/profile
alias test343="echo working"
# cat /etc/bash.bashrc
alias test727="echo working"
# test727
bash: test727: command not found
# test343
bash: test343: command not found
Run Code Online (Sandbox Code Playgroud)
请看一下bash手册:
/etc/配置文件
系统范围的初始化文件,为交互式登录 shell 执行
/etc/bash.bashrc
系统范围的初始化文件,为交互式非登录 shell 执行。
~/.bash_profile
个人初始化文件,为交互式登录 shell 执行
~/.bashrc
单独的 per-interactive-shell 启动文件
~/.bash_logout
单个登录 shell 清理文件,在登录 shell 退出时执行
因此,您需要将别名放入/etc/profile或/etc/bash.bashrc以使它们可供所有用户使用。
| 归档时间: |
|
| 查看次数: |
20241 次 |
| 最近记录: |