All Products
Search
Document Center

:"Permission denied" when accessing /tmp on a Linux instance

Last Updated:Feb 27, 2026

Problem

Running cd /tmp on a CentOS 7 instance returns the following error:

bash: cd: /tmp: Permission denied

Cause

The /tmp directory has incorrect permissions. By default, /tmp uses permission mode 1777 (sticky bit set, world-readable/writable/executable). If these permissions are changed, non-root users cannot access the directory.

Common causes:

  • A chmod command was run on /tmp without preserving the sticky bit

  • A script or configuration management tool reset the directory permissions

  • Security hardening inadvertently restricted /tmp access

Solution

Note

Alibaba Cloud reminds you that:

  • Before you perform operations that may cause risks, 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 but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.

Run the following command as the root user to restore the correct permissions:

chmod 1777 /tmp

Verify that the permissions are correct:

ls -ld /tmp

Expected output:

drwxrwxrwt  2 root root 4096 Feb 17 10:00 /tmp

The t at the end of the permission string confirms that the sticky bit is set. The inode count, file size, and timestamp in the output vary by instance.

Permission breakdown

DigitValueMeaning
1Sticky bitPrevents users from deleting files owned by others
7Owner (root)Read + write + execute
7Group (root)Read + write + execute
7OthersRead + write + execute

The sticky bit is critical for shared directories like /tmp. Without it, any user could delete or rename files owned by other users.

Applicable products

  • Elastic Compute Service (ECS)

  • Simple Application Server