You are not logged in.
Hello there,
recently I changed to an auto login via agetty as described in the ArchWiki:getty. The first method described is using systemctl edit but this results in the following
$ sudo systemctl edit getty@tty1
Cannot edit unit(s), no editor available. Please set either $SYSTEMD_EDITOR, $EDITOR or $VISUAL.
(editor) failed with exit status 1.Issuing the env command I get
$ env
SHELL=/usr/bin/zsh
...
EDITOR=vi
...I see how that is a problem as I only have neovim installed. So I tried changing the variable by adding to my "~/.xinitrc" (I also tried to add it to "~/.zprofile" with the same result) [ArchWiki:Environment variables]
# Set neovim as default editor
EDITOR="/usr/bin/nvim"
export EDITORNow I have
$ env
SHELL=/usr/bin/zsh
...
EDITOR=/usr/bin/nvim
...But even after a reboot, I still get the same error message about setting my EDITOR variables.
Curiously enough though, when I issue
$ sudo EDITOR=/usr/bin/nvim systemctl edit getty@tty1 it does work.
So obviously I am missing something but I could not figure out what it is.
It is not something that breaks my system, but nonetheless it is something that I feel like I should configure the right way.
Last edited by lonlon (2020-04-17 13:27:11)
Offline
You're probably running "systemctl edit getty@tty1" a root with sudo, so altering the $EDITOR for your regular user will have what effect on that environment?
Offline
Sorry I had a mistake in my post. I am logged in as a regular user XYZ and run the command
sudo systemctl edit getty@tty1I thought it means that I run the command as this user with root privileges and thus it should use the editor that I specified via the "~/.xinitrc" of that user XYZ, right?
Offline
.xinitrc is in any case the wrong place to specify this, but no if you run the command with sudo, sudo will not carry over your own user's environment. Tell it to keep editor: https://wiki.archlinux.org/index.php/Su … _variables or rely on polkit and don't use sudo for the systemctl command
Last edited by V1del (2020-04-17 13:11:07)
Offline
I thought it means that I run the command as this user with root privileges
No. That's non-sensical and impossible. It runs with root privileges because it runs as root.
DESCRIPTION
sudo allows a permitted user to execute a command as the superuser or another user...
But also see
-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing environment variables...
Or just set those variables in the root shell rc or system-wide.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Oh, I did not know that, thank you for pointing that out.
Now that I have added to my /etc/sudoers
Defaults env_keep += "EDITOR=/usr/bin/nvimit does actually work.
I also removed the parts from the "~/.xinitrc" and moved them over to "./zprofile", I hope that is now the right way to do it.
Thank you!
Last edited by lonlon (2020-04-17 13:28:45)
Offline