Software & AppsOperating SystemLinux

How To Change Default Shell When User Does Not Exist in /etc/passwd

Ubuntu 20

In this article, we will delve into a common issue faced by system administrators and developers: changing the default shell when a user does not exist in the /etc/passwd file. We will explain why this issue occurs and provide several workarounds to solve it.

Understanding the Issue

When you attempt to change your default shell using the chsh command and encounter the error message “user ‘userid’ does not exist in /etc/passwd,” it typically signifies that your system is using distributed authentication, such as Kerberos or Winbind. In this scenario, your user details may not be present in the local /etc/passwd file.

You can confirm this by running the following command:

getent passwd <userid>

If your user details are visible, it indicates that your system is using distributed authentication. The ability to run chsh in such cases may depend on the settings in the /etc/pam.d/ directory.

Workarounds

Despite the issue, there are several workarounds that you can employ to change your default shell.

Workaround 1: Using a Core Machine

If you have access to a core machine or a dedicated machine provided by your organization, you can try using the chsh command on that machine.

Workaround 2: Changing Terminal Preferences

Open your terminal preferences and select the Unnamed profile. In the “Command” menu, check the box “Run a custom command instead of my shell” and type /bin/zsh as the command. This will effectively change your default shell.

Workaround 3: Custom Command for gnome-terminal

For gnome-terminal, go to Edit → Profile preferences → Title and Command. Check “Run a custom command instead of my shell” and provide bash (or any other shell) as the custom command.

Workaround 4: Changing Login Shell in LDAP Authentication

If you are using LDAP authentication, such as Microsoft AD, you can change the login shell in the AD settings. If you have administrator access, you can do it yourself. Otherwise, ask your AD admin to enable advanced features in the Active Directory Users and Computers settings to change the login shell to /bin/bash. Additionally, you may need to run sudo /opt/pbis/bin/config LoginShellTemplate /bin/bash to update the login shell template.

Workaround 5: SSH with a Custom Shell

If you are trying to SSH into a remote host with a domain user, you can use the ssh command with the -t option to specify the shell you want to use. For example, ssh my-host -t "zsh --login".

Workaround 6: Edit Your ~/.profile File

Edit your ~/.profile file and add the line zsh (or your preferred shell) at the end. This will launch your preferred shell when you open a terminal.

Conclusion

Changing the default shell when the user does not exist in /etc/passwd can be a challenging task. However, with the workarounds provided in this article, you should be able to change your default shell effectively. Remember to choose the workaround that best suits your situation and preferences.

For more information on distributed authentication and the chsh command, you can refer to the Linux man pages.

Why does the error message “user ‘userid’ does not exist in /etc/passwd” occur when trying to change the default shell?

This error message occurs when the system is using distributed authentication, such as Kerberos or Winbind, and the user details are not present in the local /etc/passwd file.

How can I confirm if my user details are visible using distributed authentication?

You can confirm this by running the command getent passwd <userid>. If your user details are visible, it indicates that your system is using distributed authentication.

Where can I find more information on distributed authentication and the `chsh` command?

You can refer to the Linux man pages for more information. Visit Linux man pages.

Leave a Comment

Your email address will not be published. Required fields are marked *