sudo apt-get update -y && sudo apt-get upgrade -y
Then, it's best practice to run sudo apt-get dist-upgrade -y
after.
apt-get update
refreshes the package index files from sources listed on /etc/apt/sources.list
apt-get upgrade
will fetch new versions of packages that are installed on your system. This command will fail if there are conflicting packages, hence the need for apt-get dist-upgrade
. The versions it will install depend on the index apt-get update
downloaded, so running apt-get update
beforehand is important.
apt-get dist-upgrade
does the same thing as apt-get upgrade
, but handles changing dependencies. It will attempt to upgrade more important packages at the expense of less important ones. Some packages may be automatically removed.
The -y
switch tells apt-get
to answer yes on any questions it might ask.
The &&
part tells whatever is running the command to execute the second command if the first is successful. So an apt-get upgrade
won't happen if ever apt-get update
fails.
(Source)