Jump to content

Shell prompt problem Reposted from Old board


willisoften
 Share

Recommended Posts

My shell prompt reads:

 

bash-2.05b$

 

It doesn't matter where in the system I navigate to it's always the same. If I su then its fine it behaves as I expect it to but this bash-2.05b$ business is driving me up the walls! I can't tell where I am from the prompt.

 

Does anyone know whats going on? I have no ~/.bashrc file although the one in /etc seems fine. I have tried creating a soft link between my home directory and /etc/bashrc but no joy so far.

 

(Thanks to Glitz for help already recieved.)

Link to comment
Share on other sites

Are you using KDE?

 

If yes, then the answer is:

 

edit /etc/X11/Xsession and replace the:

#!/bin/sh

 

with:

#!/bin/bash -login

 

This was widely discussed in the old board here:

http://www.club-nihil.net/mub/viewtopic.php?t=5805

http://www.club-nihil.net/mub/viewtopic.php?t=6610

 

If you aren't using KDE, check that your login shell is bash

 [arusabal@localhost ~]$  awk -F: "/$USER/ {print $NF}" < /etc/passwd

/bin/bash

[arusabal@localhost ~]$

 

If there you see /bin/sh edit /etc/password and put /bin/bash in your user's line.

Link to comment
Share on other sites

Hi aru (shorter to type than arusabal)

No joy. I tried that but it just didn't work.

Doesn't the # mean its a coment.

 

Edit 1 Sorted!

I copied .bashrc and .bashprofile from my laptop to my desktop home directory. (seems like cheating!)

 

Thanks anyway aru, it's good to know I can always find a Valencia supporter when I need one :D

Link to comment
Share on other sites

Check out this web site..

 

http://www.linux.org/docs/ldp/howto/Bash-Prompt-HOWTO/

 

so, open a console and play around with prompt strings

 

PS1='u w $'

 

save this in a file in your /etc/profile.d folder (think this works for kde as well) or in your ~/.bashrc or ~/.profile.

 

Make sure your console command is setup to reload your login each time you open a window..

Link to comment
Share on other sites

Thanks anyway aru, it's good to know I can always find a Valencia supporter when I need one :D

:lol:

 

Doesn't the # mean its a coment.

No, not in the first line of a script, there it tells the kernel which will be the interpreter that should run the script.

 

cannonfodder and willisoften, those are patches to hide a problem but not its solution :wink:. The issue is that when you open a terminal (subshell) its environment variables (such as PATH and PS1) are inherited from its parent process; a normal terminal doesn't open a login shell, so it will only read ~/.bashrc but not the system profiles, inheriting most of its environment vars from its parent. So for PATH and PS1, there should be a parent process that had already started a bash login sesion, and thus read the /etc/profile /etc/bashrc ~/.bash_profile.

 

For some reason(1), KDE doesn't start a bash login shell in its "launching process" at runlevel 5 (kdm), so the terminals you open can't inherit those environment variables, so they take their defaults. That's why I proposed that (limited) solution (after searching some KDE sites -- and as I don't use KDE I cannot test if it works or not). With that, I guess that doing that you'll ensure that at least is a bash login shell the one that is launching KDE.

 

(1) security?

Link to comment
Share on other sites

So we are talking apples and oranges?

 

I've done the patch I suggested and then just set the gnome terminal to use the --login parameter to process the login scripts. Haven't really considered it past that point... would I be right then in stating this is a KDE terminal issue? That's why I don't have a problem in gnome?

Link to comment
Share on other sites

IFAIK, It seems that is a problem only with KDE (maybe kdm), and it affects later releases (also AFAIK). I don't use KDE, and I still have Mdk8.1, so I only know this problem from the people who asked solutions in the old board. Never happened to me.

 

Check out this link from kde.org:

http://www.kde.org/documentation/faq/confi....html#id2913380

9.7. KDE (kdm) does not read my .bash_profile!

 

The login managers xdm and kdm do not run a login shell, so .profile, .bash_profile, etc. are not sourced. When the user logs in, xdm runs Xstartup as root and then Xsession as user. So the normal practice is to add statements in Xsession to source the user profile. Please edit your Xsession and .xsession files.

 

there is where applies the #! /bin/bash at Xsession. But if you check the changelog of the "xinitrc" rpmpackage you'll see that Mdk (also Redhat, if you check their rpm package) changed the #! /bin/bash -login to #! /bin/sh (I don't know the reason)

 

The problem applies to kdm (IMHO) -- I use gdm --

Link to comment
Share on other sites

I'm pretty much a settled KDE user. In my case it looks like for some reason no local .bashrc or .bash_profile files were created on the desktop.

 

They were created on the laptop and there has never been such a problem with the laptop. So I presume someting went wrong during the install?

 

To go back to aru's first fix my script now reads #! /bin/bash -login as well as having the home directory bash files copied from the laptop. I still don't know or at least haven't tested if #! /bin/bash -login is strictly necessary.

Link to comment
Share on other sites

I'm pretty much a settled KDE user.  In my case it looks like for some reason no local .bashrc or .bash_profile files were created on the desktop.

 

sorry but didnt read the whole thread (not much time).

 

im assuming you are logging straight through runlevel 5 (kdm/gdm)? then your .bash_profile wont be read during bootup.

 

just want to toss that thing in as it has been covered a few boards ago. :grin:

 

ciao!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...