How to resolve the "bash: cd: /tmp: Permission denied" error on a Linux instance

更新时间:
复制 MD 格式

This topic explains how to resolve the "bash: cd: /tmp: Permission denied" error when you access the /tmp directory on a Linux ECS instance.

Symptom

Accessing the /tmp directory on a Linux ECS instance returns the following error:

bash: cd: /tmp: Permission denied

Cause

This error occurs because the /tmp directory on the ECS instance has incorrect permissions.

Solution

  1. Connect to the ECS instance as the root user.

    For more information, see Connection methods.

  2. Run the following command to check the permissions of the /tmp directory:

    Note

    By default, the /tmp directory has drwxrwxrwt permissions.

    ls -l /

    The output shows that the /tmp directory permissions are dr--r--r--, which must be modified.

    tmp权限

  3. Run the following command to set the correct permissions for the /tmp directory:

    chmod 1777 /tmp
  4. Verify that you can now access the /tmp directory.