The apt update command doesn't accept any arguments. This error occurs when you accidentally pass package names, file paths, or other parameters to apt update, which is a package index refresh command.
The `apt update` (or `apt-get update`) command is used to refresh the package index from configured software repositories. Unlike `apt install` or `apt upgrade`, the update command doesn't operate on packages themselves—it only synchronizes your local package list with remote repositories. When you pass arguments to `apt update`, it rejects them because the command is designed to update the entire index without package-specific targets. This commonly happens when users confuse apt update with apt install or when copy-pasting commands that mix different apt operations.
The simplest fix is to remove any arguments from the apt update command:
# WRONG - produces the error
apt update python3
apt-get update /etc/apt/sources.list
# CORRECT - apt update takes no arguments
sudo apt update
sudo apt-get updateThe command will refresh all configured package sources and update your local package cache.
If you need to update and then install packages, use two separate commands with proper chaining:
# WRONG - mixes update with install
sudo apt update python3
# CORRECT - use && to chain commands properly
sudo apt update && sudo apt install python3
# Or run them separately
sudo apt update
sudo apt install python3The && operator ensures the second command only runs if the first succeeds. Never use other special characters like $$ instead of &&.
If you're using apt update in a shell script, ensure proper escaping and shebang:
#!/bin/bash
# Ensure shebang is present at the very top
# Properly quote arguments if any
apt update
# Chain multiple apt commands correctly
apt update && apt upgrade -y && apt install -y package-nameCommon script issues:
- Missing #!/bin/bash shebang at the start
- Incorrectly escaped quotes in command chains
- Mixing tabs and spaces (YAML files especially)
- Hidden characters from copy-paste
After running apt update correctly, verify your package sources are configured:
# List all configured sources
cat /etc/apt/sources.list
# List sources in separate files
ls /etc/apt/sources.list.d/
# Check for syntax errors in sources
apt-get checkIf you see network errors or missing sources, you may need to:
- Add Ubuntu universe/multiverse repos: sudo apt-add-repository universe
- Update your sources.list file if it's misconfigured
Understanding apt's command structure helps avoid this error. The apt command has three main categories:
1. Index operations: apt update (no arguments)
2. Package operations: apt install, apt remove, apt upgrade (take package names)
3. System operations: apt clean, apt autoclean, apt autoremove (no package arguments)
In shell scripts, always verify command chaining syntax. The && operator passes the exit status, while ;" runs commands unconditionally. For example:
- apt update && apt install pkg - only installs if update succeeds
- apt update ; apt install pkg` - installs regardless of update status
Docker users frequently encounter this when running apt commands in RUN instructions. Each RUN layer should be a complete, valid command sequence:
# BAD - update and install in one layer but wrong syntax
RUN apt update python3
# GOOD - properly chain update and install
RUN apt update && apt install -y python3E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT