You are not logged in.

#1 2010-10-02 21:54:38

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 442

bashrc related minor headache

Hello there

I'm trying to set up a simple .bashrc color prompt for "myuser" and "root" by editing /home/myuser/.bashrc and /root/.bashrc

Both are working fine in any gnome terminals, I see my nice new colors, and if i use sudo su, i see roots color prompt

However, if I switch to any of my tty1-6 and I log in as root or myuser, I still see the old white bash colors

It looks like /etc/bash.bashrc is relevant here, but how ?

(Strangest thing, if I log in into tty1-6 with myuser, colors are white - but if I do sudo su, I have the colors of /root/.bashrc)

How can I have simply my colors in a terminal login without touching my /etc/bash.bashrc?


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

#2 2010-10-02 22:00:51

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: bashrc related minor headache

Is bash your login shell? Try to source /home/myuser/.bashrc by hand:

. /home/myuser/.bashrc

Offline

#3 2010-10-02 22:03:05

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 442

Re: bashrc related minor headache

what do you mean by sourcing it? ( and yes, it is my shell)

# cat /etc/passwd | grep myuser:

myuser:x:1000:100:BloodyMe,,,:/home/myuser:/bin/bash

Last edited by scar (2010-10-02 22:04:29)


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

#4 2010-10-02 22:07:11

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: bashrc related minor headache

scar wrote:

what do you mean by sourcing it?

Run the command I posted: 'dot space /path/to/your/.bashrc'

Offline

#5 2010-10-02 22:11:02

patlkli
Member
From: Landshut, Germany
Registered: 2010-07-11
Posts: 10
Website

Re: bashrc related minor headache

The difference between your TTYs and your gnome terminals is that a TTY is a login shell and the gnome terminals are non-login shells.

Login shells read the profile files (/etc/profile, ~/.bash_profile, ~/.bash_login, and ~/.profile) and non-login shells read the bashrc (/etc/bash.bashrc and ~/.bashrc).

The most easy way to force your TTY to do the same as your gnome terminal is to source the .bashrc in .profile.

Offline

#6 2010-10-02 22:11:25

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 442

Re: bashrc related minor headache

it is done, buit i have to do it with all my users including root?

if it is the case, when I log in as root, it works fine, but with a regular user it is a bit funny, I got an error message ( do not have perm to access /root/.bashrc - because I've "sourced it" ) smile

Why can't it work just with ~/.bashrc ?

Last edited by scar (2010-10-02 22:12:20)


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

#7 2010-10-02 22:12:46

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: bashrc related minor headache

Read patlkli's post and don't source root's stuff as a user ;P

Not sure if it helps you understand but http://wiki.archlinux.org/index.php/Hel … and_source

Last edited by karol (2010-10-02 22:14:50)

Offline

#8 2010-10-02 22:44:59

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 442

Re: bashrc related minor headache

not really dolved the problem, but :

I've edited my .bashrc with this stuff in it:

if [ `id -u` = 0 ] # is it root ?
then
. /root/.bashrc
fi

if [ `id -u` = 1000 ] # is it myuser ?
then
. /home/myuser/.bashrc
fi

It would be nicer if bash used my .bashrc simply in any ttys too............


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

#9 2010-10-02 23:01:24

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: bashrc related minor headache

scar wrote:

not really dolved the problem, but :

I've edited my .bashrc with this stuff in it:
.

Your .bashrc or bash_profile?

Offline

#10 2010-10-03 20:54:46

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 442

Re: bashrc related minor headache

my .bashrc


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

#11 2010-10-03 20:57:00

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: bashrc related minor headache

scar wrote:

my .bashrc

In your /home/myuser/.bashrc? And it did help?

Offline

#12 2010-10-07 12:14:30

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 442

Re: bashrc related minor headache

sorry, I was not precise enough

The file above is /etc/bash.bashrc
I'm sourcing the profiles of myuser and root, and it solved the problem

But if I add a new user, I have to source his profile too, else his profile remains the same even if I edit his .bashrc

So it does not solved anything, it is just a workaround

(my install is a fresh one)


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

#13 2010-10-07 12:27:19

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: bashrc related minor headache

There's a few ways you can do this:

1) Set the PS1 in /etc/profile and do *not* set it anywhere else.

2) Set the PS1 in ~/.bash_profile and do *not* set it in ~/.bashrc
This means you'll have to set each user's one, but the user's .bash_profile gets set from a template one whenever their account is created. So set it in there, too.
I'm not sure where this template file is, but I'm sure it can be found with a search.

3) Set the PS1 in ~/.bash_profile and source that file from ~/.bash_profile. Again, see (2) for new users. The ~/.bashrc will also get created from a template.

4) Do what you're doing now, but change your code to this:

. $HOME/.bashrc

The $HOME will return the path to the user's .bashrc so you don't need to hard code in paths or check for IDs etc.

5) To be suggested by someone else wink


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#14 2010-10-07 12:30:33

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: bashrc related minor headache

Now it makes more sense :-)

/etc/skel/.bash_profile has the line you need: '. $HOME/.bashrc'. If you create a new user with the skel files copied over to his home folder, you have a working profile w/o any tricks.

Offline

#15 2010-10-07 12:32:29

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: bashrc related minor headache

/etc/skel/.bash_profile

That's the one. Forgot about skel (age you know). neutral


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#16 2010-10-07 12:35:40

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: bashrc related minor headache

skanky wrote:

/etc/skel/.bash_profile

That's the one. Forgot about skel (age you know). neutral

;P

Those files are used when you

useradd -m

-m, --create-home
           Create the user's home directory if it does not exist. The files and directories contained in the
           skeleton directory (which can be defined with the -k option) will be copied to the home directory.

           By default, no home directories are created.

If you omit the '-m' switch you need to fix it yourself.

Offline

Board footer

Powered by FluxBB