Ubuntu – Permission denied: ‘/etc/apt/sources.list.d/google-earth.list’


I'm trying to add a ppa but get error: Permission denied: '/etc/apt/sources.list.d/google-earth.list':

~$ sudo add-apt-repository ppa:otto-kesselgulasch/gimp-edge


Press [ENTER] to continue or ctrl-c to cancel adding it

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 168, in <module>
    if not sp.add_source_from_shortcut(shortcut, options.enable_source):
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 768, in add_source_from_shortcut
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 492, in set_modified_sourceslist
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 658, in save_sourceslist
  File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 413, in save
    files[source.file] = open(source.file, "w")
PermissionError: [Errno 13] Permission denied: '/etc/apt/sources.list.d/google-earth.list'

same happens when trying to run as root instead of using sudo:

~$ sudo su -
~# add-apt-repository ppa:otto-kesselgulasch/gimp-edge

The source file of the ppa is created, but is empty:

~$ ll /etc/apt/sources.list.d/otto-kesselgulasch-ubuntu-gimp-edge-xenial.list*
-rw-r--r-- 1 root root 0 Apr  3 10:26 /etc/apt/sources.list.d/otto-kesselgulasch-ubuntu-gimp-edge-xenial.list
-rw-r--r-- 1 root root 0 Mai  3 15:03 /etc/apt/sources.list.d/otto-kesselgulasch-ubuntu-gimp-edge-xenial.list.save

Owner of that google-earth.list is root with u:rw access.

~$ ll /etc/apt/sources.list.d/google-earth.list
-rw-r--r-- 1 root root 188 Apr  3 10:27 /etc/apt/sources.list.d/google-earth.list

~$ getfacl /etc/apt/sources.list.d/google-earth.list
getfacl: Removing leading '/' from absolute path names
# file: etc/apt/sources.list.d/google-earth.list
# owner: root
# group: root

There is also enough free space:

~$ df -h /etc/apt/sources.list.d/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       902G  252G  604G  30% /

apt update / apt upgrade are working fine.

What is going on here ?
(PS: I don't need a workaround, I know that I can add the deb manually.)

Best Answer

  • Thanks to the hint from Zanna I found the issue:

    lsattr output showed that google-earth.list was set immutable.

    ~$ lsattr /etc/apt/sources.list.d/google-earth.list
    ----i--------e-- /etc/apt/sources.list.d/google-earth.list

    With this attribute set, not even root can write the file.
    To fix it, I just used chattr -i to remove the immutable attribute on the file:

    ~$ sudo chattr -i /etc/apt/sources.list.d/google-earth.list

    I made that file immutable myself, because after each Google Earth Update, [arch=amd64] gets removed from the source file (blame Google !). I originally found that "immutable fix" on webupd8.

  • Related Question