From f7bf2c1e36ad7b431b6ceb0c410e41ef6cc8076a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AD=E5=BC=80=E7=AE=B1?= Date: Sat, 18 Feb 2023 15:13:58 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][tech]:?= =?UTF-8?q?=2020230217.1=20=E2=AD=90=EF=B8=8F=20Downgrading=20a=20Package?= =?UTF-8?q?=20via=20apt-get.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ....1 ⭐️ Downgrading a Package via apt-get.md | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 sources/tech/20230217.1 ⭐️ Downgrading a Package via apt-get.md diff --git a/sources/tech/20230217.1 ⭐️ Downgrading a Package via apt-get.md b/sources/tech/20230217.1 ⭐️ Downgrading a Package via apt-get.md new file mode 100644 index 0000000000..4fdf5c61c0 --- /dev/null +++ b/sources/tech/20230217.1 ⭐️ Downgrading a Package via apt-get.md @@ -0,0 +1,123 @@ +[#]: subject: "Downgrading a Package via apt-get" +[#]: via: "https://itsfoss.com/downgrade-apt-package/" +[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Downgrading a Package via apt-get +====== + +In a situation where a recently upgraded software is causing issues? + +While you can always investigate the issue to fix it, at times, going back to the previous working version saves time and effort. + +If the new version introduced a bug, you could do nothing on your end, right? + +The good thing is that you can easily downgrade an apt package in Ubuntu and Debian. + +All you have to do is to use the apt command like this: + +``` +sudo apt install package_name=package-version-number +``` + +That seems easy enough but how would you get the exact version number? Which old versions are supported? You can get that detail with: + +``` +sudo apt-cache policy package_name +``` + +Let me explain all this with a real-life example. + +### Downgrading apt package + +Recently, I was updating the Ubuntu server that hosts It's FOSS Community forum. + +I did the usual apt update && apt upgrade and things went bonkers by the time updates were installed. + +Apparently, the latest version of Docker didn't support the aufs storage driver. To reduce the downtime, I opted to downgrade to the previous Docker version. + +Check the currently installed package version + +![Installed Docker version][1] + +Then check for the available versions that could be installed: + +``` +sudo apt-cache policy package_name +``` + +It may throw a huge list or just a small one: + +![All installable versions of an apt package][2] + +If it shows at least one older version than the current one, you are in luck. + +Now, you may think that the version number of a package would be composed of just the numbers. But that may not always be the case. + +Basically, you copy the entire stuff before 500 (the priority number). + +``` +brave-browser: + Installed: 1.48.158 + Candidate: 1.48.164 + Version table: + 1.48.164 500 + 500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages + *** 1.48.158 500 + 500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages + 100 /var/lib/dpkg/status + 1.47.186 500 + 500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages + 1.47.171 500 + 500 https://brave-browser-apt-release.s3.brave.com stable/main amd64 Packages + 1.46.153 500 +``` + +Once you have got the package number, use it to downgrade the installed package like this: + +``` +sudo apt install package_name=package-version-number +``` + +![Downgrading an installed package via apt-get command][3] + +You'll see a warning about downgrading the package, of course. + +![Downgrading apt package][4] + +But once the process completes, your package would have been downgraded to the given older version. + +### So, hold it, maybe? + +So, you just learned to downgrade apt packages. But if you don't pay attention, the package will be upgraded again with the next system update. + +Don't want that? You can [prevent a package from being updated][5]. Use the apt-mark command like this: + +``` +sudo apt-mark hold package_name +``` + +I hope this quick tip helps you with downgrading the apt packages when the need arises. Let me know if you have questions or suggestions. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/downgrade-apt-package/ + +作者:[Abhishek Prakash][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lkxed/ +[1]: https://itsfoss.com/content/images/2023/02/installed-docker-version.png +[2]: https://itsfoss.com/content/images/2023/02/available-docker-versions.png +[3]: https://itsfoss.com/content/images/2023/02/downgrading-installed-packages.png +[4]: https://itsfoss.com/content/images/2023/02/downgrading-installed-package.png +[5]: https://itsfoss.com/prevent-package-update-ubuntu/