Software & AppsOperating SystemLinux

Fixing PAM Authentication Failure When Changing Default Shell with chsh

Ubuntu 1


When working with Unix or Linux systems, you may want to change your default shell to enhance your productivity or to use features not available in your current shell. The chsh command is typically used for this purpose. However, you may encounter a “PAM: Authentication failure” error during this process. This article will guide you through the steps to resolve this issue.

Understanding the chsh Command

The chsh command, short for ‘change shell’, is a command line utility in Unix and Linux that allows you to change your login shell. The syntax is:

chsh [options] [LOGIN]

Here, LOGIN is optional and represents the user account you want to change the shell for. If it’s not specified, the shell for the current user is changed.

Understanding the PAM Authentication Failure

PAM, or Pluggable Authentication Modules, is a flexible mechanism for authenticating users. A “PAM: Authentication failure” error means that the system is unable to authenticate the user. This could be due to a wrong password, a misconfiguration in the PAM modules, or a bug in the system.

Steps to Fix the PAM Authentication Failure

  1. Check for Aliases or Configurations Related to sudo

The first step in troubleshooting is to check for any aliases or configurations related to sudo in your .bashrc, .zshrc, or other relevant files. An incorrect configuration could be causing the authentication failure.

  1. Check for Bugs

If there are no issues with your configurations, the problem could be a bug. Even when running the commands as root, you may still encounter the password prompt and authentication failure. If this is the case, consider updating your system or reporting the bug to your distribution’s bug tracker.

  1. Manual Change in /etc/passwd File

As a workaround, you can manually change the shell in the /etc/passwd file. To do this, you need to have root access. Here’s how:

sudo vi /etc/passwd

This command opens the /etc/passwd file in the vi editor. Find the line corresponding to your user account and change the shell at the end of the line to your desired shell. For example, to change the shell to zsh, the line should look like this:


Save and close the file. The next time you log in, your default shell will be the one you specified.


Changing your default shell with the chsh command should be a straightforward process. However, if you encounter a “PAM: Authentication failure” error, it could be due to a wrong password, a misconfiguration, or a bug. By following the steps outlined in this article, you should be able to resolve the issue and successfully change your default shell.

Remember to always be careful when making changes to system files or configurations. Always make a backup before making any changes, and only make changes if you understand what they do. If you’re unsure, seek help from a knowledgeable colleague or from online communities such as Stack Overflow or Unix & Linux Stack Exchange.

Can I change the default shell for any user on the system using the chsh command?

No, by default, only the root user can change the default shell for other users. Regular users can only change their own default shell.

How can I find out what my current default shell is?

You can use the echo $SHELL command to display the path to your current default shell.

What are some common default shells in Unix and Linux systems?

Some common default shells include Bash (/bin/bash), Zsh (/bin/zsh), and Dash (/bin/dash).

Can I use a shell that is not listed in the `/etc/shells` file?

No, in order to change your default shell to a specific shell, it must be listed in the /etc/shells file. If it’s not listed, you’ll need to add it to the file before using the chsh command.

What should I do if I forget my new shell’s commands or configuration?

If you’re new to the shell you changed to and need help with commands or configuration, you can refer to the shell’s documentation or search for online resources and tutorials specific to that shell. Additionally, you can ask for help on forums or communities dedicated to that shell, such as the Zsh mailing list or the Bash subreddit.

Leave a Comment

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