27

I use a samba4 domain account to log in on my laptop. I wanted to try zsh out, but since my user doesn't reside in /etc/passwd I found that chsh can't find my user. Can anyone advise how I can change my login_shell?

I couldn't see anything in my ldap.conf, nssswitch.conf or anything in /etc/pam.d that helped...

Looking on the domain controller I thought maybe I could use samba-tool, but I saw nothing in help that pointed me in the right direction...

7ochem
  • 282
  • 1
  • 4
  • 12
Rumbles
  • 1,054

5 Answers5

33

I asked about this in the #suse channel on Freenode, and Miuku suggested the same as Arul, however, he mentioned two things, if I were using a Windows domain I could set the loginShell attribute.

Sadly, I'm on a samba domain, so that didn't help. But his final suggestion was perfect, get the output of:

getent passwd USERNAME

This will have the valid entry equivalent for your user in /etc/passwd, take this, paste it in to /etc/passwd and update the shell at the end for the valid path of the shell you want to use. This way it doesn't change it for all users, and you can make sure that shell is on the machine you're configuring this on before making the change.

Rumbles
  • 1,054
10

I had exactly the same issue. Since not all machines in my domain have zsh installed, and since I did not want to affect all users, I ended up putting in my .bashrc:

if [ -x /usr/bin/zsh ]; then
  echo 'starting zsh'
  # export SHELL=/bin/zsh #edit: this is probably not what you want, see the comment.
  exec /usr/bin/zsh
fi

This might be inelegant, but at least it gets the job done.

2

If you have access to edit the samba domain controller config, you can set the following property that allows you to set the shell in smb.conf

template shell    = /bin/zsh

Not sure what happens if you login to a machine that does not have zsh installed (not all distros have zsh installed by default), but my guess is that it will invoke distro default shell.

If you simply want to try it, just type zsh to get a subshell which I am sure you know that already.

Arul Selvan
  • 1,488
0

However this answer is correct, additionally, for a concise one-line solution, you may use the following command:

sudo sh -c "getent passwd $USER | sed 's:/bin/bash:/bin/zsh:' >> /etc/passwd"
  • getent passwd $USER: Fetches the entry for the user specified in the $USER variable.
  • sed 's:/bin/bash:/bin/zsh:': This part uses sed, the stream editor, to replace /bin/bash with /bin/zsh in the output of getent. This assumes that the default shell is /bin/bash; if it's different, you'll need to adjust this part accordingly.
  • >> /etc/passwd: Appends the modified output to the end of the /etc/passwd file.
-1

This is a subjective solution which could be useful for some.

Since I use MobaXterm, my method was to just configure my session settings and tell it to use bash. Right-Click on your specific Session > Edit Session then type bash in the Execute command input box.

Since my account is also a domain account, I did not have an entry into /etc/passwd and I also did not want to modify any environment settings that could break my shell. This method is simple and non-destructive. You can then create your ~/.bashrc file and configure your shell the way you want.

bash configuration in MobaXterm

Shailen
  • 109