In Linux, you use the apt update
and apt upgrade
commands to get the latest version of the packages.
The apt update
command doesn't download and upgrade any package, but it will provide information about which packages can be updated. In other words, this command can get the latest metadata (version, dependencies, etc.) of all the packages and is stored in the cache. Hence it is necessary to run this command to refresh the cache.
Here's how to utilize the apt update
command.
Note: You must run these commands as a root user or by using the
sudo
prefix. Use the terminal attached at the end of this shot to try the commands discussed in this Answer.
root@educative:/# apt updateHit:1 http://archive.ubuntu.com/ubuntu xenial InReleaseGet:2 https://deb.nodesource.com/node_8.x xenial InRelease [4619 B]Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [99.8 kB]Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [99.8 kB]Get:5 https://deb.nodesource.com/node_8.x xenial/main amd64 Packages [1008 B]Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [97.4 kB]Get:7 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [2051 kB]Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [2560 kB]Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [16.4 kB]Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [1544 kB]Get:11 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [15.9 kB]Get:12 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [984 kB]Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [26.2 kB]Get:14 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [10.9 kB]Get:15 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [12.7 kB]Get:16 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [8820 B]Fetched 7533 kB in 2s (3613 kB/s)Reading package lists... DoneBuilding dependency treeReading state information... Done123 packages can be upgraded. Run 'apt list --upgradable' to see them.root@educative:/#
To see the package list that can be upgraded, use the apt list --upgradable
command.
Once you get the latest version of metadata using the apt update
command, you run the apt upgrade
command to download and update the package to the newest version.
Here's how to use the apt upgrade
command (you will be asked to enter Y/N to proceed, Y will continue, and N will exit the command).
root@educative:/# apt upgradeReading package lists... DoneBuilding dependency treeReading state information... DoneCalculating upgrade... DoneThe following NEW packages will be installed:libzstd1The following packages will be upgraded:apt apt-transport-https base-files bash binutils bsdutils bzip2ca-certificates cpp-5 curl debconf dh-python distro-info-datadpkg dpkg-dev e2fslibs e2fsprogs file g++-5 gcc-5 gcc-5-base gitgit-man iproute2 krb5-locales libapparmor1 libapt-pkg5.0 libasan2libatomic1 libblkid1 libbsd0 libbz2-1.0 libc-bin libc-dev-binlibc6 libc6-dev libcc1-0 libcilkrts5 libcomerr2 libcurl3-gnutlslibdb5.3 libdns-export162 libdpkg-perl libexpat1 libfdisk1libgcc-5-dev libgcrypt20 libgnutls30 libgomp1 libgssapi-krb5-2libhogweed4 libisc-export160 libitm1 libk5crypto3 libkmod2libkrb5-3 libkrb5support0 libldap-2.4-2 liblsan0 libmagic1libmount1 libmpx0 libnettle6 libp11-kit0 libpam-moduleslibpam-modules-bin libpam-runtime libpam0g libperl5.22 libprocps4libpython2.7-minimal libpython2.7-stdlib libpython3.5libpython3.5-minimal libpython3.5-stdlib libquadmath0 libsasl2-2libsasl2-modules libsasl2-modules-db libseccomp2 libsmartcols1libsqlite3-0 libss2 libssl-dev libssl-doc libssl1.0.0libstdc++-5-dev libstdc++6 libsystemd0 libtsan0 libubsan0libudev1 libuuid1 libx11-6 libx11-data linux-libc-dev login mountmultiarch-support nodejs openssh-client openssl passwd patch perlperl-base perl-modules-5.22 procps python2.7 python2.7-minimalpython3.5 python3.5-minimal rsync systemd systemd-sysv tarubuntu-keyring util-linux vim vim-common vim-runtime zlib1gzlib1g-dev123 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.Need to get 105 MB of archives.After this operation, 6889 kB of additional disk space will be used.Do you want to continue? [Y/n]
Note:
apt upgrade
will update all the upgradeable packages. To update a specific package, use the commandapt install
[package-name].
Free Resources