|Requirements||Ubuntu or Debian Linux and friends|
What does sudo apt-get update command do?
- The sudo apt-get update command is used to download package information from all configured sources.
- The sources often defined in /etc/apt/sources.list file and other files located in /etc/apt/sources.list.d/ directory.
- So when you run update command, it downloads the package information from the Internet. It is useful to get info on an updated version of packages or their dependencies.
How to see /etc/apt/sources.list file
Type the cat command:
$ cat /etc/apt/sources.list
Run sudo apt-get update command to update package index
What does sudo apt-get upgrade command do?
- Now you know sudo apt-get update command gets you an updated list of packages from the Internet.
- But, how do you install outdated packages? How do you apply security patches for packages and keep your system secure? How do you find new packages to install?
- You run sudo apt-get upgrade to install available upgrades of all packages currently installed on the system from the sources configured via sources.list file.
- New packages will be installed if required to satisfy dependencies, but existing packages will never be removed.
The differences between update and upgrade command
From the apt-get update man page:
update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.
From the apt-get upgrade man page:
upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
In short executing “sudo apt-get update” fetches you a list of packages for all of your repositories and PPA’s and make sure it is up to date. While “sudo apt-get upgrade” does an actual software upgrade. Hence, it recommended option is always to run update command before upgrade command to update installed packages for an Ubuntu or Debian system:
$ sudo apt-get update && sudo apt-get upgrade
One can run multiple commands in sudo as follows:
$ sudo sh -c 'apt update && apt upgrade'
- Ubuntu 18.04 update installed packages for security
- How Do I Update Ubuntu Linux Softwares Using Command Line?
- Ubuntu Linux: Upgrade Linux Kernel
- Ubuntu Enable & Setup Automatic Unattended Security Updates
- Linux: Update All Packages Command
- How do I update Ubuntu using terminal command line
- Debian upgrade or update a single package using apt-get
- Ubuntu upgrade or update a single package using apt-get
- How do I see what packages are installed on Ubuntu Linux?
- What does sudo apt-get update command do on Ubuntu/Debian?
- Ubuntu Linux – How Do I install .deb Packages?
- apt-get hold back packages on Ubuntu / Debian Linux
- Ubuntu 20.04 LTS update installed packages for security
🐧 13 comments so far... add one ↓
|Category||List of Unix and Linux commands|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|