How to Fix: sudo su - with error su: failed to execute /bin/bash: Permission denied
sudo su - permission denied on Red Hat Enterprise Linux Server release 7.7
📋 Table of Contents
The error 'sudo su - with error su: failed to execute /bin/bash: Permission denied' affects users who are trying to use the sudo command followed by su, but facing permission issues. This can be frustrating for system administrators and power users who need to switch betweenuser accounts or run commands that require elevated privileges.
This issue is particularly challenging because it seems like all permissions should be set correctly with the ALL = (ALL) ALL configuration in the sudoers file.
🛑 Root Causes of the Error
- The primary reason for this error is a mismatch between the user's effective and login groups. When a user logs in, their effective group is the same as their login group, but when they run 'sudo su -', the shell changes to the root group, which may not be the same as the user's login group. This can cause permission issues when trying to execute certain commands.
- Another possible reason for this error could be a problem with the user's home directory permissions or if there is an issue with the sudoers file configuration.
🛠️ Step-by-Step Verified Fixes
Chown /bin/bash
- Step 1: To fix this, we need to change the ownership of the /bin/bash executable to the current user. We can do this by running the command 'chown $USER:$GROUPID /bin/bash'. This will set the ownership of the file to the current user's ID and group ID.
- Step 2: After changing the ownership, we need to update the permissions of the file to ensure that it is readable and executable by the current user. We can do this by running the command 'chmod u+x /bin/bash'.
- Step 3: Once these steps are completed, we should be able to run 'sudo su -' without encountering any permission issues.
Check sudoers file configuration
- Step 1: As a precautionary measure, let's check the sudoers file configuration to ensure that it is set correctly. We can do this by running the command 'visudo -f /etc/sudoers'. This will open the sudoers file in a text editor where we can verify that the ALL = (ALL) ALL configuration is correct.
- Step 2: If everything looks good in the sudoers file, we should be able to run 'sudo su -' without encountering any permission issues.
🎯 Final Words
To summarize, the error 'sudo su - with error su: failed to execute /bin/bash: Permission denied' can be resolved by changing the ownership of the /bin/bash executable or checking the sudoers file configuration. By following these steps, users should be able to run 'sudo su -' without any permission issues.
❓ Frequently Asked Questions
🛠️ Related Fixes
How to Fix: Pc crashes shortly after launching game (rainbow
Fix Pc crashes shortly after launching game (rainbow six siege). Compl
How to Fix: Installing an APK on a locked down phone
Installing an APK on a locked down phone: Try using a rooted device, e
How to Fix: New PC build- no signal and no clue
Fix New PC build- no signal and no clue. Complete troubleshooting guid