How to gain permission into crontab folder in SD card rootfs

How can I access the crontab files on an sd card from an old raspberry pi?

When. i try to cd into the /var/spool/cron/crontabs/ i get permission denied, presumably because im not the original user of that folder.

Thx

Have you tried using sudo su to swtich to the root account?
Be cautious when doing so, making any changes as the root account could break your system completely. This I have learned through bitter previous experience, haha.

crontab is best used with the -e or -l switches to edit or list the contents of an accounts crontab.

For example, if I wanted to edit the crontab for the user pi I would use crontab -e command. If I wanted to edit the crontab for the root user I would use sudo crontab -e

For more info on the crontab command check out this link.

Generally it’s considered “best practice” to make root user level changes using sudo. As if, like me, you haven’t got a clue what your doing, even on the best of days. Horrible, horrible things can happen when elevated as superuser, if you are not a sandal wearing Linux guru with a very long beard.

I hope this helps.

1 Like

Thanks.

Im most definitely not a sandal wearing linux guru…lol

Now I’m not trying to edit/view the main rpi crontabs. I want to view the contents of the Sd card in the usb port of the rpi. That sd card used to belong to an old rpi0 which is what I’m interested in viewing.

Suggest using the chmod command. For example sudo chmod -R +777 /path-to-sd-card-and-desired-partition should make the entire deivces contents readable.

Double check your path name with lsblk to list block devices. I’d imagine that it would be something similar to sda with any partions numbered, say for example sda1 and sda2.

Using the +777 octal is a bit of an extreme soloution. +765 would be a more general sensible permissions setting. For more information on the chmod command click here.

Hope that helps you to solve your issue!

Thanks, but it didnt quite work out as expected;

**mars@raspberrypi**:**~ $** ls

**Bookshelf** **Desktop** **Documents** **Downloads** **Music** **Pictures** **Pimoroni** **Public** **Templates** **Videos**

**mars@raspberrypi**:**~ $** cd /

**mars@raspberrypi**:**/ $** ls

**bin** **boot** **dev** **etc** **home** **lib** **lost+found** **media** **mnt** **opt** **proc** **root** **run** **sbin** **srv** **sys** tmp **usr** **var**

**mars@raspberrypi**:**/ $** cd media/

**mars@raspberrypi**:**/media $** ls

**mars**

**mars@raspberrypi**:**/media $** cd mars/

**mars@raspberrypi**:**/media/mars $** ls

**bootfs** **rootfs**

**mars@raspberrypi**:**/media/mars $** cd rootfs

**mars@raspberrypi**:**/media/mars/rootfs $** ls

**bin** **boot** **dev** **etc** **home** **lib** **lost+found** **media** **mnt** **opt** **proc** **root** **run** **sbin** **srv** **sys** tmp **usr** **var**

**mars@raspberrypi**:**/media/mars/rootfs $** cd /var/spool/cron

**mars@raspberrypi**:**/var/spool/cron $** ls

crontabs

**mars@raspberrypi**:**/var/spool/cron $** sudo chmod -R +765 /media/mars/rootfs/var/spool/cron/crontabs/

**mars@raspberrypi**:**/var/spool/cron $** cd crontabs

-bash: cd: crontabs: Permission denied

**mars@raspberrypi**:**/var/spool/cron $**

You overused a slash ;-)

cd /media/mars/rootfs gets you into the mounted SD’s rootfs.

cd /var/spool/cron then took you off the SD card and back into your own rootfs.

Try a plain cd var/spool/cron instead (or just run it all together in one handy cd /media/mars/rootfs/var/spool/cron)

2 Likes