2

I'm somewhat a Linux noob, so I'm sorry if this is a very basic question. I tried to look on superuser for other answers, but i'm not exactly sure what i'm looking for.

So, here's my problem. When I log in to my vpn server, it no longer opens bash automatically. Instead it just gives me the

$ 

instead of

$ user@host / location 

When I log in with my root user, it actually loads bash on login. I can load bash manually with the

/bin/bash

command, but I rather understand what happened, that changed this in the first place, and how to restore it.

  • How do you know you are not running bash? Bash could be set up up to just show $ to you. You can you 'echo $0' to check. – bdsl Feb 22 '15 at 16:28
5

Run this command:

grep $USER /etc/passwd

(Explained here. Alternatively use cat /etc/passwd | grep $USER, both are equivalent but the latter one may be easier to understand. It's less efficient, though, so it's not recommended for scripts etc. Thanks to @Mat for this suggestion.)

It will return your user account's information. Here's mine:

gronostaj:x:1000:1000:gronostaj,,,:/home/gronostaj:/bin/bash

The part after the last colon (/bin/bash) is my default shell. It seems that yours is sh. That would mean that you either have it explicitly set as your default shell (/bin/sh) or you have no default shell/invalid one, so Linux falls back to sh which is the most basic one.

To switch to bash, run this command:

chsh -s /bin/bash

It will ask for your password and change default shell to bash.

  • Hey thanks for the help. However, I must have broke something. This is my account info: "david:x:1000:100::/home/david:" And when I try to switch bash, i get this "You may not change the shell for 'david'." – David Feb 22 '15 at 11:34
  • I tried to change it with root, and that worked however. Thank you very much for pointing me to chsh. – David Feb 22 '15 at 11:38
  • 1
    Note to @Mat: I am aware that grep can read files, but I have intentionally used cat and pipe. This is a simple one-time command, so performance is not an issue. cat | grep is more explicit than grep alone, so it's often easier to understand for beginners. And I don't have to remember order of arguments for grep ;) – gronostaj Feb 22 '15 at 16:09
  • 7
    I understand what you say but completely disagree. Especially if you're show stuff to beginners - teach the right way. It's less typing and more efficient. If you start by teaching bad habits, well, they stick. (But indeed this is a minor nit. Have it your way :-) ). – Mat Feb 22 '15 at 16:43
  • @Mat if you find if truly offensive, you can always edit the answer, especially if you think it will contribute something positive to said answer. :-) – Rylee Fowler Feb 22 '15 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.