Last Updated: February 25, 2016
·
885
· tobiassjosten

Poor man's chsh

I have this set of machines on which my default shell is sh, which sucks, so I always start bash the first thing I do. When it's time to disconnect I exit bash and then I have to exit sh as well. Undelightful.

Normally you could change your default shell with chsh or usermod. But if chsh won't work for whatever reason and if you don't have root access, then what?

echo 'bash && exit' >> ~/.profile

That's really all there's to it. Let's see how it works.

When you connect to the machine by SSH, then ~/.profile will be executed. With this code it will first run bash and give your that delicious shell for your session. When you exit that, it will trigger the && and consequentially run exit to kill your sh shell.

Profit!