Revision as of 12:22, 7 August 2011 by Annew (talk | contribs)

Session Environment Variables

It is simple to set environment variables that affect your whole session. KDE will execute any script it finds in $HOME/.kde/env whose filename ends in .sh, and it will maintain all the environment variables set by them. it is important that any variable you want to set must be also exported. In the case of PATH, for instance, your system will be set up with certain likely directories as the likely places to find things. Now you are adding an extra possible search place. You can see what is already set by opening Konsole and typing echo $PATH

To add paths to your PATH, simply create a file named $HOME/.kde/env/ with a contents similar to this:

export PATH=$HOME/local/bin:$PATH

Let's explore that. The command export tells the system that this is something that should be saved and used when looking for files. Next you add the full name of the directory you want to add (in this case ~/local/bin, another way of writing /home/you/local/bin - again you can use echo $HOME to see how that works). Finally you see the $PATH variable itself - that's because you want to add your new path into it, not replace the existing path.

Often that will work well enough for you, but as you get more familiar with the system you will probably want to have the same environment when using a console or accessing your machine via ssh, you will need to add to the end of your .bashrc something like this:

source $HOME/.kde/env/

You can also check how KDE actually does it. It's done in your local startkde, which normally you can find in /usr/bin/startkde. You can also can view it online. Just search for environment variables.

This page was last edited on 13 June 2018, at 16:14. Content is available under Creative Commons License SA 4.0 unless otherwise noted.