LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 11-19-2003, 10:12 AM   #1
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Rep: Reputation: 30
User prompt


Is there any way to get the terminal window prompt for normal users to show the current full path that they are in, rather than just bash-2.05b$? I know the root user will show the current folder, and the entire path at the top of the window, but other users don't see that. Is there any way to get that to show up in RedHat 9?

Thanks.
 
Old 11-19-2003, 10:35 AM   #2
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
Yes there is. The bash prompt how-to has all the details.

AFAIK, if you save your setting in /etc/profile, each user will inherit the same prompt - but there's nothing to stop them changing it themselves of course.

John
 
Old 11-19-2003, 02:55 PM   #3
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Original Poster
Rep: Reputation: 30
Cool, that link helps a lot. I can get it set up just how I like it... but so far haven't been able to get it to stick. As soon as I close the terminal window, the prompt reverts back to normal. The How-to touches on what they think might work to save it, but they don't know for sure. I've tried adding the PS1 line into both profile and bashrc files in the /etc folder, without success. The link seems to think the bashrc file is the right place, but they don't really mention if it needs to be put anyplace in specific. So, I'm almost there now (and still looking), but if anyone has gotten their prompt settings to stick, I'd love to hear it.
 
Old 11-19-2003, 09:51 PM   #4
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480° N, 95.3690° W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 47
Try putting the following line in your .bashrc
export PS1='[\u \w]\$ '
 
Old 11-20-2003, 12:00 PM   #5
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Original Poster
Rep: Reputation: 30
Hmm... Still no go with this. I even put that line in a couple different places, with and without the export, just to see if something would happen. No matter where I put it though, I still get that ugly bash-2.05b$ prompt every time I log in. So far I've added these PS1 lines into .bashrc, /etc/bashrc, and /etc/profile... and it hasn't made any difference with any of them. It shouldn't matter where in the file I put this line, right?

Thanks for the suggestions so far, hopefully I can get this working yet.
 
Old 11-20-2003, 12:45 PM   #6
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
Hmmm, I just started bash and got the same prompt you're stuck with. When I typed "source /etc/profile" the prompt changed to my username, host and wdir, which is what I would expect from looking at /etc/profile.

So, it seems that /etc/profile isn't automatically read when you call bash.

When I put the line "source /etc/profile" into ~/.bashrc, then it works. But your problem then is how to create this file automatically for each user.

John
 
Old 11-20-2003, 01:02 PM   #7
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
Just did some googling, and it seems bash reads /etc/profile when it's a
login shell and ~/.bashrc otherwise.

Are you testing your changes by logging completely in and out, or just by opening a new xterm? I don't know enough to know how booting into runlevel 5 will affect things. Is bash still the login shell in that case?

John
 
Old 11-20-2003, 01:18 PM   #8
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Original Poster
Rep: Reputation: 30
Hey John, thanks for all the help with this. Thus far, I've been opening new xterm windows to test for the most part, but I've also restarted a few times as well, just to make sure. I see what you mean about the source thing.. typing "source /etc/profile" gets things looking right for me too. I only need to get this working for 1 user ideally, but knowing how to do it for others would be very helpful. Does each user account have their own profile that needs to be edited?

I did add that line into the .bashrc file, and it doesn't seem to work when just opening a new xterm window. When you added it, did it start working right away? Or did you logout first? Maybe a reset is needed for it to kick in... have to give that a shot.

Also, I'm not sure yet about how bash is running when in graphic mode.

Thanks again.

Last edited by Phaethar; 11-20-2003 at 01:31 PM.
 
Old 11-20-2003, 01:49 PM   #9
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
No problem, Phaethar, I like doing this stuff.

The general pattern for shells is that there's a system wide set-up file in /etc which is read first and then the shell looks in the users home directory for customisations. If some variable is set twice, the user's set-up file overrides the /etc one, simply by virtue of being read second, but if there isn't any file there, the shell doesn't care.

The /etc files save sysadmins a lot of hassle keeping everyone's profile up-to-date with any changes in the environment, etc. Then what the users do with their set-up is up to them.

I'm off now, let me know how you get on.

John
 
Old 11-21-2003, 01:41 PM   #10
Phaethar
Member
 
Registered: Oct 2003
Location: MN
Distribution: CentOS, Fedora
Posts: 182

Original Poster
Rep: Reputation: 30
Hey John,

That explanation makes sense, seems to allow for users to customize some of their own settings. So, when the shells look to the home directory, are they still looking for a bashrc file for the settings, or a profile? Since I haven't had any luck just adding the settings to the global config files, maybe I will have better luck with the individual users (which there aren't that many of luckily).


Edit: Nevermind, answered my own question. Created a .bashrc file in the users home directory with the line 'source /etc/profile' and things seem to be working correctly now, even tried multiple terminal apps (Gnome-terminal, xterm) and they all seem to be working right. Thanks for all the help!

Last edited by Phaethar; 11-21-2003 at 01:48 PM.
 
  


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
add a user with password without prompt grendel-IT Linux - Software 7 09-27-2006 02:07 PM
add user prompt for password on login redir Linux - Newbie 2 02-28-2005 11:01 AM
Prompt w/ current dir and user Jair Slackware 2 03-15-2004 06:16 PM
Deleting a user account from prompt lozz1978 Linux - Newbie 8 01-15-2004 07:43 AM
user comand prompt changed - don't know why sadmac Linux - Newbie 2 04-24-2003 12:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

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