How to Make APT Install Always Ask for Confirmation?

Abstract: Prevents accidental silent package installations by forcing APT to always prompt for user confirmation.

Created: 2026-08-01 by
To force APT to always prompt for confirmation during package installations, you must configure the APT::Get::Assume-Yes option to false in your system settings. This can be achieved by creating a dedicated configuration file in the /etc/apt/apt.conf.d/ directory or by using environment variables for temporary sessions. By setting this flag explicitly, you prevent automated scripts or accidental commands from silently installing packages and their dependencies without your explicit approval, thereby adding a critical layer of safety to your package management workflow on Ubuntu and Debian systems.

Understanding APT Confirmation Behavior

By default, many Linux distributions are configured to skip confirmation prompts when running standard update or upgrade commands via cron jobs or unattended-upgrades services. While this is efficient for server maintenance, it poses a security risk on desktop environments where manual oversight is preferred. The Advanced Package Tool (APT) uses a configuration hierarchy to determine its behavior, allowing users to override default flags at various levels. When you run a command like apt install, APT checks for the -y or --yes flag. If present, it assumes yes to all questions. If absent, it typically asks for confirmation unless another configuration directive overrides this interaction. Understanding how these flags interact with system-wide configurations is essential for enforcing strict confirmation policies.

Method 1: System-Wide Configuration File

The most robust way to enforce confirmation across all user accounts and scripts is to create a persistent configuration file. This method ensures that even if a user forgets to add the -n flag, the system will still pause for input. Create a new configuration file in the /etc/apt/apt.conf.d/ directory. You can name it something descriptive, such as 99-force-confirm. Use a text editor with root privileges to write the following line into this file:
APT::Get::Assume-Yes "false";
This directive tells APT to treat the --assume-yes flag as false unless explicitly overridden by a command-line argument. If you want to ensure that no script can accidentally bypass this, you can also set APT::Get::Show-Upgraded to true to see exactly what is being changed before confirming. After saving the file, verify the configuration by running a dry-run installation. This allows you to see how APT would behave without actually making changes. Run the following command:
sudo apt install -s <package-name>
If the configuration is correct, APT should not automatically assume yes, although dry-runs sometimes suppress interactive prompts depending on the version. To test the actual interactive behavior, try installing a small package without the -y flag and observe if the prompt appears.

Method 2: Using Aliases for User Convenience

For users who prefer not to modify system-wide settings, creating shell aliases is an effective alternative. This approach requires discipline but offers flexibility. You can define aliases in your ~/.bashrc or ~/.zshrc file that automatically append the -n (no) flag to common installation commands. Add the following lines to your shell configuration file:
alias apti='apt install -n'
alias aptu='apt upgrade -n'
After editing the file, reload your shell configuration by running source ~/.bashrc. Now, whenever you type apti instead of apt install, the system will ask for confirmation. This method is particularly useful for developers who frequently switch between automation scripts and manual installations. However, note that this does not protect against direct usage of apt install without the alias. For complete protection, Method 1 is superior because it operates at the package manager level rather than the shell level.

Related Configuration Options

Beyond forcing confirmation, you might want to refine how APT handles dependencies. For instance, some users prefer to avoid installing recommended packages to keep their system minimal. If you are interested in controlling dependency resolution alongside confirmation prompts, you may find our guide on Installing Specific Packages without Recommended Ones using apt helpful. This complements the confirmation strategy by giving you granular control over what gets installed once you say yes. Additionally, if you encounter errors while managing packages, such as broken dependencies or dpkg failures, understanding how to fix them is crucial. A common issue is the error code returned by dpkg, which can halt installations. Refer to our article on Fixing E: Sub-process /usr/bin/dpkg returned an error code (1) on Kali Linux for troubleshooting steps that apply to Debian-based systems generally.

Verifying Your Settings

To ensure your changes have taken effect, you can query the current APT configuration directly. Use the apt-config command to dump specific settings. For example, to check the assume-yes setting, run:
apt-config dump | grep Assume-Yes
You should see output similar to APT::Get::Assume-Yes "false";. If you do not see this, or if it shows true, check your configuration files in /etc/apt/apt.conf.d/ for any conflicting entries. Files with higher numbers in their names often take precedence, so ensure your confirmation file has a high enough number, like 99, to override defaults.

Frequently Asked Questions

Will this affect unattended-upgrades?

Yes, if you set APT::Get::Assume-Yes to false globally, it may interfere with automated updates that rely on silent execution. Unattended-upgrades typically uses its own configuration in /etc/apt/apt.conf.d/50unattended-upgrades, but it is best to test this change carefully on non-critical systems first to ensure automated maintenance scripts do not fail.

How do I temporarily bypass the confirmation prompt?

You can always override the system configuration by appending the -y or --yes flag to your APT command. For example, sudo apt install -y <package> will proceed without asking for confirmation, regardless of the global settings. This is useful for scripting or when you are certain about the installation.

Does this work for snap or flatpak packages?

No, this configuration only affects APT, which manages .deb packages. Snap and Flatpak use different package managers (snap and flatpak) with their own separate confirmation behaviors. You would need to configure those tools independently if you wish to enforce confirmation for them as well.

What happens if I miss the confirmation prompt?

If you are in an interactive terminal and miss the prompt, the process will simply wait indefinitely until you provide input or cancel it with Ctrl+C. In headless environments or scripts, this can cause timeouts. Always ensure you are present at the terminal when running interactive APT commands after enabling this feature.

Can I reset this setting easily?

Yes, simply delete or rename the configuration file you created in /etc/apt/apt.conf.d/. For example, renaming 99-force-confirm to 99-force-confirm.bak will disable the rule immediately. Alternatively, you can edit the file and change the value back to true or remove the line entirely.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More