LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 11-19-2003, 10:55 AM   #1
tmoorman
Member
 
Registered: Aug 2003
Location: Ottawa, Ontario, Canada
Distribution: Kubuntu
Posts: 50

Rep: Reputation: 15
Question Setting Shell variables


The PATH shell variable is wrong on my system (Mandrake 9.2). I can set it properly with
PATH=/usr/bin:/usr/sbin:...
Where in the system (/etc/ ?) are shell variables set on boot?

Thanks
 
Old 11-19-2003, 11:00 AM   #2
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Environment variables are set depending on the user and upon which shell they choose to use. If you're using bash for your shell (the default on many Linux distributions), check for a file called .bashrc in your home directory. There's also a global set of definitions in /etc/bashrc. If you want to change your path, for instance, you can edit your ~/.bashrc to add any environment variables you want.

By the way, what's wrong with your path variable? Mine's always given me everything I need; usually, normal users should have /bin, /usr/bin, /usr/local/bin, /usr/X11R6/bin and possibly a couple others. Normal users could, I suppose, have /usr/sbin and /sbin on their path as well, but most of the time they don't need to, since they contain system administration binaries, and only root should be running them most of the time.

Last edited by wapcaplet; 11-19-2003 at 11:03 AM.
 
Old 11-19-2003, 11:19 AM   #3
tmoorman
Member
 
Registered: Aug 2003
Location: Ottawa, Ontario, Canada
Distribution: Kubuntu
Posts: 50

Original Poster
Rep: Reputation: 15
I am running bash

echo $SHELL
/bin/bash

I have the same .bashrc for both root and my normal user:

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

There is nothing in /etc/bashrc for PATH.

# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
umask 002
else
umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
case $TERM in
xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
;;
*)
;;
esac
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

if [ -z "$loginsh" ]; then # We're not a login shell
for i in /etc/profile.d/*.sh; do
if [ -x $i ]; then
. $i
fi
done
fi
fi

unset loginsh

Every time I start a new shell the path is reset to this:
/usr//bin:/bin:/usr/bin::/usr/local/bin:/usr/X11R6/bin:/usr/games:/home/tmoorman/bi

Where is this set?
 
Old 11-19-2003, 11:22 AM   #4
tmoorman
Member
 
Registered: Aug 2003
Location: Ottawa, Ontario, Canada
Distribution: Kubuntu
Posts: 50

Original Poster
Rep: Reputation: 15
BTW, I am running Konsole under Kde 3.1
 
Old 11-19-2003, 11:56 AM   #5
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
....... adding to what Wap said - check this site out:

http://www.linuxenvy.com/gened/notes/note_path.html
 
Old 11-19-2003, 01:34 PM   #6
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Some PATH stuff is probably set in /etc/profile and/or ~/.profile. It looks like your /etc/bashrc is also pulling in all the scripts from /etc/profile.d/*, which may also be changing the PATH.

If you want your path to be something explicit, you could just add to ~/.profile:

export PATH=/stuff/you/want/on/the/path

but that could disrupt things if you install a new program that also needs to add itself to your path, so it's probably better to use:

export PATH=$PATH:/other/stuff

which will just add to your existing path.
 
Old 11-19-2003, 03:41 PM   #7
tmoorman
Member
 
Registered: Aug 2003
Location: Ottawa, Ontario, Canada
Distribution: Kubuntu
Posts: 50

Original Poster
Rep: Reputation: 15
I found the solution at mandrakeclub.com
http://www.mandrakeclub.com/modules....&post_id=32900
There are two variables, SystemPath and UserPath in /usr/share/config/kdm/kdmrc, which were set incorrectly. I changed them, restarted Kde and now I get the correct path with every shell.
This seems to be specific to Mandrake 9.2 upgrades.
 
  


Reply



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
Setting environment variables from shell script theta Linux - General 5 09-02-2004 08:50 PM
Sub shell environment variables tnine9 Programming 1 06-08-2004 01:27 PM
Why?? can not use variables with shell script Bassam Linux - General 9 01-27-2004 07:42 AM
Shell Variables. ducka Programming 5 09-03-2003 05:38 PM
Makefiles and shell variables Snabber Linux - Software 1 08-05-2003 11:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:44 PM.

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