You are not logged in.

#1 2023-04-26 12:56:02

860lacov
Member
Registered: 2020-05-02
Posts: 497

[SOLVED] How to find the source of unknown environment variables?

After running the printenv command, I noticed several environment variables that I recognize, except for a few that I'm curious about:

KONSOLE_DBUS_WINDOW=/Windows/1
JOURNAL_STREAM=8:27766
QSG_RENDER_LOOP=basic
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
MAIL=/var/spool/mail/jm

The variable that stands out to me the most is KONSOLE_DBUS_WINDOW=/Windows/1. I used to have a dual-boot setup with Windows, but I have since removed it and there is no longer a /Windows directory on my system.

When I checked /etc/environment, the only variable set there is MOZ_ENABLE_WAYLAND=1 firefox, (this one I created).

I have also checked /etc/profile, ~/.bash_profile, and ~/.profile, but none of them contain any variables.

I tried

sudo find /home/jm/ -type f -size -1M -exec grep "KONSOLE_DBUS_WINDOW" {} \;

However, it did not return any results, and using the -size -2M option seems to take forever.

Last edited by 860lacov (2023-04-27 09:37:28)

Offline

#2 2023-04-26 13:07:15

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

Re: [SOLVED] How to find the source of unknown environment variables?

This will give you a set of pids with that variable in their environment

sudo find /proc/ -name environ -exec grep -l 'KONSOLE_DBUS_WINDOW=' '{}' \+ | cut -d / -f 3 | sort -u

Then check what processes those are.  One of those processes set it ... start checking with the lowest numbered pids.  Or as a script:

#!/bin/sh

sudo find /proc/ -name environ -exec grep -l 'KONSOLE_DBUS_WINDOW=' '{}' \+ 2>/dev/null \
	| cut -d / -f 3 \
	| sort -nu \
	| while read pid; do
		cat /proc/$pid/comm 2>/dev/null
	done

Sidenote: there is no reason to use sudo to run find on your home directory as you did

But are you using KONSOLE as your terminal?  I'd guess that'd be what's setting that variable.

Last edited by Trilby (2023-04-26 13:08:50)


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

Offline

#3 2023-04-26 14:12:27

loqs
Member
Registered: 2014-03-06
Posts: 18,961

Re: [SOLVED] How to find the source of unknown environment variables?

Trilby wrote:

But are you using KONSOLE as your terminal?  I'd guess that'd be what's setting that variable.

https://github.com/KDE/konsole/blob/v23 … r.cpp#L606
Edit:
https://www.freedesktop.org/software/sy … NAL_STREAM
Edit2:
DBUS_SESSION_BUS_ADDRESS is set by pam_systemd https://github.com/systemd/systemd/comm … 925640f0b7

Last edited by loqs (2023-04-26 14:21:57)

Offline

#4 2023-04-26 21:31:49

860lacov
Member
Registered: 2020-05-02
Posts: 497

Re: [SOLVED] How to find the source of unknown environment variables?

Trilby wrote:

This will give you a set of pids with that variable in their environment

sudo find /proc/ -name environ -exec grep -l 'KONSOLE_DBUS_WINDOW=' '{}' \+ | cut -d / -f 3 | sort -u

Then check what processes those are.  One of those processes set it ... start checking with the lowest numbered pids.  Or as a script:

#!/bin/sh

sudo find /proc/ -name environ -exec grep -l 'KONSOLE_DBUS_WINDOW=' '{}' \+ 2>/dev/null \
	| cut -d / -f 3 \
	| sort -nu \
	| while read pid; do
		cat /proc/$pid/comm 2>/dev/null
	done

Sidenote: there is no reason to use sudo to run find on your home directory as you did

But are you using KONSOLE as your terminal?  I'd guess that'd be what's setting that variable.

I had some files owned by root in my home directory. That's why sudo.
Yes. I use konsole




loqs wrote:
Trilby wrote:

But are you using KONSOLE as your terminal?  I'd guess that'd be what's setting that variable.

https://github.com/KDE/konsole/blob/v23 … r.cpp#L606
Edit:
https://www.freedesktop.org/software/sy … NAL_STREAM
Edit2:
DBUS_SESSION_BUS_ADDRESS is set by pam_systemd https://github.com/systemd/systemd/comm … 925640f0b7

Thank you.
I tried to search environments variables in google, but didn't find anything related.
Did you know about those things or are you just better with searching?

Offline

#5 2023-04-26 23:08:41

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

Re: [SOLVED] How to find the source of unknown environment variables?

c) "all of the above"

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

Board footer

Powered by FluxBB