LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash prompt issue when logging in via SSH (https://www.linuxquestions.org/questions/linux-newbie-8/bash-prompt-issue-when-logging-in-via-ssh-4175428807/)

tar1827 09-24-2012 11:23 AM

Bash prompt issue when logging in via SSH
 
I'm wondering if someone can shed light on this for me:

When I log into my Fedora17 box using SSH as the user "tommy", I get an unexpected command line prompt from bash. When I SSH in as "johnny" I get a more conventional prompt. I looked at the files .bashrc and .bash_profile in each user's home directory to see if I could identify what is different; however, they appear to be the same. I don't see where else the prompt variable is set. Normally, I use "tommy" as the user account that I remotely access via SSH. This prompt is not helpful to me.

Below is the output I get from Putty when I log in as each user.
Code:

Using username "tommy".
tommy@my.domain.net's password:
Last login: Mon Sep 24 11:59:29 2012 from c-111-2-333-44.some.isp
-bash-4.2$

Code:

Using username "johnny".
johnny@my.domain.net's password:
Last login: Mon Sep 24 11:59:57 2012 from c-111-2-333-44.some.isp
[johnny@server ~]$


Habitual 09-24-2012 11:40 AM

post tommy's .bashrc?

mandyapenguin 09-24-2012 11:51 AM

I think tommy user's login shell is set to /bin/sh instead of /bin/bash.
Code:

grep tommy /etc/passwd
If login shell of tommy is not set as /bin/bash, then you change it to /bin/bash using chsh command
Code:

chsh tommy
Changing the login shell for tommy
Enter the new value, or press ENTER for the default
        Login Shell [/bin/sh]: /bin/bash

grep tommy /etc/passwd
tommy:x:1003:1003::/home/tommy:/bin/bash

Or simply run "bash" command after logged in as tommy user.

Habitual 09-24-2012 06:43 PM

Quote:

Originally Posted by mandyapenguin (Post 4788128)
I think tommy user's login shell is set to /bin/sh instead of /bin/bash.
Code:

grep tommy /etc/passwd

Man, I must be stuck in a time warp, or a mental ward.
Why do I assume everyone uses bash? </rhethorical_Q> :)

Thanks mandyapenguin!

mandyapenguin 09-24-2012 08:52 PM

Quote:

Habitual;4788413]Man, I must be stuck in a time warp, or a mental ward.
Why do I assume everyone uses bash? </rhethorical_Q> :)

Thanks mandyapenguin!
Hi Habitua,
I have ever seen as where there is no usernmae, hostname and pwd info (like [johnny@server ~]$) after logged in and also there is no command completion while we are using shell as /bin/sh. So I am guessing about login shell.

tar1827 09-25-2012 11:43 AM

Wow, thanks for the help! Just looking at your suggestions and looking in the home directories of each lead me to discover that tommy had no .bashrc file at all. For completeness, here are the results of the various commands:

Code:

-bash-4.2$ ls -al
total 20
drwxrwxr-x. 2 tommy users  4096 Sep 25 12:16 .
drwxr-xr-x. 6 root  root  4096 Jul  8 18:27 ..
-rw-------  1 tommy tommy  360 Sep 24 12:00 .bash_history
-rw-r--r--  1 tommy users  176 Sep 24 10:34 .bash_profile
-rw-------  1 tommy tommy  53 Sep 25 12:16 .Xauthority
-bash-4.2$ grep tommy /etc/passwd
tommy:x:1001:1001:Tommy:/home/tommy:/bin/bash
-bash-4.2$

Code:

[johnny@server ~]$ grep johnny /etc/passwd
johnny:x:1000:1000:Johnny:/home/johnny:/bin/bash
[johnny@server ~]$ cat .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
[johnny@server ~]$

So the simplest answer was the one. :) I copied the .bashrc file over, reset the ownership, and the problem was resolved!

Code:

Using username "tommy".
tommy@server's password:
Last login: Tue Sep 25 12:27:40 2012 from c-111-2-333-44.some.isp
[tommy@server ~]$

Thank you, again, for your assistance. I know it's a minor thing, but it was irritating me! :newbie:

Habitual 09-25-2012 01:11 PM

Quote:

Originally Posted by tar1827 (Post 4788988)
Code:

$ cat .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions


Tommy, I think that is supposed to be the contents of any .bash_profile
See http://www.linuxquestions.org/questi...9/#post2914160 for details.

NOTE: root will need these files (/root/.bash_profile and /root/.bashrc) created also. :)

Please let us know...

tar1827 09-25-2012 10:28 PM

Well, I guess I need to do a better job of searching...both here and on my own system. I should have noticed that the .bashrc file was missing for tommy. Root had it already, and so did johnny. I'm not sure how it got that way, but I learned some more about bash today. The link you provided would have been a good thread for me to have read before posting.

Thanks again to Habitual and mandyapenguin for your assistance.
Best regards to all...

(BTW, I didn't see an obvious way to mark this as solved; I'm not sure that matters on LQ Forum)


All times are GMT -5. The time now is 11:54 AM.