Changing the default systemd editor
So far, I've been showing you how to do all of this in the nano text editor, which is the default systemd
editor for most modern Linux distros. But, what if you don't like nano, and would prefer to use something else? Let's say that Vim is your favorite text editor, and you want to use it instead of nano.
One way to use an alternate text editor is to specify the alternate editor each time you run a systemctl edit
command, like this:
[donnie@localhost ~]$ sudo EDITOR=vim systemctl edit --full sshd [donnie@localhost ~]$
That works, but doing it every time you want to run a systemctl edit
command could get a bit tiresome. Fortunately, changing the default editor is easy, once you know how to do it.
First, edit the .bashrc
file that's in your own home directory. At the very bottom of the file, add this line:
export SYSTEMD_EDITOR=vim
After saving the file, reload the new configuration:
[donnie@localhost ~]$ source...