LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Right place to setup path statement (https://www.linuxquestions.org/questions/linux-newbie-8/right-place-to-setup-path-statement-700624/)

steflik 01-28-2009 04:07 PM

Right place to setup path statement
 
Hi, I'm not new to Linux but have always wondered where the right place to set up the path is so that it is set for all users as soon as they start a session?

Dick Steflik

sycamorex 01-28-2009 04:17 PM

For all non-root users there's an option in /etc/profile:

Code:

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi

You could modify it. However, wouldn't it be better to set it up separately for each user in ~/.bashrc?

onebuck 01-28-2009 04:21 PM

Hi,

I like to setup my .bashrc and .bash_profile;

Code:

#.bashrc

# Add bin to path
export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# Custom prompt
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

if [ `id -un` = root ]; then
  PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
 else
  PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi
#
# Add color
eval `dircolors -b`

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
  trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
#  trap 0 rm -f ~$LOGNAME/.bash_history

Code:


# .bash_profile
# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi


i92guboj 01-28-2009 09:57 PM

Quote:

Originally Posted by steflik (Post 3424510)
Hi, I'm not new to Linux but have always wondered where the right place to set up the path is so that it is set for all users as soon as they start a session?

Dick Steflik

This entirely depends on the shell you/they use. So, you need to read the man page for the shell(s) you allow in your box.

For bash, /etc/profile is a good choice for global configs. But note that any user can completely override it on his or her personal settings. If you want to know all the files that are involved for bash check the "INVOCATION" section on its man page.

For other shells the picture will be different. So, again, check the shells you allow and read their man pages.


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