When your distribution has /etc/profile.d
, it usually means that the /etc/profile
or equivalent of any Bourne/POSIX-compatible shell will source all files matching /etc/profile.d/*.sh
. So if you want to add your own customization for all users, you should create your own file, e.g. /etc/profile.d/set-vimode.sh
.
However, set -o vi
is a shell setting, and as such won't be inheritable from one process to another. So you must set it at the start-up of every shell, not just for the login shell. The right place for global settings of such nature would be /etc/bash.bashrc
for Bash. Other shells will have other conventions.
Like Kusalananda in the comments, I would also urge you to not change the global defaults, although - as you said - you're the only user of this system. If you ever work as part of a system administrator team, and that team has at least one member with strong preferences that conflict with yours (in the shell vi/emacs mode choice), changing the global default can create a surprising amount of hostility. (Been there, seen that.)
The only solution that will be happy for everyone will be using sudo -s
to become root with the sudoers
option always_set_home
unset, so that the root shell will use your home directory (and so your preferred settings) while having the identity of root
. This allows each administrator in the team to have their own preferences satisfied without stepping on others.
Note that in some systems with stronger auditability requirements, you may be required to only run each individual privileged command through sudo
and not use a shell running as root, to provide a clear log of exactly what privileged commands were used, when, and by who. Of course you can do whatever you want on your home system, but if you think you might some day be employed as a system administrator in a financial, healthcare or national-security-sensitive environment, a habit of avoiding working in an interactive root shell would serve you well.
sudo
instead. – Kusalananda Jun 09 '18 at 18:56