The officially official Devuan Forum!

You are not logged in.

#1 2026-07-11 20:36:55

tux_99
Member
Registered: 2025-06-17
Posts: 128  

[SOLVED] How can I make "xhost +" the default at every boot?

I run some X11-apps as a different user than the user with which i log on to the desktop (XFCE) so after a reboot I always have to type "xhost +" in a terminal before being able to launch these X11-apps as a different user.

So how can I make "xhost +" the default at every boot?

In which config file do I have to set this to avoid having to type it manually each time?

Last edited by tux_99 (2026-07-11 20:39:50)


Either the users control the program – or the program controls the users” Richard Stallman

Offline

#2 2026-07-11 22:25:37

tux_99
Member
Registered: 2025-06-17
Posts: 128  

Re: [SOLVED] How can I make "xhost +" the default at every boot?

BTW, I already tried creating /etc/X0.hosts with relevant entries (see below) as indicated in the xhost manpage but that doesn't seem to have any effect.

$ more /etc/X0.hosts
+SI:localuser:username1
+SI:localuser:username2

Either the users control the program – or the program controls the users” Richard Stallman

Offline

#3 2026-07-11 23:30:00

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,946  

Re: [SOLVED] How can I make "xhost +" the default at every boot?

Another approach would be to only use 'xhost +' when you want to be the other user and then 'xhost -' when you're done. Put the following script in your path, make it executable and use it like this. I'm calling it 'swu'. You can call it whatever you like.

Open a terminal.

swu <otheruser>
(run some commands as the other user)
exit

Here's the magic sauce:

#!/usr/bin/env bash
# swu

otheruser="$1"

xhost +
su "$otheruser" 
xhost -

exit 0

Offline

#4 2026-07-13 16:40:34

tux_99
Member
Registered: 2025-06-17
Posts: 128  

Re: [SOLVED] How can I make "xhost +" the default at every boot?

Thanks, that could be a feasible workaround but surely there must be a X11 config file that gets read each time X11 is started (i.e. when logging in) in which I could put the xhost command?


Either the users control the program – or the program controls the users” Richard Stallman

Offline

#5 2026-07-16 20:23:35

tux_99
Member
Registered: 2025-06-17
Posts: 128  

Re: [SOLVED] How can I make "xhost +" the default at every boot?

I sort of solved this by adding the xhost commands I need in the XFCE configuration under "Session and Startup" -> "Application Autostart" as a 'program' to be run on login.

It works fine but I don't consider it an ideal solution as it's DE specific.

Surely there must be a generic DE-independent X11 config file where I could put these 'xhost' commands so that they run on login?
(I did also try .xinitrc in my home directory but that is ignored)


Either the users control the program – or the program controls the users” Richard Stallman

Offline

#6 2026-07-16 21:28:38

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,946  

Re: [SOLVED] How can I make "xhost +" the default at every boot?

man xsession says:

       $HOME/.xsession
              is  a  sequence  of commands invoking X clients (or a session manager such as xsm(1)).  See the manual page
              for xinit for tips on writing an .xsession file.

This page talks about the security risks of 'xhost +':
https://www.debian.org/doc/manuals/secu … 04.en.html

If you follow the (very bad) suggestion of many docs, you type xhost + on your machine. This allows any X client to connect to your system. For slightly better security, you can use the command xhost +hostname instead to only allow access from specific hosts.

Offline

#7 Yesterday 19:52:50

tux_99
Member
Registered: 2025-06-17
Posts: 128  

Re: [SOLVED] How can I make "xhost +" the default at every boot?

Thanks fsmithred, while .xsession isn't quite the right file either, by pointing me to it I did some research on it and stumbled upon the correct file:

.xsessionrc

As far as I figured out .xsession replaces the default session startup scripts that are under /etc/X11, while .xsessionrc only complements them, i.e. gets parsed last thing after the /etc/X11 startup scripts, and that's exactly what I was looking for.
I already tested it and it works as expected.

With regards to the security risks, there are none as Devuan (like most Linux distros since many years) starts Xorg with the "-nolisten tcp" parameter, so it's not accessible via the network. Only local users can access it and this is a desktop PC used by a single human user.

Last edited by tux_99 (Yesterday 19:54:04)


Either the users control the program – or the program controls the users” Richard Stallman

Offline

#8 Today 16:20:06

chris2be8
Member
Registered: 2018-08-11
Posts: 381  

Re: [SOLVED] How can I make "xhost +" the default at every boot?

Or use xhost +localhost to allow connections from the same system only. See man xhost for details (it imples that xhost local would do the same, but I'm not sure if i understood it correctly).

Offline

Board footer