All Products
Search
Document Center

:How do I fix the "su: faild to execute /bin/bash:Permission denied" error when I switch users by running the su command?

Last Updated:Aug 05, 2021

Description

The following error message appears when users are switched by running the su command on a Linux instance:

su: faild to execute /bin/bash: Permission denied

Cause

The error message appears when you run the su command because the permissions of the root directory are incorrectly configured.

Solution

Take note of the following items:

  • Before you perform high-risk operations such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • You can modify the configurations and data of instances including Elastic Compute Service (ECS) and ApsaraDB RDS instances. We recommend that you create snapshots or enable RDS log backup before you modify instance configurations or data.
  • If you have authorized or submitted sensitive information such as the logon account and password in Alibaba Cloud Management console, we recommend that you modify the information in a timely manner.
  1. Run the following command to view the hidden attributes of the file:
    lsattr /bin/bash
  2. Run the following command to check whether the permissions of the root directory are correctly configured:
    ls -l /bin/bash
  3. Run the stat / command to check whether the root directory has the read and write permissions.
  4. Run the chmod 555 / command to grant the read and execute permissions. After the permissions are granted, you can run the su command to switch users.

Applicable scope

  • ECS
  • Simple Application Server