Linux MintThis forum is for the discussion of Linux Mint.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thanks for the reply. Both root and user are using bash but after doing a search, I find it nowhere on my system. I wonder where I set the search path etc? Coming from Debian Stable and used to seeing the .bashrc and editing it. Maybe I'll find a stock bashrc on the web and use that.
Here's a sample .bashrc for root, just to get you going. Because it is a customisation file there is no "one size fits all" and you may not like any of this one!
Code:
# Locally created customisation for bash interactive non-login shells
# Set command prompt
# This needs to be here rather than in /etc/profile because $TERM
# is not appropriate when logging in graphically
case $TERM in
mrxvt | rxvt | rxvt-unicode | xterm )
export PS1='\[\033]0;\u@\h:\w\007\]\u@\h:\w\$ '
;;
* )
export PS1='\u:\w\$ '
esac
# Aliases
alias df='df -hT'
alias lrt='ls -lrt --human-readable --color=never'
alias ll='ls -l --human-readable --color=never'
alias vl='cd /var/log; lrt'
# Functions
function wll {
local afn
afn=$( which "$1" )
[[ $? -ne 0 ]] && { echo "$afn" ; return 1 ; }
ll "$afn"
file "$afn"
}
Last edited by catkin; 12-27-2010 at 09:52 AM.
Reason: speeling and puncturation
@catkin - I looked at the link you provided and it seems to gel with what I thought I knew, however, are you able to explain to me what file(s) are referenced
when performing something like the following:
Code:
su user -c 'echo $PATH' --login
According to the link it should be:
Quote:
When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
So my understanding is that the above is non-interactive but as --login has been used it should go through the list of files mentioned.
In my /etc/profile I have the following line (as a test):
Code:
export PATH=$PATH:/sbin
But it seems when I execute the 'su' listed above my PATH is:
Code:
/bin:/usr/bin
This is the default as defined in login.defs for ENV_PATH.
Now should I actually login as the user then the PATH variable is set as required with /sbin also included.
Are you (or anyone else) able to explain what I am missing??
Note: sorry for hijacking question but it was not marked as SOLVED so figured there are more answers required
The current environment is passed to the new shell. The value of $PATH is reset to /bin:/usr/bin for normal users, or
/sbin:/bin:/usr/sbin:/usr/bin for the superuser. This may be changed with the ENV_PATH and ENV_SUPATH definitions in
/etc/login.defs
So then none of the files listed in your link are sourced I did read the man page and saw the segment you have quoted, but it also says:
Code:
-, -l, --login
Provide an environment similar to what the user would expect had the user logged in directly.
And thought that this call to --login was the same one mentioned in your link. As this appears to not be the case, where and when is --login used and with what command??
And thought that this call to --login was the same one mentioned in your link. As this appears to not be the case, where and when is --login used and with what command??
I have always used su - <user name> (equivalent to using the --login option) and assumed it was equivalent to logging in. Now it seems it is equivalent to logging in except for PATH. I don't have time to experiment now.
Yes I too use, su - <user name>, and until recently thought all the settings, not just PATH as none of my aliases work either, were being loaded.
I have also tried placing them in ~/.bashrc, as the non-interactive login place to set things, and this also does not utilise any of the predefined settings when called
with su in this way. It concerns me as I am trying to also consider how this will affect the scripts I have being run under these users.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.