Answers:
用户主目录中的许多配置文件只是覆盖/添加到其中/etc
-例如,用户主目录中的GIMP设置位于~/.gimp-2.*
其中,这会添加到系统级配置中/etc/gimp/2.0
。
因此,对于~/.bashrc
,您可以编辑系统范围的配置文件/etc/bash.bashrc
(对于功能/别名)或/etc/profile
(对于环境材料) -您可以从man bash
以下位置获取完整列表:
FILES
/bin/bash
The bash executable
/etc/profile
The systemwide initialization file, executed for login shells
/etc/bash.bash_logout
The systemwide login shell cleanup file, executed when a login shell exits
~/.bash_profile
The personal initialization file, executed for login shells
~/.bashrc
The individual per-interactive-shell startup file
~/.bash_logout
The individual login shell cleanup file, executed when a login shell exits
~/.inputrc
Individual readline initialization file
文件中的一些Linux系统给出了此警告:
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
因此,您可以编辑这些文件,您可能想要先对其进行备份(cp /etc/bash.bashrc /etc/bash.bashrc-backup
例如),或者在其中创建外壳程序脚本/etc/profile.d
-例如,您可以使用以下命令(使用sudo /作为root)创建一个:
touch /etc/profile.d/custom.sh
chmod +x /etc/profile.d/custom.sh
然后用 nano /etc/profile.d/custom.sh
#!/bin/sh
alias ls='ls -lah'
并通过查看是否显示在-的输出中来检查它是否有效alias
-请注意,您可能需要注销/登录或重新引导才能看到任何更改(如果您不希望这样做,则source /etc/profile
在进行任何更改后运行即可)
[编辑:删除了该死链接] www.thelinuxdaily.com/2010/08/setup-a-universal-user-profile-with-etcprofile-dcustom-sh/]
~/.bash_logout
并/etc/bash.bash_logout
不能正常工作。:(
/etc/profile.d/
将不会被子进程权被拾起?因此,仅当Bash是登录外壳程序时,别名才可用吗?
我真的是Linux操作系统的新手,但是我做了一个bash脚本的草图,该脚本可以修改所有用户.bashrc文件,而不是系统文件/etc/.bashrc文件。
#!/bin/bash
X=$( cat etc/passwd | cut -f1 -d: ) #All-users
For X in /home/*/.bashrc ; do
echo "alias ls='ls -al'" >> $X
2>/dev/null
done
source $X
exit 0
好的,所以我知道该脚本可以工作,但是如果它没有错误,我就不行:)另外,您也可以对其进行修改,以使其不涉及所有用户,也许您为需要其.bashrc文件的所有用户创建了一个文件定制。
.bashrc
文件,并且无论行是否已经在他们的文件中,都始终追加。
/etc/skel/.bashrc
以更改~/.bashrc
新创建用户的内容。