when to use the command sudo apt-get update

whired123

Member
Joined
Nov 15, 2021
Messages
145
Reaction score
9
Credits
1,062
Software (packages) installing

Code:
sudo apt-get update
sudo apt-get -y install <PACKAGES_TO_INSTALL>

OK!!!

Software updating

Code:
sudo apt-get update
sudo apt-get -y dist-upgrade

mmmhhh...
even when you need to update the software you need to give the command sudo apt-get update ???
 


from man apt:
update (apt-get(8))

update is used to download package information from all configured sources. Other commands operate on this data to e.g. perform package upgrades or search in and display details about all packages available for installation.


upgrade (apt-get(8))

upgrade is used to install available upgrades of all packages currently installed on the system from the sources configured via sources.list(5). New packages will be installed if required to satisfy dependencies, but existing packages will never be removed. If an upgrade for a package requires the removal of an installed package the upgrade for this package isn't performed.


When a package is supplied as an argument, the package will be installed prior to the upgrade action.


full-upgrade (apt-get(8))

full-upgrade performs the function of upgrade but will remove currently installed packages if this is needed to upgrade the system as a whole.


When a package is supplied as an argument, the package will be installed prior to the upgrade action.

Hope that helps.
 
Last edited:
Software (packages) installing

Code:
sudo apt-get update
sudo apt-get -y install <PACKAGES_TO_INSTALL>

OK!!!

Software updating

Code:
sudo apt-get update
sudo apt-get -y dist-upgrade

mmmhhh...
even when you need to update the software you need to give the command sudo apt-get update ???
There's quite a bit of documentation on updating and upgrading which is in the debian wiki and the release notes for any new release. If one is upgrading from one release to the next, it's advisable to read the release notes, for example, for debian trixie they are here: https://www.debian.org/releases/trixie/release-notes/ and downloadable from here: https://www.debian.org/releases/trixie/releasenotes. The man pages provide information too, but in a more terse form than the release notes.

To briefly describe a common practice that works if there are no complications, the following "just works".

Firstly, either the root user, or a sudo user, or a doas user needs to run all the apt commands.
Secondly, apt rather than apt-get is now recommended because apt is the front-end for apt-get and is adapted for the purpose

The commands are the following, which, if using sudo or doas, need to have those commands preceding. The # is the root prompt in a root shell, which is not necessary if one is using sudo or doas:
Code:
COMMAND             COMMENT
 
# apt update ...    the output on screen will show the sources that are
                    being accessed by the system to provide the latest packages
                    for the system to download. The process refreshes the system's
                    listings of the most recent available packages.
 
# apt upgrade ...   the output on screen shows the packages that will be upgraded
                    and the user can just press enter to start the process. The
                    apt command will not remove packages. It is wise to inspect
                    the listings to see what is being upgraded, and what may not
                    be being upgraded, since the output may list what it's not
                    upgrading as well.

                    If you add the -y option, the upgrade will assume "yes" and
                    not stop and ask to provide some information or questions
                    which it may do if the -y is not present. Personally, I don't
                    use -y for this but rather prefer to see if information does
                    appear. It doesn't always appear, so it may make no
                    difference at times.
 
# apt dist-upgrade ... This command is usually used when upgrading from
                      one release to another, like from debian bookworm to
                      trixie. Once trixie is set, often this command is
                      unnecessary and so not used until the next release
                      in a couple of years. However, it can be used if the
                      user wants some more recent versions of packages
                      and they are available. This command will remove
                      packages if it sees fit, for example when it thinks it
                      needs to remove an older package for a newer one
                      and there's some conflict that needs to be resolved.
                      The ordinary upgrade command will not remove
                      packages. So, with this command, when the output
                      appears on screen, it's useful to examine it to see
                      what will be removed and then not run the command
                      if one doesn't agree with the removal.
 
Last edited:
As a Debian base user, my routeen for updating is [and note no GET it's not been needed for updates for several years]

sudo apt update && apt upgrade -y
followed by
apt autoremove

Occasionally I Might run sudo apt autoclean

if you have a broken or part installed package then upgrade will not work so start with

dpkg --configure -a
 
even when you need to update the software you need to give the command sudo apt-get update ??
apt update refreshes the list of apps and dependencies so you get the latest upgrades
 
even when you need to update the software you need to give the command sudo apt-get update ???
The point is to see what updates are there and then deciding whether to install them or not. (for what ever reason)
Single command wouldn't let you know what update are there.
 
I use :
Code:
sudo apt --update full-upgrade
It runs apt update then shows if there any updates, like just now it shows:
Code:
5 packages can be upgraded. Run 'apt list --upgradable' to see them.
Upgrading:                      
  gir1.2-nm-1.0  libnm0  network-manager  raspberrypi-net-mods  raspi-config

Summary:
  Upgrading: 5, Installing: 0, Removing: 0, Not Upgrading: 0
  Download size: 2,600 kB
  Space needed: 8,192 B / 761 GB available

Continue? [Y/n]
 


Follow Linux.org

Members online


Top