LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-29-2010, 01:42 AM   #1
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Rep: Reputation: 48
not everything in bash_profile is executed...


I have edited my dot bash_profile as follows:
Code:
bash-3.1$ cat /home/logicalfuzz/.bash_profile
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
export PS1='\u@\H \w $ '
alias ls='ls --color=tty'
bash-3.1$
while the PATH variable works just fine... the others dont.. can someone point out whats wrong with this?
 
Old 05-29-2010, 02:05 AM   #2
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
What are the symptoms that make you believe the PS1 and ls alias don't work?

PATH is not exported so will work only interactive shells; it will not be available in, for example, any shell scripts which will have the original version of $PATH.

Regards PS1, you can use echo $PS1 to show that it has been set. If \H does not display anything try \h. If that does not work (or you need \H) perhaps there is something wrong with the local hostname setting. What is the output of hostname ?

The ls alias tests OK on my system. You can check if it has been set using the alias command with no options or arguments. You can check the command itself by running /bin/ls --color=tty
 
Old 05-29-2010, 02:08 AM   #3
mac.tieu
Member
 
Registered: Jan 2010
Location: Vietnam
Distribution: Arch
Posts: 65

Rep: Reputation: 22
Quote:
Originally Posted by logicalfuzz View Post
I have edited my dot bash_profile as follows:
Code:
bash-3.1$ cat /home/logicalfuzz/.bash_profile
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
export PS1='\u@\H \w $ '
alias ls='ls --color=tty'
bash-3.1$
while the PATH variable works just fine... the others dont.. can someone point out whats wrong with this?
Your file look good, have you apply changes after edit?
Code:
source /home/logicalfuzz/.bash_profile
Regards,
MT
 
Old 05-29-2010, 03:47 AM   #4
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by catkin View Post
What are the symptoms that make you believe the PS1 and ls alias don't work?
I just checked this again... PS1 and ls alias seem to work well in Konsole, but not Yakuake.. but i hardly use Konsole.. most of the time i use Yakuake, hence i had not noticed this. (PATH does work though, as expected, in Yakuake)

Quote:
Originally Posted by catkin View Post
PATH is not exported so will work only interactive shells; it will not be available in, for example, any shell scripts which will have the original version of $PATH.
Noted. I'll 'export' the PATH variable


Quote:
Originally Posted by catkin View Post
Regards PS1, you can use echo $PS1 to show that it has been set. If \H does not display anything try \h. If that does not work (or you need \H) perhaps there is something wrong with the local hostname setting. What is the output of hostname ?
echo $PS1 in Yakuake says '\s-\v\$'. Since it is working good in Konsole (as admitted above) i am assuming the \H is correct

Quote:
Originally Posted by catkin View Post
The ls alias tests OK on my system. You can check if it has been set using the alias command with no options or arguments. You can check the command itself by running /bin/ls --color=tty
again, simply firing 'alias', shows me the --color=tty in Konsole, but not in Yakuake

Last edited by logicalfuzz; 05-29-2010 at 03:50 AM.
 
Old 05-29-2010, 03:50 AM   #5
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by mac.tieu View Post
Your file look good, have you apply changes after edit?
Hi MT,
There have been multiple reboots after having changed the .bash_profile file. So, i presume, it should have been executed...
 
Old 05-29-2010, 08:10 AM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

You could setup a .bashrc & .bash_profile for yourself or for a user;

Code:
sample .bash_profile;

# .bash_profile
#08-30-06 12:21
#
# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
Code:
sample .bashrc;

#.bashrc
#08-30-06 12:20 

# Add bin to path

export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#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\]\$ '

#08-29-06 11:40

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'

#08-29-06 11:50

#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
The .bashrc is very useful!

 
Old 05-29-2010, 08:26 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
Quote:
Originally Posted by logicalfuzz View Post
I just checked this again...
Thanks for the update. Given that, in Yakuake, $PS1 is different and alias does not show the ls alias from your ~/.bashrc it seems likely that Yakuake initialisation is doing some other bash initialisation ... ?
 
Old 05-29-2010, 11:47 AM   #8
sandgroper
Member
 
Registered: Jul 2004
Location: Perth , Western Australia
Distribution: Fedora Core 5 , Mint 9
Posts: 118

Rep: Reputation: 15
Here is a copy of my working .bash_profile in Fedora , it should give you an idea of how to set up your bash_profile.

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

PATH=$PATH:$HOME/bin:$HOME/bin/
BASH_ENV=$HOME/.bashrc
USERNAME="steve"
PS1='[\u@\h]$ '
PS2='[\u@\h]# '
export USERNAME BASH_ENV PATH PS1 PS2 
clear
uname -osrn
date
echo
.
 
Old 05-29-2010, 12:43 PM   #9
logicalfuzz
Member
 
Registered: Aug 2005
Distribution: Arch Linux
Posts: 291

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by onebuck View Post
The .bashrc is very useful!
Indeed yes! i did not have a .bashrc before... now that i have it, and all commands moved to bashrc file from bash_profile, they seem to work.. thanks!

I am yet to figure out how the PATH variable was working.. maybe its set somewhere else too... 'coz i can now see the 'sbin' paths in the PATH variable twice.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
~/.bash_profile not being executed at login Radicalm16 Slackware 9 07-28-2009 09:39 PM
.bash_profile not executed at login Kiwi944 Linux - Newbie 6 06-25-2009 07:22 AM
why executables are executed through ./ only keanu Linux - Newbie 6 09-17-2007 05:24 AM
.bashrc and .bash_profile not executed enlight1 Fedora 5 06-27-2006 08:24 PM
.bashrc not being executed, why? realos Linux - Newbie 1 12-20-2003 07:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:14 AM.

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