894

When I log into my web server via SSH I see the information:

88 packages can be updated.
80 updates are security updates

I tried apt-get update then apt-get upgrade but each time I log in I still see the message about updates. How do I install them?

muru
  • 207,228
Marlin
  • 9,094

9 Answers9

1138

Use this:

sudo apt update        # Fetches the list of available updates
sudo apt upgrade       # Installs some updates; does not remove packages
sudo apt full-upgrade  # Installs updates; may also remove some packages, if needed
sudo apt autoremove    # Removes any old packages that are no longer needed

Documentation about each apt option can be found in the the manpages for apt. These are also available by running man apt in your terminal.

Use of both upgrade and full-upgrade together is usually not needed, but it may help in some cases: see Debian documentation about Upgrades from Debian 9.

Wayne
  • 3
  • 1
SirCharlo
  • 40,096
169

To install updates, Use:

sudo -s -- <<EOF
apt-get update
apt-get upgrade -y
apt-get full-upgrade -y
apt-get autoremove -y
apt-get autoclean -y
EOF

Or even shorter in a for loop (thanks @dessert!):

sudo bash -c 'for i in update {,full-}upgrade auto{remove,clean}; do apt-get $i -y; done'
Benny
  • 5,100
100

This is normal behavior.

The message you see on login has been appended to the server status 'Message-Of-The-Day', which is only updated each calendar day (or on server boot / startup). Have a look at the contents, using

cat /etc/motd

Still seeing the same updates available, after running

sudo apt-get update && sudo apt-get upgrade

is to be expected. If you then re-run this command you will only be prompted for any further updates if even further (newer) updates have been released.

dialogik
  • 273
david6
  • 14,528
  • 5
  • 38
  • 46
13

Once your log into your server, run the command below.

sudo apt-get upgrade

It should do the trick. Maybe you just need to restart your server.

NorTicUs
  • 2,402
  • 2
  • 20
  • 34
9

In my case, I had an incorrect or not accessible URL in /etc/apt/sources.list. After removing this URL, I was able to update all packages successfully.

Commands:

sudo vi /etc/apt/sources.list
sudo apt-get update && sudo apt-get upgrade
burtsevyg
  • 302
8

My (really late, I like necromancer badges :-) ) solution:

  1. Install wajig (once):

    sudo apt-get install wajig 
    
  2. When you want to update/upgrade fully your system

    wajig dailyupgrade
    

    (it will ask for password if needed, and do all the update, upgrade, dist-upgrade, and autoremove steps for you).

Rmano
  • 32,167
4

You may also need to do this -

sudo touch /etc/motd.tail

From - Ubuntu tells me I have packages to upgrade when I don't

It worked for me on 14.04

1

If you run apt-get update again after apt-get upgrade has been concluded, those messages at ssh login should go away.

0

this script is handy to automate updates including removing unneeded packages and performing a reboot only if the OS wants one

remote_user=usernamehere
remote_host=example.com

ssh -A -n -o StrictHostKeyChecking=no ${remote_user}@${remote_host} && \
sudo apt-get update && \
sudo apt-get -f install -y && \
sudo apt-get -o Dpkg::Options::="--force-confnew" -yy dist-upgrade -y && \
sudo apt-get autoremove -y && \
[ -f /var/run/reboot-required ] && \
echo "sudo reboot now" && \
sudo reboot now 

to run on your local box just leave off that first line doing the ssh

here is an alias I save in ~/.bashrc

alias doit='echo; kill $( ps -eafww|grep update-manager|grep -v grep | grep update-manager | tr -s " " |cut -d" "  -f2 ) > /dev/null 2>&1;  echo "sudo apt-get update && sudo apt-get dist-upgrade &&  [ -f /var/run/reboot-required ] && echo && echo reboot required && echo";echo;sudo apt-get update && sudo apt-get dist-upgrade &&  [ -f /var/run/reboot-required ] && echo && echo reboot required && echo '

then on terminal I just issue doit