1

I am new to Linux and i cannot correct this error which i am facing in Ubuntu 16.04. I feel that my question is different than the other questions involving apt-get update because the situation differs. My system information is as follows:

Linux PcAbdurraheem 4.10.0-28-generic #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Whenever I type the command:

sudo apt-get update

I get:

Reading package lists... Done
N: Ignoring file 'mono-xamarin.listsudo' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

Can anyone please help me. I was trying to run the following command after which the error occurred to do programming in Visual Basic when this error occured:

echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.listsudo 
  • You have a sudo which fails with a "permission denied". That is rather worrying. Could it be that /var is on a read-only filesystem? What does "mount" show? – Gerard H. Pille Feb 17 '18 at 10:56
  • @GerardH.Pille he mentioned being new to linux, so I find that rather unlikely. He clearly named the source.list file wrong and I assume one of his attempts messed up the procedure. – rwenz3l Feb 17 '18 at 10:58
  • @rwenz3l You may very well be right, but it could be you are wrong (in this case). I don't remember ever having had an apt session stuck, but I've only been using Linux for 20 years. – Gerard H. Pille Feb 17 '18 at 11:03
5

N: Ignoring file 'mono-xamarin.listsudo' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension

clearly indicates that the filename is wrong:

# Goto directory:
cd /etc/apt/sources.list.d/
# fix the name:
mv mono-xamarin.listsudo mono-xamarin.list

[..] Operation not permitted

and

E: Unable to lock directory /var/lib/apt/lists/

as well as

[..] 13: Permission denied

indicates that you are not root OR the apt-get process is already running, but failed and left an unclean state behind.

check for running apt-get processes:

ps -A | grep apt

you should see something like this:

8737 pts/7    00:00:00 apt-get

where 8737 is the process that is stuck if you see multiple processess, kill each of them with:

sudo kill <process>

check back if the process is still there. If you can not terminate the process this way, use:

sudo kill -9 <process>

after that you have to cleanup the apt-get lockfiles:

sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock

finally to the desired update:

sudo apt-get update

Sources: tecmint

| improve this answer | |
0

It could be that you have some broken things there. Try this: wget -q -O - NAME_OF_MISSING_WHATEVER sc | apt-key add - to add it. Also what's the latest action(s) that you/someone else did there before this happened? Is this the first time ever on that OS that you did apt-get update (did it ever work before)? If you just installed your distro of Linux it could be that you need to re-download the *.ISO file, then check for MD5 value to verify that it matches and if you burn it to CD/DVD make sure you use CD/DVD burning software with ability to verify that ISO was written properly (i added this since you you're new to Linux).

| improve this answer | |
  • Yes @Frido-X this apt-get update has worked before but, as I stated in my original question that after entering the command: – A.Farooqui Feb 17 '18 at 15:09
  • Well then something or somebody wrecked your OS. I'm sure that looking at *.log files can't hurt -- look at log files (including old files) from the time when you know all worked fine to the latest logs from today. That might give you a clue what went wrong, @A.Farooqui. – Fido-X Feb 17 '18 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.