Linux 101: How to hold packages back from getting upgraded with apt

Jack Wallen shows you how to mark a package on an Ubuntu system such that it won’t upgrade when the apt-get upgrade command is issued.

linuxhero1.jpg

Image: Jack Wallen

You probably have a lot of software installed on your Linux servers. Of course, each of those packages depends on other packages to function properly. You might even have a situation where you’ve developed a website or application that depends on a very particular version of a package. 

For example, say you’ve built a web application that uses PHP 7.4 and you know that upgrading to PHP 8 might break the entire system—you certainly don’t want that. Although you should probably ensure your web application can run on the latest version of the software, that includes the latest bug fixes and vulnerability patches, we all know that takes some time.

SEE: Linux service control commands (TechRepublic Premium)

What do you do? If your operating system of choice uses apt, holding a package back from getting upgraded is quite simple. Let me show you how. 

How to hold a package back with apt

Holding a package back with apt can be done with a single command. Let’s say the package in question is php7.4 and you want to make sure it isn’t upgraded. For that, you would issue the command: 

sudo apt-mark hold php7.4

It really is that simple. Now, let’s say you eventually retool your web application so it’ll work with PHP 8. How do you unmark php7.4 for an upgrade? You issue the command: 

sudo apt-mark unhold php7.4

The next time you run sudo apt-get upgrade, if PHP 8 is available for your system, it’ll be upgraded. This is a really important tool to use for your development and production systems. Just make sure you don’t mark too many applications to be held, otherwise, you could wind up with an operating system filled with vulnerable software.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Also see

Source link

İlk yorum yapan olun

Bir yanıt bırakın

E-posta hesabınız yayımlanmayacak.


*