first step
Open the virtual machine ubuntu system, and then open the software update (software & updates) in the lower left corner of the menu bar, check the following options as shown in Figure (general default are checked).
The second step
sudo sh -c'echo“ deb http://packages.ros.org/ros/ubuntu $ {lsb_release -sc)main”> /etc/apt/sources.list.d/ros-latest.list'
So official order of operations is installed (see the other operations Official Guide ->): http://wiki.ros.org/melodic/Installation/Ubuntu
Reference Links: https://blog.csdn.net/ZhangRelay/article/details/80241758