I wanted to resolve the same issue after installing Ubuntu 18.04 desktop version from a live USB drive, but the other answer didn't quite work because my USB drive was automatically mounted after boot, and the apt command was expecting the USB drive to be at /media/cdrom.
After booting the newly installed Ubuntu, the USB drive was automatically mounted at /media/username/UBUNTU 18_0, where username will be your user name.
To use that as a source in apt I did the following:
sudo apt-cdrom --no-auto-detect --cdrom=/media/username/UBUNTU\ 18_0 -m add
sudo rmdir -f /media/cdrom
sudo ln -snf /media/username/UBUNTU\ 18_0 /media/cdrom
sudo apt-get update
sudo apt-get install package_name
The ln was necessary because apt was expecting the source to be in /media/cdrom in my case.
The apt-cdrom options are different from other answers. -m prevents it from being unmounted.
You can still do the backup and restore of the sources.list as written in the other answers.