Have you ever logged onto a system, done an apt update and then been met with something like
"The repository 'blahblahblah' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details"
No? Well you’re just a lucky one aren’t you (or you don’t dabble with Linux, which like, more power to you I guess).
Anywho, this is primarily a Debian, more specifically Ubuntu, issue (I think? Idk. I use Ubuntu Server for 90% of my stuff so I’m blaming Ubuntu. Even if it’s not just Ubuntu, I’m still blaming Ubuntu). What’s basically happened is that the release you are using is now deprecated, so now the apt sources you were using are no longer live and you can’t update anything because Canonical likes causing pain. You CAN just ignore this and not worry about it, especially if whatever server this is isn’t internet facing, but there’s a simple solution that you can also just script. Two, actually. Let’s go through those:
- Probably the simplest, especially if you’re hellbent on staying on one release and don’t want to update.
First back up your sources.list file like a good Linux person:
cp /etc/apt/sources.list /etc/apt/sources.list.bak
Now just replace any mention of “archive” and “security” with “old-releases”:
sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
Now do an apt update and you should be good to go until something else breaks because that’s just how Ubuntu is.
- This is arguably the better way to go about this because you’re actively hopping to a newer (more stable? less stable?) release
Once again, back up your sources.list file because it’s good practice:
cp /etc/apt/sources.list /etc/apt/sources.list.bak
Now you’re going to just replace the distro codename in the releases file with whatever is newer. There’s multiple ways to do this, but I use the below:
sudo sed -i -e 's|{insert_current_here}|{insert_target_here}|g' /etc/apt/sources.list
Make sure to actually put the current and target in those spots or it’ll just break. So if you were on Jammy and moving to Kinetic you’d put Jammy in current and Kinetic in target, like so:
sudo sed -i -e 's|jammy|kinetic|g' /etc/apt/sources.list
“What if we don’t know what release we’re on?” Easy:
lsb_release -cs
That’ll show you if there are any LSB modules available and will also spit out the short name for your current release.
“Oh, wow, that’s easy”. Correct! Well, yes, but no. What if I told you that because Canonical likes causing pain they have basically made the above irrelevant as of the Noble release? Cause that’s kinda what they’ve done. Well, not really, they just moved the file where the releases actually are. So instead of /etc/apt/sources.list it is now /etc/apt/sources.list.d/ubuntu.sources (annoying, I know). So the above commands change to:
cp /etc/apt/sources.list.d/sources.ubuntu /etc/apt/sources.list.d/sources.ubuntu.bak
sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list.d/ubuntu.sources
sudo sed -i -e 's|jammy|kinetic|g' /etc/apt/sources.list.d/ubuntu/sources
The exact same, just a different file.
“Is there an easier way to go about this?” Uh, yeah, don’t use Ubuntu. That’s probably the easiest workaround. But otherwise, yeah probably, this is just the shenanigans I personally use in my homelab environment. Probably not the best or most efficient, but it works so I don’t really bother looking for more complex solutions.
Anywho, this was meant to be just a short-ish tip post to help anyone that has/will encounter this issue (and also for me to refer back to later because it’s inevitable).
(also I don’t know if I’ll add the whole copy button thingy back to this or not. It’s not baked into the theme I’m using, and I don’t know if it’ll break anything if I add it, but I’ll fiddle with it and possibly add it maybe in the future)