I just created an Ubuntu 21.04 USB thumb drive and booted it in Live/Try mode.
I opened a terminal and ran sudo apt update
and sudo apt-get install apt-file
:
ubuntu@ubuntu:~$ sudo apt update
Ign:1 cdrom://Ubuntu 21.04 _Hirsute Hippo_ - Release amd64 (20210420) hirsute InRelease
Hit:2 cdrom://Ubuntu 21.04 _Hirsute Hippo_ - Release amd64 (20210420) hirsute Release
Hit:4 http://archive.ubuntu.com/ubuntu hirsute InRelease
Get:5 http://archive.ubuntu.com/ubuntu hirsute-updates InRelease [109 kB]
Get:6 http://security.ubuntu.com/ubuntu hirsute-security InRelease [101 kB]
Fetched 209 kB in 1s (286 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
280 packages can be upgraded. Run 'apt list --upgradable' to see them.
ubuntu@ubuntu:~$ sudo apt-get install apt-file
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package apt-file is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'apt-file' has no installation candidate
But as you can see it fails.
So I check the apt-cache
and it should indeed be available:
ubuntu@ubuntu:~$ apt-cache dump | grep apt-file
Package: apt-file
Depends: apt-file (null)
Then I checked if it was already installed:
ubuntu@ubuntu:~$ which apt-file
ubuntu@ubuntu:~$
But nope...
Then I checked the online database: https://packages.ubuntu.com/hirsute/apt-file
And again it should be there.
Then I tried, just for fun, to install a different package. sudo apt-get install ncdu
, but I got the same error... Then I tried to install sudo apt-get install vim
and that worked! But I still can't install the other packages.
What is going on here?
The link you provided
https://packages.ubuntu.com/hirsute/apt-file
should have tipped you off, it clearly tells you it's a community package in bold (ie. found in 'universe') which whilst enabled by default in flavors (ie. distributions from the community), it requires a specific enable for Ubuntu.
If your release is a LTS release, packages provided on the Ubuntu ISO have support for 5 years, where as packages found in 'universe' do not have the 5 year support (eg. for 18.04 many flavor packages were LTS which means 3 years of support, whilst others were not LTS meaning they only had 9 months of support; eg. Lubuntu Next [LXQt] or Ubuntu Studio 18.04 were not LTS products). By not having 'universe' enabled by default, you know all packages are supported the entire life of your product's install.
Once 'universe' is enabled, you'll be able to install community supported packages found in 'universe'
For more details, please see https://help.ubuntu.com/community/Repositories/Ubuntu