You are not logged in.

#1 2018-09-26 19:15:36

DimitrisLol
Member
Registered: 2016-06-19
Posts: 20

systemd "Cannot edit units if not on a tty."

After a fresh installation i get this error when i try to edit any unit files.

Cannot edit units if not on a tty.

I startx and autologin exactly the way described in wiki and a who command confirms i am logged on tty1.How can i debug this?There seems to be no answers in google.Anyone has any idea?

Offline

#2 2018-09-26 21:30:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,498
Website

Re: systemd "Cannot edit units if not on a tty."

If you are under X, you are not on a tty, you are on a pty pseudo terminal.

But what command are you using to get that ouput?  You can just open a unit file in any text editor which will fork fine under any terminal.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2018-09-27 01:36:45

DimitrisLol
Member
Registered: 2016-06-19
Posts: 20

Re: systemd "Cannot edit units if not on a tty."

Thanks for your reply and sorry for the delayed response.
I just input commands like systemctl edit sshd.socket or systemctl edit fstrim.timer i tried switching to a tty but the response is the same..
I do manual overrides for now but i am worried i messed up something in my installation

Offline

#4 2018-09-27 02:35:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,498
Website

Re: systemd "Cannot edit units if not on a tty."

Those commands should work from within X.  Do you log in as root, or are you using sudo?

What is the output of `loginctl`?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2018-09-27 06:28:25

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,251

Re: systemd "Cannot edit units if not on a tty."

input commands like systemctl edit sshd.socket

What is the *exact* command?
on_tty() checks for isatty of stdin & stderr, so if you redirect/pipe the output of the command, you'll get this error (which, granted, is of lennart-grade uselessnes…)

Offline

#6 2018-09-27 10:30:19

DimitrisLol
Member
Registered: 2016-06-19
Posts: 20

Re: systemd "Cannot edit units if not on a tty."

Thanks for you time guys.I know i am not very helpful but i am kinda in the dark in how systemd works big_smile
loginctl output:

$ loginctl        
SESSION  UID USER     SEAT  TTY 
      1 1000 dimitris seat0 tty1

1 sessions listed.

service edit output:

$ systemctl edit sshd.socket        
Cannot edit units if not on a tty.

$ systemctl status sshd.socket              
● sshd.socket
   Loaded: loaded (/usr/lib/systemd/system/sshd.socket; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/sshd.socket.d
           └─override.conf
   Active: active (listening) since Thu 2018-09-27 13:20:50 EEST; 3min 1s ago
   Listen: [::]:xxxx (Stream)
 Accepted: 0; Connected: 0;
    Tasks: 0 (limit: 4915)
   Memory: 0B
   CGroup: /system.slice/sshd.socket

Sep 27 13:20:50 archos systemd[1]: Listening on sshd.socket.

start X which seems to be irrelevant since i cant edit even on tty2+

% cat xserverrc 
#!/bin/sh
exec /usr/bin/Xorg -keeptty -nolisten tcp "$@" vt$XDG_VTNR > /dev/null

$ cat ~/.config/zsh/.zlogin
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
  exec startx &> /dev/null
fi

getty tty1 override

[Service]
Type=simple
ExecStart=
ExecStart=-/usr/bin/agetty --autologin dimitris --nohints --nohostname --noissue %I $TERM

Last edited by DimitrisLol (2018-09-27 10:30:50)

Offline

#7 2018-09-27 12:35:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,251

Re: systemd "Cannot edit units if not on a tty."

Wild guess: output of "echo $EDITOR"?
Also this looks like you're attempting to edit the service as regular user?

Offline

#8 2018-09-30 12:26:51

DimitrisLol
Member
Registered: 2016-06-19
Posts: 20

Re: systemd "Cannot edit units if not on a tty."

Sorry for the delay.Nope its not that

$echo $EDITOR
vim

editor is set and the error message appears even when trying to edit as root.Guess i should take this upstream?

Offline

#9 2018-09-30 12:50:33

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,251

Re: systemd "Cannot edit units if not on a tty."

Maybe - what kind of shell and VTE is that?
(Though I understand it even happens on the linux console?)

Offline

#10 2021-11-14 19:53:59

nopro404
Member
Registered: 2021-11-14
Posts: 1

Re: systemd "Cannot edit units if not on a tty."

I had the "Cannot edit units if not on a tty." which led me here.  Problem was I have a function that wraps systemctl with generic colouriser grc package. 

which systemctl
systemctl () {
        grc --colour=auto ${commands[$0]} "$@"
}

using the full path

/usr/bin/systemctl edit unitfile

works fine.

Offline

Board footer

Powered by FluxBB