How to update Linux packages with command

How to update Linux packages with command

You might be using a Linux distribution like Ubuntu or PopOS and want to update Linux packages with the terminal. To achieve this you just need two commands.

Step 1: Run "sudo apt update" to resynchronize package index

The first command "apt-get update" is to resynchronize the package index with the source.

sudo apt update

OR

sudo apt-get update

Output

Hit:1 https://brave-browser-apt-release.s3.brave.com stable InRelease
Hit:2 http://packages.microsoft.com/repos/code stable InRelease
Hit:3 http://apt.pop-os.org/proprietary hirsute InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu hirsute InRelease
Hit:5 http://ppa.launchpad.net/daniruiz/flat-remix/ubuntu hirsute InRelease
Hit:6 http://us.archive.ubuntu.com/ubuntu hirsute-security InRelease
Hit:7 http://us.archive.ubuntu.com/ubuntu hirsute-updates InRelease
Hit:8 http://ppa.launchpad.net/obsproject/obs-studio/ubuntu hirsute InRelease
Hit:9 https://download.sublimetext.com apt/stable/ InRelease
Hit:10 http://us.archive.ubuntu.com/ubuntu hirsute-backports InRelease
Hit:11 http://ppa.launchpad.net/papirus/papirus/ubuntu hirsute InRelease
Hit:12 http://ppa.launchpad.net/system76/pop/ubuntu hirsute InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
94 packages can be upgraded. Run 'apt list --upgradable' to see them.

If you see any updates available then you can run the second command.

Step 2: Run "apt-get upgrade" to download available package updates

And the second command is "apt-get upgrade" to actually download available package updates.

sudo apt upgrade

OR

sudo apt-get upgrade

Output

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
.
.
.
The following packages will be upgraded:
 apport brave-browser code curl libcurl3-gnutls libcurl4 libdrm-amdgpu1
 libdrm-amdgpu1:i386 libdrm-common libdrm-intel1 libdrm-intel1:i386
 libdrm-nouveau2 libdrm-nouveau2:i386 libdrm-radeon1 libdrm-radeon1:i386
 libdrm2 libdrm2:i386 libegl-mesa0 libgbm1 libgl1-mesa-dev libgl1-mesa-dri
 libgl1-mesa-dri:i386 libglapi-mesa libglapi-mesa:i386 libglx-mesa0
 libglx-mesa0:i386 libnvidia-cfg1-465 libnvidia-cfg1-470 libnvidia-common-465
 .
 .
 .
94 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
8 standard security updates
Need to get 799 MB of archives.
After this operation, 775 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://brave-browser-apt-release.s3.brave.com stable/main
  amd64 brave-browser amd64 1.29.81 [91.7 MB]
Get:2 http://us.archive.ubuntu.com/ubuntu hirsute-security/main
  amd64 libcurl3-gnutls amd64 7.74.0-1ubuntu2.3 [248 kB]
Get:3 http://ppa.launchpad.net/system76/pop/ubuntu hirsute/main
  amd64 libdrm-common all 2.4.107-1pop0~1631647891~21.04~ab1d332 [15.2 kB]
Get:4 http://packages.microsoft.com/repos/code stable/main
  amd64 code amd64 1.60.1-1631294805 [75.9 MB]
.
.
.
Progress: [ 90%]
[############################################################..........] 

After running "sudo apt upgrade" you might be prompted to press Y to continue. So just press "Y" and the packages will be upgraded.

Based on the upgrade size it might take some time, so sit tight.

Optional Step: Run "sudo apt autoremove"

Once you run the upgrade command you might see a message about automatically installed packages that are no longer required. And this also helps in freeing up some space on your disk.

sudo apt autoremove

Or

​sudo apt-get autoremove

Output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  fonts-lato gir1.2-xapp-1.0 gist inxi libllvm11:i386 libruby2.7 libxapp1 
  linux-headers-5.11.0-7614 linux-headers-5.11.0-7614-generic
  linux-headers-5.11.0-7620 linux-headers-5.11.0-7620-generic
  linux-image-5.11.0-7614-generic linux-image-5.11.0-7620-generic
  linux-modules-5.11.0-7614-generic linux-modules-5.11.0-7620-generic
  linux-modules-extra-5.11.0-7614-generic
  linux-modules-extra-5.11.0-7620-generic python3-configobj python3-debconf
  python3-distro-info python3-distupgrade python3-requests-file
  python3-setproctitle python3-tldextract python3-update-manager rake ruby
  ruby-json ruby-minitest ruby-net-telnet ruby-power-assert ruby-rubygems
  ruby-test-unit ruby-xmlrpc ruby2.7 rubygems-integration tree xapps-common
0 upgraded, 0 newly installed, 38 to remove and 0 not upgraded.
After this operation, 1,105 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 508365 files and directories currently installed.)
.
.
.

 

And now you have a Linux system with fully updated packages. And make sure to run these commands regularly to make sure you don't fall behind.

 

Cover Photo by Gabriel Heinzer on Unsplash

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
3 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.