3

I get error when trying to set time:

$ sudo timedatectl set-timezone America/New_York   
Failed to set time zone: Access denied   

This is on an almost pristine stretch lite image. I noticed

$ ls -lad /etc  
drwxr-xr-x 92 pi pi 4096 Mar 12 12:16 /etc  

Shouldn't /etc be owned by root?
Is there something that changed ownership to pi?

I tried

sudo chown root /etc   

and that seemed to fix this issue, but did I break something else?
Is this a bug with the original OS image?

3
  • Whatever you've done your system is broken. /etc and most of the "system" files should be root:root for owner and group. There's nothing sensible you can do apart from creating a fresh SDCard with Raspbian then moving your data & programs from the broken card.
    – Dougie
    Mar 12 '19 at 20:55
  • 1
    in my /etc - all files are owned by root ... all but 7 have group ownership of root (2 of which you're unlikely to have) ... so, chown root probably fixed most of the issue, but there's still the group that needs to be fixed Mar 12 '19 at 21:09
  • Thanks. I had a specific list of things I installed carefully, but somewhere /etc got changed. Mar 13 '19 at 2:00
2

Minutes after starting the new image, I used

cd /  
sudo tar -xf /home/pi/files.tar.gz   

to put a few files at needed places. I should have used

sudo tar --no-same-owner -xf /home/pi/files.tar.gz   

since tar changed ownership of directories it did not create.

--same-owner is a tar default when run as superuser, and the tar was created from pi-owned directories.

0

Your Raspbian Stretch Lite installation cannot be pristine. I have just used a virgin installation of Raspbian Stretch Lite 2018-11-13. It shows that /etc belongs to user root and group root.

There is another weird thing with your installation. Using sudo to execute commands run them with superuser root and has no restrictions, particular running commands belonging to other users. I cannot see why root should fail to execute timedatectl only why /etc has user:group pi:pi.

I suggest to download Raspbian Stretch Lite 2018-11-13, compare the checksum and either using etcher to flash the image or use

unzip -p 2018-11-13-raspbian-stretch.zip | sudo dd of=/dev/sdX bs=4M conv=fsync

on a Linux machine to flash the image to the SD Card.

2
  • Thanks. I will start with a new image. I only installed a few things, but something must have affected /etc. Mar 13 '19 at 2:00
  • @Codemeister If the answer help you a bit it would be nice if you could accept it. This will finish the question and show other users that it has a solution.
    – Ingo
    Mar 13 '19 at 9:04

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.