LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux Mint
User Name
Password
Linux Mint This forum is for the discussion of Linux Mint.

Notices


Reply
  Search this Thread
Old 12-27-2010, 12:01 AM   #1
aquaboot
Member
 
Registered: May 2005
Location: Berkeley, CA.
Distribution: debain freebsd
Posts: 483

Rep: Reputation: 31
setting shell variables- no .bashrc


Just installed LMDE and don't see .bashrc in normal or root user's homes. I'm trying to set up command aliases. Where the heck should they go?

ab
 
Old 12-27-2010, 12:12 AM   #2
prodev05
Member
 
Registered: Jul 2009
Location: Planet Earth
Distribution: Unix & Linux Variants
Posts: 304

Rep: Reputation: 20
if your shell is bash then it(.bashrc) should be there, else create it and append the alias.
 
Old 12-27-2010, 12:27 AM   #3
aquaboot
Member
 
Registered: May 2005
Location: Berkeley, CA.
Distribution: debain freebsd
Posts: 483

Original Poster
Rep: Reputation: 31
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.

Thanks,

ab
 
Old 12-27-2010, 07:35 AM   #4
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 48
/etc/profile or /etc/bashrc (or /etc/bash.bashrc) could be potential candidates.
 
Old 12-27-2010, 09:50 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
All the bash startup files are described here.

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
 
Old 01-06-2011, 10:59 PM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
@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
 
Old 01-07-2011, 03:06 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
From the su man page:
Code:
       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
 
Old 01-07-2011, 03:31 AM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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??
 
Old 01-07-2011, 09:15 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by grail View Post
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.
 
Old 01-07-2011, 09:33 AM   #10
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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.

I look forward to any findings you might have?
 
  


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
[SOLVED] Setting system wide shell variables in RHEL5 leblinux Red Hat 10 05-11-2010 12:00 PM
Setting up environment variables for j2se and j2ee on linux in .bashrc vitalstrike82 SUSE / openSUSE 1 03-30-2008 07:26 AM
Need help setting environment variables via shell script srosburg Linux - Newbie 2 12-08-2005 07:58 PM
Setting environment variables from shell script theta Linux - General 5 09-02-2004 08:50 PM
Setting Shell variables tmoorman Linux - Software 6 11-19-2003 03:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux Mint

All times are GMT -5. The time now is 11:04 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