Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change my default shell in Ubuntu when not in /etc/passwd? [closed]

Tags:

linux

shell

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).

like image 604
marcman Avatar asked Oct 22 '15 23:10

marcman


1 Answers

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:

  • How to switch to Bash shell from some other shell?
  • What's the difference between .bashrc, .bash_profile and .environment?

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.

like image 55
Jonathan Leffler Avatar answered Oct 25 '22 10:10

Jonathan Leffler