How to install updates via command line?
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?
9 Answers 9
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.
Just pointing out that apt full-upgrade performs the same function as apt-get dist-upgrade , if, like me, you’re comparing the commands with other answers in this question.
@hellboy It will tell you if a reboot is required. Also it’s unclear whether you’re asking if rebooting command line is required — the answer is No. It doesn’t matter how you restart the machine.
Execute all the commands by typing sudo once:
sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get full-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'
or even shorter in a for loop (thanks @dessert!):
sudo bash -c 'for i in update upgrade auto; do apt-get $i -y; done'
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
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?
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 ?
This is no longer true on 16.04. After «apt-get dist-upgrade» and a reboot I see «0 packages can be upgraded».
Once your log into your server, run the command below.
It should do the trick. Maybe you just need to restart your server.
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.
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.
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.
sudo vi /etc/apt/sources.list sudo apt-get update && sudo apt-get upgrade
My (really late, I like necromancer badges 🙂 ) solution:
sudo apt-get install wajig
You may also need to do this —
If you run apt-get update again after apt-get upgrade has been concluded, those messages at ssh login should go away.
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 $@$ && \ 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
“Packages can be updated” – How to update Ubuntu in terminal
To install the latest versions of all packages for the current release, begin by updating the package list:
apt-get update doesn’t actually install new versions of software. It downloads the package lists from the repositories and updates them to get information on the newest versions of packages and their dependencies.
To upgrade installed packages to their latest available versions, use apt-get upgrade . This will fetch new versions of packages existing on the machine.
You will be shown a list of upgrades. Press y for yes and then press Enter.
The apt-get upgrade command will normally only install updates or fixes to currently installed packages. It will not generally install new releases where major changes are required, like when a new Linux kernel is available.
Use the dist-upgrade command to perform upgrades involving the Linux kernel, changing dependencies, or adding and removing new packages as necessary.
You will be shown a list of upgrades. Press y for yes and then press Enter.
A system restart may be required after installing updates.
Detailed Explanation
apt-get update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.
apt-get upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available.
apt-get dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a “smart” conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. So, dist-upgrade command may remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.
p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.
Ubuntu Server message says packages can be updated, but apt-get does not update any [duplicate]
Any ideas why either nothing was updated, or why the count of 3 (from apt-get) is different than 42? What software says 42 if not apt? (Other details: This is the server edition, no GUI; I haven’t touched the apt configuration files; when I installed the software, I declined to allow automatic updates)
@Chopper3: Though is true that this answer is really closed to the one spotted as duplicate, I cannot see how the OP may know that the command aptitude is related to this question. Aptitude is not installed by default in latest ubuntu servers so the answer should focused in how to solve it using apt-get not aptitude (which is the tool proposed in the other post and have to be installed previously in order to solve this issue) lists.ubuntu.com/archives/maverick-changes/2010-June/… -> aptitude removed from standard
A number of people asked for it to be closed as duplicate, I have no particular opinion on the question. SF is a democracy if enough people want a question closed then it is, same for if enough people want it reopened.
2 Answers 2
In order to install packages kept back you have to run:
sudo apt-get update && sudo apt-get dist-upgrade
Trying to run just sudo apt-get update && sudo apt-get upgrade wont install packages kept back because apt-get upgrade by default does not try to install new packages (such as new kernel versions); from the man page: under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed.
However apt-get dist-upgrade allows you to install new packages when needed (ie, a new kernel version); From the man page:
dist-upgrade dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. So, dist-upgrade command may remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.