crontab listing or editing results in fopen: permission denied

Solution 1:

The permissions on /usr/bin/crontab should be:

 owner=root
 group=root
 perms= 4755  (rws rx rx)

Your /usr/bin/crontab has the wrong group owner. Additionally, it has sgid and NOT suid which it must have.

Solution 2:

You can edit your user crontab if you have superuser access, without modifying permissions:

$ sudo crontab -u username -e

I thought you could edit your user crontab without sudo, but I get the same permission issues as you, even after adding myself to the crontab group. The permissions in my user's crontab (/var/spool/cron/crontabs) are -rw-------, group is crontab.

Solution 3:

I encountered the same error. The issue was on directory /var/spool/cron/crontabs

$ sudo stat /var/spool/cron/crontabs
  Fichier : '/var/spool/cron/crontabs'
   Taille : 34          Blocs : 0          Blocs d'E/S : 4096   répertoire
Périphérique : 802h/2050d   Inœud : 272986341   Liens : 2
Accès : (1730/drwx-wx--T)  UID : (    0/    root)   GID : (  107/ crontab)
Accès : 2020-07-10 14:01:01.246597775 +0200
Modif. : 2020-07-10 14:01:00.806605868 +0200
Changt : 2020-07-10 14:01:00.806605868 +0200
  Créé : -

If you have different permission / owner / group, you can fix it like this :

sudo chmod 1730 /var/spool/cron/crontabs
sudo chown root:crontab /var/spool/cron/crontabs