How sudo apt-get update works. SOLVED

Those who are familiar with any Distros based operating system must have heard about Sudo apt-get update. For a Newbie, this command can be interpreted as nothing but updating the system. But there is the completely different scenario with this command.

“You must have thought about this command downloads the new update from their source and updates the system.”  But the real thing is different with Sudo apt-get update.

Sudo apt-get update does not install a new version of the system.

Whenever this command is executed it fetches all the packages and their information from the system. This information is stored in /etc/apt/sources.list . It then just synchronises all packages from their source which then updates the information about newest versions and their dependencies.

Keep in mind that your system till now only has the older version of packages till now.

The work to actually update these packages now is done by Sudo apt-get upgrade. This command then fetches new versions of packages existing on the machine if APT (Advance Package Tool) knows about these new versions by way of apt-get update.

As per Linux apt-get documentation

Used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list(5). Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, nor are packages that are 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. [Emphasis mine] An update must be performed first so that apt-get knows that new versions of packages are available.

NOTE– You will only need to write Sudo before this command if you are not a root user. If you are there is no need of it as it is only there to give you super user permission which you actually are.

So now always remember to run apt-get update first and then run apt-get upgrade. If you do not run this command, you could be getting older versions of various packages you are installing, or if you are not lucky enough there can be dependencies issue too

Also, apt-get –help will be always there you. 

  • Add Your Comment