Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-24-2009, 11:32 AM   #1
Registered: Aug 2003
Location: Slovenia
Distribution: Arch, Debian, Embedded
Posts: 136

Rep: Reputation: 15
kdm/kde hijacking $PATH environment


I have small problem with my environment variables, particularly the $PATH. I have set the PATH in /etc/environment to: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:."

It was a small modification to include the current path "." at the end. If I let the system boot to the kdm login screen, and do ctrl+alt+F2 to login on another tty as a regular user, I get the proper $PATH output when issuing a `set` command or `echo $PATH`. The same happens when I login as root. PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:.

Going back to kdm with ctrl+alt+F7 and logging in with my regular user account will bring me to my KDE screen. So when I fire up a terminal (Konsole) in KDE, the $PATH will look completely different: PATH=/opt/kde3/bin:/opt/kde3/games:/usr/local/bin:/opt/kde3/bin:/usr/bin:/bin:/opt/kde3/games:/usr/games

Notice that /opt/kde3/bin and /opt/kde3/games appear twice, and that /sbin is missing? It appears that for some reason $PATH is getting completely overwritten. Doing a `su <user>` to login as another user in the existing terminal will once again show appropriate $PATH as defined in /etc/environment.

Any ideas what might be causing this and how to prevent it? My kde version is 3.5.10.
Old 10-24-2009, 06:47 PM   #2
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 129Reputation: 129
Set it in your ~/.bashrc too, it might work.
Old 10-26-2009, 02:17 AM   #3
Registered: Aug 2003
Location: Slovenia
Distribution: Arch, Debian, Embedded
Posts: 136

Original Poster
Rep: Reputation: 15
Yeah, exporting the path in .bashrc works. Looking at it again, I've exported a few more variables in /etc/environment, which do not appear in Konsole terminal unless I redefine them in .bashrc too. However, having two separate places for environmental vars isn't a good idea, as I'm sure you'd agree. I'm still wondering what is causing these vars to be overwritten and/or reset, as it did not happen before I installed kdm.

Looking at my disk, I found a file /etc/kde3/kdm/kdmrc where an interesting piece of text can be found:

# The PATH for the Session program.
# Default is "/usr/local/bin:/opt/kde3/bin:/usr/bin:/bin:/opt/kde3/games:/usr/games"
Notice how this string matches a part of the hijacked $PATH in my first post? In another file at /opt/kde3/bin/startkde you can see how the first two folders get added to the $PATH and become duplicates:

export KDEHOME=$HOME/.kde3 && export PATH=/opt/kde3/bin:/opt/kde3/games:$PATH && export KDEDIRS=/usr/:/opt/kde3/ && export XDG_DATA_DIRS=/opt/kde3/share/:/usr/share/ && export XDG_CONFIG_DIRS=/opt/kde3/etc/xdg/:/etc/xdg/ && export MANPATH=/opt/kde3/share/man:$MANPATH
I think kdm is the main culprit here.


kde, kdm, path

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help w/ a few PATH and Environment variables DaFrEQ SUSE / openSUSE 3 06-10-2006 04:12 PM
ServerCmd wrong path in Debian Etch /etc/kde3/kdm/kdmrc forgox Debian 0 05-28-2006 06:51 PM
PATH environment variable moonz Red Hat 3 09-08-2005 04:10 PM
setting environment PATH heathpitts Linux - Newbie 26 12-03-2004 10:15 AM
Changing environment path. JMC Linux - General 1 05-04-2002 03:50 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:39 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration