Fix Ubuntu apt‑get Update Errors: Configure Local Repositories & Install Packages
After installing Ubuntu 20.10 in a VM, the author encountered missing command errors and apt‑get update failures, then documents step‑by‑step troubleshooting: checking the OS version, adjusting sources.list via USTC mirrors, backing up and editing the file, installing essential packages, and handling offline installations.
Background: The author installed Ubuntu 20.10 in a virtual machine to test PCAP packets. After installation, many commands were unavailable because openssh-server was not installed, and running sudo apt-get update produced errors.
Step 1 – Verify Ubuntu Version
lsb_release -aThe command confirms the exact Ubuntu release being used.
Step 2 – Configure Software Sources
Using the USTC mirror, the author downloaded a sources.list file for the groovy (20.10) release. The original file is backed up before replacement:
cp /etc/apt/sources.list /etc/apt/sources.list.bakIf vim is installed, edit the file directly; otherwise use gedit:
vim /etc/apt/sources.list sudo gedit /etc/apt/sources.listInsert the appropriate deb lines, for example:
deb http://mirrors.ustc.edu.cn/ubuntu/ groovy main restrictedStep 3 – Update and Install Packages
After saving the new source list, run: sudo apt-get update When the update succeeds, install required tools, e.g.:
sudo apt install treeAdditional – VMware Tools for Bridged Networking
If the VM is not in bridged mode, install VMware Tools to enable drag‑and‑drop and proper network access:
cd /home/jacktian/桌面/123/VMwareTools-10.3.22-15902021/vmware-tools-distrib
./vmware-install.plAccept the defaults (answer "yes") until installation completes.
Offline Repository via ISO
When the host has no internet access, mount the Ubuntu ISO and create a local repository:
mkdir /mnt/cdrom
umount /dev/sr0
mount -t iso9660 /dev/sr0 /cdrom
# or using a loop device
sudo mount -t iso9660 -o loop /home/jacktian/桌面/123/ubuntu-20.10-desktop-amd64.iso /mnt/cdromBackup the current sources.list, then add the CDROM entry:
cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo apt-cdrom addVerify the file with cat /etc/apt/sources.list, clean the cache, and update:
sudo apt clean all
sudo apt updateOffline Installation of Required Packages
If the repository is still unreachable, download the .deb packages manually. Example for net-tools and openssh-server:
sudo dpkg -i net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.debThe openssh-server installer is provided as a zip containing all dependency debs:
unzip openssh-server-installer.zip
sudo dpkg -i *.debAfter completing these steps, the Ubuntu VM can be accessed via terminal tools even without external network connectivity.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
