Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

(Solved) Auto startx as User Not working, has to be manually run in TTY

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
miltonx
Posts: 4
Joined: 2020-11-05 01:30

(Solved) Auto startx as User Not working, has to be manually run in TTY

#1 Post by miltonx »

Auto logging in and auto startx works fine as root, using the following approach:
Edit /etc/systemd/system/getty@tty1.service.d/override.conf:

Code: Select all

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM
Run:

Code: Select all

systemctl set-default multi-user.target
Edit /root/.profile to include at end:

Code: Select all

if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
  startx
fi
X is auto started on tty1 (See following user m's case in contrast).
---------------------
As this works for root, I appllied the same approach to user m:
/etc/systemd/system/getty@tty1.service.d/override.conf:

Code: Select all

[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin m --noclear %I $TERM
Edit /home/m/.profile to include at end:

Code: Select all

if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
  startx
fi
Reboot machine, user m successfully auto logged in on tty1, but failed to startx, with following error:
error: ...cannot open /dev/tty0, permission denied.
Then I removed the startx part from /home/m/.profile. Rebooted, user m auto logged in. I manually ran "startx", and X started! (The "startx" command was input in tty1, but somehow X started on tty2.)

I googled the "cannot open /dev/tty0..." error and found a lot related topics but none of them was identical to my scenario. It really confuses me why it is fine to manually startx but the .profile script does not work.


Background Info:
version: Debian GNU/Linux 10 (buster) -- minimally installed
Then installed xorg related packages and various video firmware and modules, and awesome wm
No display manager.
Last edited by miltonx on 2021-09-18 14:16, edited 4 times in total.

CwF
Global Moderator
Global Moderator
Posts: 2636
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: Auto startx as User Not working, has to be manually run in TTY

#2 Post by CwF »

miltonx wrote: 2021-09-18 03:05 Edit /home/m/.profile to include at end:
try;

Code: Select all

[ "$(tty)" = "/dev/tty1" ] && exec startx

miltonx
Posts: 4
Joined: 2020-11-05 01:30

Re: Auto startx as User Not working, has to be manually run in TTY

#3 Post by miltonx »

After reading other posts about the "cannot open dev/tty0" error, I fixed it. The non-root user has to be added to the tty group. (It is said that it is also necessary to add to the video group, but since my m user was already in that group, I just ran "usermod -aG tty m", rebooted and X auto started.)

CwF
Global Moderator
Global Moderator
Posts: 2636
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: (Solved) Auto startx as User Not working, has to be manually run in TTY

#4 Post by CwF »

miltonx wrote: 2021-09-18 14:15 The non-root user has to be added to the tty group. (It is said that it is also necessary to add to the video group,
Interesting...
many paths, too many.
I leave tty1 empty and use the others for users. tty2 is a single group user, not even sudo. Some tty's need a password, some don't. Group alignment is one way, but not required. If you dropped the $DISPLAY part then group doesn't matter.

Post Reply