VM default shell sh vs. bash in Ubuntu 22.04 and 24.04 VMs

Andrew Janke 65 Reputation points
2025-05-01T00:02:09.5+00:00

Does anyone know if and why the default shell changed from bash to sh between the Ubuntu 22.04 and 24.04 VM images? And what the right way is to configure it to be bash for new human users, including those created by AadSshLoginForLinux?

In our older Linux VMs created using the Ubuntu 22.04 and Ubuntu 20.04 VM images from Canonical in the marketplace images for "Ubuntu Server 20.04 LTS" and "Ubuntu Server 22.04 LTS", the default shell that new users got was bash. In new VMs created with the "Ubuntu 24.04 LTS - all plans including Ubuntu Pro" images, they're getting plain /bin/sh, which makes for a lousy interactive shell and isn't compatible with most of our users' shell startup scripts, which use bashisms.

In the new 24.04 VMs, /etc/default/useradd has it set to /bin/sh, saying this:

# The SHELL variable specifies the default login shell on your
# system.
# Similar to DSHELL in adduser. However, we use "sh" here because
# useradd is a low level utility and should be as general
# as possible
SHELL=/bin/sh

In the old 22.04 VMs, it has /bin/bash. Though it still has the comment about using "sh".

# Similar to DSHELL in adduser. However, we use "sh" here because
# useradd is a low level utility and should be as general
# as possible
SHELL=/bin/bash

I don't recall ever changing that myself, and have built several VMs from these images. And non-Azure Ubuntu VMs that I build from the vanilla Ubuntu distro downloads have /bin/sh there. So I assume this is a customization in the Azure marketplace VM images?

Does anyone know why this customization went away in the Ubuntu 24.04 VM images and it's /bin/sh now?

This is a minor bummer because we use Entra ID login (AADSSHLoginForLinux) on these VMs, and chsh doesn't work with Entra ID backed users, as described in this Stack Overflow question.[1] And some users don't know about chsh anyway. So an admin has to change it for them, by editing /etc/aadpasswd.

I've been changing our /etc/default/aaduseradd to set the default shell to bash there. Seems to work. Is that the right place to do it? (Assuming the /etc/defult/useradd customization went away for a reason, and wasn't just forgotten when building the 24.04 VM images.)

# The SHELL variable.
SHELL=/bin/bash

Relatedly, does anyone know how to get chsh or similar to work with Entra ID login? Or if it is expected to work with Entra ID login?

UPDATE 5/6/25 13:30 EDT: Edited to say "Entra ID login" instead of "Entra AD login". I mixed it up with the old "Azure AD" name. We use Entra ID logins, with the AADSSHLoginForLinux extension.

[1] https://serverfault.com/questions/1114802/setting-default-shell-on-azure-linux-vm-using-aad-login

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,760 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alex Burlachenko 4,875 Reputation points
    2025-05-05T15:49:58.0233333+00:00

    Hi Andrew,

    Thanks for posting your question on the Q&A portal!

    The switch from bash to sh in Ubuntu 24.04 VM images aligns with the upstream Ubuntu default, which prefers /bin/sh for broader compatibility. The Azure marketplace images for 22.04 and earlier likely had a custom override.

    To ensure new users (including AAD-backed ones) get bash, your approach of modifying /etc/default/aaduseradd is correct. Alternatively, you can:

    • Set SHELL=/bin/bash in /etc/default/useradd (though this may be overwritten on updates).

    Use usermod -s /bin/bash <username> for existing users (note the chsh limitation with Entra ID).

    For Entra ID (AAD) users, editing /etc/aadpasswd remains the most reliable method since chsh doesn’t work with AAD-backed accounts.

    AAD SSH Login Documentation and useradd man page

    Let me know if you need further clarification!

    Best regards,
    Alex
    P.S. If my answer help to you, please Accept my answer
    PPS That is my Answer and not a Comment
    
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.