Though, the return to X might then also need attention; or does X start happily on tty7 while it's in use by a running getty?
I'd rather suggest that utilizing runlevels (and init) is the "simple" approach.
EDIT: or, it might be possible to shift to, say, tty1 instead, and then not start getty for tty7 at all. The "simpler" line would then be:
sudo chvt 1 ; sudo lightdm stop
I.e., first shift to tty1, then kill lightdm (and the C-A-Del handling). The return to X would be the command
$ sudo lightdm start
If that works, I would call it simpler
]]>Maybe we could simply write a one-liner that does everything we need? I was thinking something like this, but it doesn't work:
sudo service lightdm stop; sudo /sbin/getty 38400 tty7
No luck with this either:
sudo chvt 1; sudo service lightdm stop; sudo /sbin/getty 38400 tty7; sudo chvt 7
Any ideas how to tweak the above so that it works?
]]>So to summarize:
1. Do the steps in post #9
2. Add the line to /etc/inittab as shown in post #10
3. Bind Control+Alt+Backspace to run the command sudo init 3 (e.g., via xbindkeys)
4. Disable* the system's Control+Alt+Backspace keybinding to kill X server (if your system has that binding)
Now the behavior is exactly what one would expect: Logging out causes LightDM to show a graphical login screen, while Control+Alt+Backspace kills X and lightdm, and the user gets a CLI login prompt in tty7. To return to a graphical session in tty7, user types sudo init 2 (if xinit package is installed, startx also works).
* I don't know a CLI or DE-agnostic way to do this. In MATE: System > Preferences > Keyboard > Layouts > Options > Key sequence to kill the X server > uncheck the Control+Alt+Backspace box
]]>7:3:respawn:/sbin/getty 38400 tty7
In /etc/init.d/lightdm, change this
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
To this
# Default-Start: 2 4 5
# Default-Stop: 0 1 3 6
Then run these commands:
sudo update-rc.d lightdm remove
sudo update-rc.d lightdm defaults
Now switching from runlevel 2 to 3 with sudo init 3 does stop lightdm and X. The only problem with this is that, as in my approach in #7, lightdm quits to a black screen with blinking cursor and not to a prompt.
Isn't there any way for tty7 to be usable after lightdm stops?
]]>Normally when I want to remove a symlink for a runlevel, I just go with the absolute easiest way and prepend the link's name with an underscore.
Here's what I tried:
$ sudo mv /etc/rc3.d/{,_}S04lightdm
$ sudo init 3
But the above is not working: Switching runlevels has no discernible effect--I still find myself in my MATE session with both X and lightdm still running. I can confirm that the change in runlevel did occur:
bruno@thinkpad:~$ runlevel
2 3
Any ideas?
]]>The problem with this is that when lightdm stops, it leaves behind nothing but a black screen with a blinking cursor in tty7, thus rendering tty7 unusable. Doesn't lightdm know how to stop gracefully (e.g., to a command prompt or CLI login prompt)?
]]>/etc/init.d/lightdm start|stop|restart
or
service lightdm start|stop|restart
An alternate solution would be to remove the lightdm symlinks for one runlevel. Easy way: install sysv-rc-conf, run it and remove the check mark from lightdm for runlevel 3. (arrows, space bar and q to quit). Then in a root terminal, just run
init 3
to get to multi-user without graphical environment.
To restart lightdm:
init 2
[Service]
Restart=no
What would be the Devuan/SysVinit equivalent?
]]>I appreciate lightdm presenting a new graphical login screen when I log off. IMHO that is expected behavior.
When I kill X what I would like is, well, for X to be killed in tty7, stay dead (e.g., so that I can install/uninstall X-related packages), and for the system to present me with a non-GUI login or command prompt in tty7.
Lightdm's current (default) behavior "resurrects" X as soon as I kill it, which is annoying.
]]>If you want a console <CTRL><ALT><F1> will connect you through to tty1: and you can log in. If/when you want to get back to X you can type <CTRL><ALT><F7> as X runs on tty7:
Is that what you want?
Geoff
]]>If you have some way to figure out if a session started by startx was killed or if the user simply logged out i think you could hack something together with a script wrapping around /bin/login but i wouldn't know how to do that in a generic non DE dependant way.
]]>When I kill the X session, it is because I want to work in a virtual console without X running.
I perused /etc/lightdm/lightdm.conf and /etc/init.d/lightdm but didn't find anything promising.
]]>