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
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]
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
- 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
.zshrc, or other relevant files. An incorrect configuration could be causing the authentication failure.
- 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.
- 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.
No, by default, only the root user can change the default shell for other users. Regular users can only change their own default shell.
You can use the
echo $SHELL command to display the path to your current default shell.
Some common default shells include Bash (/bin/bash), Zsh (/bin/zsh), and Dash (/bin/dash).
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
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.