How to change default shell when login



Is there way to change default shell when I login VyOS? Now the default shell is /bin/vbash, but I want to use /bin/sh. I used ‘chsh’ to change, but it doesn’t work, after rebooting, the default shell will be changed back to /bin/vbash. Any idea to archive that?

best regards.


Yes, it’s reset on purpose, otherwise you may break your cli functionality in many places. However you can enforce that via setting the immutable flag for /etc/passwd, that way it /etc/passwd can’t be rewritten but you also can’t create any user etc. So, use that on your own risk.


thanks for reply, after making immutable for /etc/passwd, the default shell in /etc/passwd will not change after rebooting, but it means nothing since the default shell still be vbash after login, is there settings in VyOS to overwrite shell settings anyway?


Is there any particular reason you need the default shell to be /bin/sh ? Outside of vbash you will lose most of the VyOS CLI functionality. If you need it for script running you can always change the shell at the start of the session as shown below.

vyos@vyos:~$ whoami
vyos@vyos:~$ echo $0
vyos@vyos:~$ /bin/sh
sh-4.3$ echo $0
sh-4.3$ whoami


works for me in the latest rolling:

vyos@vyos:~$ cat /etc/passwd| grep vyos && echo $0

@joshua the environment variables will stay with bash as well, however there is some additional functionality in vbash, bash would have. ( just an example, I would have to dive into it to find more relevant code lines). In general, yes, the method you have propose is the recommended one, thanks for pointing that out.