9

I am using Ubuntu 14.04 and my default shell is /bin/sh. I'd like to change it to /bin/bash.

I read through a couple solutions (here's one), but nothing seems to work so far.

I have tried sudo chsh -s /bin/bash [username] and chsh followed by /bin/bash, but I am getting the following error:

chsh: user [username] does not exist in /etc/passwd

I have also tried manually editing that file. I have sudo permissions, so it's not a lack of access.

Does anyone have any suggestions? Or can anyone explain how I can add my username /etc/passwd?

I am working on a university machine connected to the department's server, but this local machine is solely for my use (i.e. I have control/permissions over everything local).

Community
  • 1
  • 1
marcman
  • 3,233
  • 4
  • 36
  • 71
  • weird - i didn't know a user could not be in /etc/passwd. – sashang Oct 22 '15 at 23:41
  • I'm voting to close this question as off-topic because it's not a programming question. Try https://askubuntu.com/ – Keith Thompson Oct 22 '15 at 23:45
  • @sashang: try looking at `/etc/nsswitch.conf` or similar files. – Jonathan Leffler Oct 22 '15 at 23:45
  • `getent passwd $USER` should print your account information whether it comes from `/etc/passwd` or some other source. Changing it is another matter. Talk to whoever set up your system. – Keith Thompson Oct 22 '15 at 23:48
  • @KeithThompson: askubuntu.com is a good option, but I disagree about this being off-topic. From the [help center](http://stackoverflow.com/help/on-topic): "...but if your question generally covers…a specific programming problem, or a software algorithm, or *software tools commonly used by programmers*; and is a practical, answerable problem that is unique to software development… then you’re in the right place to ask your question!" – marcman Oct 23 '15 at 00:23
  • @marcman: I think that's meant to refer to thinks like vim, git, Eclipse, and so forth. You're asking about tools that are commonly used by all Ubuntu users, not just programmers. – Keith Thompson Oct 23 '15 at 00:35

1 Answers1

30

It sounds like the machine is configured so that it uses something other than the password file to control access to the machine. You can probably look at the /etc/nsswitch.conf file to see how the machine is configured.

If you run grep username /etc/passwd, you presumably get no output. If so, then changing the password file isn't going to help*. You need to find the system that controls your rights on the machine and get it changed there. It's moderately likely to be an LDAP-based system that is centrally managed. You may do best talking to the administrators of that external system.

If you want to fix it locally, you may have to modify your .profile to execute the shell you want:

if [ "$SHELL" != "/bin/bash" ]
then
    export SHELL="/bin/bash"
    exec /bin/bash -l    # -l: login shell again
fi

I've done this often enough; it's more or less what exists in a .cshrc file (for csh) except the syntax can be a bit different and unconditional (if it's executing a C shell startup file, it's the wrong shell!).

See also:

No doubt there are other relevant related questions too.


* At the office here, there's an LDAP-based system, but our user names appear in the password file on the machine. However, the password file is rebuilt every hour or so, so you can't make lasting changes to the local password file. Sometimes there's a big enough window of opportunity to get something useful done, but it's fighting the system and basically counter-productive.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • One more thing can be done. run ``sudo dpkg-reconfigure dash`` then click on No. Then go to ``preferences`` option on terminal and check the option that says "run terminal as login shell". that's it. – saurabh gupta Nov 17 '19 at 19:05