5

I attempted to download VirtualBox from terminal. Now, when I try to update, or input a command this reads out:

tyiese@penguin:~$ apt-get update
E: Malformed entry 1 in list file /etc/apt/sources.list.d/virtualbox.list (Component)
E: The list of sources could not be read.
tyiese@penguin:~$ rm /etc/apt/sources.list.d/virtualbox.list
rm: remove write-protected regular file '/etc/apt/sources.list.d/virtualbox.list'? Y
rm: cannot remove '/etc/apt/sources.list.d/virtualbox.list': Permission denied

I did attempt to remove the file - I think - but, as you can see it was not accepted.

jww
  • 97,681
  • 90
  • 411
  • 885
TNim
  • 61
  • 1
  • 1
  • 3
  • Try to use `sudo` to remove the file, if you are sure you want to remove it. – Erik A. Brandstadmoen Dec 11 '19 at 17:52
  • That actually worked! Thank you so much! – TNim Dec 11 '19 at 17:57
  • Lovely. Happy to hear it worked out! – Erik A. Brandstadmoen Dec 11 '19 at 18:35
  • Stack Overflow is a site for programming and development questions. You should probably use another site on the [Stack Exchange network](https://stackexchange.com/sites) for this question. Also see [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. https://superuser.com/questions/tagged/apt. – jww Dec 11 '19 at 21:30

2 Answers2

19

As for the file removal, the last line of the output you provided hints what the problem is. Given your question, I assume you're not too familiar with users and permissions in GNU/Linux. The $ sign means you're running your commands as ordinary user, whereas to modify most system/configuration files (such as those pertaining to apt) you need root privileges. You typically obtain those on a per-command basis by prepending a command with sudo. So in your case that would be:

sudo rm /etc/apt/sources.list.d/virtualbox.list

After that you would be prompted for your password and (assuming your user is allowed to do so) the command would be run as root.

As for your original problem - malformed entry in sources file - I cannot help you unless you post the contents of said file. It might be a missing keyword or missing newline at the end. Hard to say.

One remark for the future. When pasting multi-line transcripts or snippets of code, please place them between two sets of triple backquotes (```) on lines of their own for better formatting.

Wojciech Gac
  • 1,538
  • 1
  • 16
  • 30
  • Thanks and sorry for the formatting errors. I ran with sudo and it worked - and now I am able to update and input other commands. Thanks again for helping a clueless person! – TNim Dec 11 '19 at 18:08
1

root cause for this error is recent update made by you. Generally copy n paste resultant to new line to the file which for some reason is causing the file to go in invalid state.

use sudo to edit the file and remove the unnecessary line. This will work 99%. cheers