How to fix W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No such file or directory) in APT
The /etc/apt/preferences.d directory is missing from your system, causing APT to warn it cannot read pinning preferences. Recreating this directory resolves the warning.
Quick fix
Fixes W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No such file or directory)
ls -ld /etc/apt/preferences.d- Verify the directory is missing
- Recreate the preferences.d directory
- Verify the fix and check directory permissions
- Fix permission issues if needed
ls -ld /etc/apt/preferences.dW: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No such file or directory)
What this error means
APT (Advanced Package Tool) looks for package pinning preferences in the /etc/apt/preferences.d directory. When this directory doesn't exist—either due to accidental deletion, failed system restore, or incomplete installation—APT issues a warning that it cannot read preferences. This directory should be present on all Debian-based systems running APT 0.7.22 or later. The warning itself is non-critical and won't prevent APT from functioning, but it indicates a system configuration issue that should be corrected. Missing this directory can also prevent you from using APT pinning, which is useful for managing package versions and repository priorities.
Typical symptoms
- Warning message appears when running apt update, apt install, or apt-get commands
- Message appears as 'W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No such file or directory)'
- System otherwise functions normally despite the warning
- Unable to use APT preferences to pin package versions
Common causes
- The /etc/apt/preferences.d directory was accidentally deleted or removed
- Incomplete installation or corruption of the apt package
- System restore or backup operations that failed to restore the directory structure
- Manual deletion of APT configuration directories
- Permissions issue preventing proper creation of the directory
How to fix "W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No such file or directory)"
Check if the /etc/apt/preferences.d directory exists:
ls -ld /etc/apt/preferences.dIf you see "No such file or directory", proceed to the next step. If the directory exists but shows permissions errors, skip to the advanced notes section.
Create the missing directory with the correct permissions:
sudo mkdir -p /etc/apt/preferences.dThis creates the directory with default permissions. APT will now have the location available for pinning preferences.
Confirm the directory was created and has correct permissions:
ls -ld /etc/apt/preferences.dThe output should show:
drwxr-xr-x 2 root root 4096 <date> /etc/apt/preferences.dRun apt commands again to confirm the warning is gone:
sudo apt updateThe warning should no longer appear.
If the directory exists but shows permission errors, fix them:
# Ensure root owns the directory
sudo chown root:root /etc/apt/preferences.d
# Set correct permissions (755)
sudo chmod 755 /etc/apt/preferences.dPermission errors typically manifest as "Permission denied" rather than "DirectoryExists", but correcting permissions ensures APT can read the directory properly.
Advanced notes
The /etc/apt/preferences.d directory allows administrators to split package pinning rules across multiple files instead of maintaining a single /etc/apt/preferences file. Files in this directory are processed alphabetically and should follow APT's preferences format.
The directory should be owned by root with permissions 755 (drwxr-xr-x). Individual preference files within it should have 644 permissions.
If you're experiencing widespread missing directories under /etc/apt/ (such as sources.list.d and preferences.d simultaneously), this may indicate a failed system backup restore or incomplete apt package installation. In severe cases, you may need to reinstall the apt package or restore from system media. For one-off recreations of just preferences.d, using mkdir -p is sufficient.
Frequently asked questions
- What does "W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No suc" mean?
- d directory. When this directory doesn't exist—either due to accidental deletion, failed system restore, or incomplete installation—APT issues a warning that it cannot read preferences. 22 or later.
- How do I fix "W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No suc"?
- The /etc/apt/preferences.d directory is missing from your system, causing APT to warn it cannot read pinning preferences. Recreating this directory resolves the warning.
- What causes "W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No suc"?
- The /etc/apt/preferences.d directory was accidentally deleted or removed Incomplete installation or corruption of the apt package System restore or backup operations that failed to restore the directory structure
- Is the "W: Unable to read /etc/apt/preferences.d/ - DirectoryExists (2: No suc" error serious?
- It is a low-severity error — more of a blocker than a risk. The steps above resolve it.