6

I recently changed the uid of my linux account (the reason for this change lies in the need to have a precise uid to access files on a mounted drive). Since then, I cannot access my crontab. After typing:

crontab -e

I get the error message:

crontabs/my_login/: fopen: Permission denied

I investigated the permissions associated to the file /usr/bin/crontab, it is:

-rwxr-xr-x 1 root my_login 35984 Feb  9  2013

However, if I look at the id of my_login, I get:

uid=11375(my_login) gid=1000(my_login) groups=1000(my_login),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),107(lpadmin),110(sambashare)

I can see something seems wrong with the gid but I am not sure what to do from this point...

Alain
  • 163
  • 1
  • 6

1 Answers1

10

Your permissions are incorrect for the crontab file. What it should be is like the following:

-rwxr-sr-x 1 root crontab 35984 Feb  9  2013 /usr/bin/crontab

To set your crontab to the above permissions, first change the ownership:

sudo chown root:crontab /usr/bin/crontab

Then set the permissions:

sudo chmod 2755 /usr/bin/crontab

That should set your crontab to the correct permissions to run.

EDIT:

Also, take a look at the /var/spool/cron/crontabs/ folder, you should see something similar to the following:

terrance@terrance-ubuntu:~$ sudo ls -al /var/spool/cron/crontabs/
total 16
drwx-wx--T 2 root     crontab 4096 Dec 17 22:08 .
drwxr-xr-x 3 root     root    4096 Dec  1 07:24 ..
-rw------- 1 root     crontab 1185 Dec 17 22:08 root
-rw------- 1 terrance crontab 1130 Dec 17 21:47 terrance

Pay attention to your username. If it doesn't have the proper ownership, change it by typing in the following:

sudo chown username:crontab /var/spool/cron/crontabs/username

And if permissions need to be set on that file:

sudo chmod 600 /var/spool/cron/crontabs/username

Hope this helps!

Terrance
  • 43,712