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?

  • 1
    Did you try this first: sudo apt-get clean this should clean the cache. – user2635584 Sep 20 '13 at 16:02

10 Answers 10

Try this:

sudo apt-get update        # Fetches the list of available updates
sudo apt-get upgrade       # Strictly upgrades the current packages
sudo apt-get dist-upgrade  # Installs updates (new ones)

Documentation about each apt-get option can be found in the the man-pages for apt-get. These are also available by running man apt-get on your computer.

  • 23
    Should I always restart with sudo reboot after it? – hellboy Apr 9 '15 at 5:47
  • 37
    I also have to run apt-get autoremove or I quickly run out of disk space. – Jeff Dec 10 '15 at 19:55
  • 1
    I needed to add -y for it to work. Ubuntu 17.10 – T04435 Feb 24 at 21:21

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.

  • I'm noticing that any file changes in the whole system doesn't show until the next calendar day, is there a way for like "refresh" to start seeing changes right away? – aljuaid86 Feb 11 '16 at 7:24
  • Do you mean updates for the content of Message-Of-The-Day, or not getting what you want after running sudo apt-get update && sudo apt-get upgrade ? – david6 Feb 11 '16 at 7:35
  • 3
    This is no longer true on 16.04. After "apt-get dist-upgrade" and a reboot I see "0 packages can be upgraded". – Bogdan Calmac Jun 24 '16 at 18:27
  • The '.. or on server reboot ..' statement above does cover that. – david6 Jun 24 '16 at 20:29
  • 3
    cat: /etc/motd: No such file or directory – xApple Jan 26 '17 at 19:17

Execute all the commands by typing sudo once:

sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'

or

sudo -s -- <<EOF
apt-get update
apt-get upgrade -y
apt-get dist-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 {,dist-}upgrade auto{remove,clean}; do apt-get $i -y; done'
  • 7
    This is a very thorough and complete way to upgrade one's server and in my view, the best of the available solutions in this thread. Thanks, @Benny! – unrivaledcreations Jul 24 '17 at 3:00
  • You can even make it shorter by replacing apt-get with apt and dist-upgrade with full-upgrade. – Eng.Fouad Mar 31 at 23:58

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.

  • 3
    Thank you for your answer but I did try sudo apt-get upgrade. Restarting the server is out of the question because I have sites on it. – Marlin Oct 5 '12 at 14:04
  • 3
    if you installed an update that directly affects the kernel or it's a driver update or it's a critical security update, you need to restart the server. – Evandro Silva Oct 5 '12 at 14:11
  • Maybe you should consider an error 503 for a minute. Do you know what kind of update this is ? – NorTicUs Oct 5 '12 at 15:09
  • 1
    How can you give a 503 if the server is offline? – mcont Jan 12 '15 at 13:58

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

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).

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

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

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

You can try all of these:

sudo apt-get install software-center (gets the software center)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
  • 7
    But why get the Software Center at all, if the goal is to install updates via the command line? (None of the subsequent commands you recommend require the Software Center, nor do any of them use it or benefit from it if it's installed.) Note also that it seems unlikely this will keep the "packages can be updated" message from appearing. As others have said, probably the message is just not yet reflecting the results of the update and upgrade actions. There could be packages not upgraded until the dist-upgrade action, but on a stable release it's rare to have 88 such packages at once. – Eliah Kagan Aug 18 '14 at 3:28

protected by Community Nov 9 '14 at 16:48

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.