0

My MacBook Pro needed repair so I backed it up using Time Machine and erased my data before bringing it to an Apple Store.

Meanwhile, I purchased a temporary MacBook Air to keep working. I then used SuperDuper! to create a bootable backup from which I could quickly restore my data on my MacBook Pro when it came back from repair which I did (wanted to do a clean install for a while vs TM restore).

For context, I could access my Time Machine backups on the MacBook Air, but now I can’t access some folders on my MacBook Pro (they have red circles with a white dash in them).

My current username is sunknudsen with uid 502. It used to be 501 before the clean install (same username).

whoami
sunknudsen
id -u
502
ls -l /Volumes/G-DRIVE\ USB/Backups.backupdb/Sun’s\ MacBook\ Pro/2019-07-15-144502/Macintosh\ HD/Users/sunknudsen
total 16
drwxr-xr-x@  3 501  staff   102 21 Jun 15:41 Creative Cloud Files
drwx------+ 26 501  staff   884  6 Jun 08:59 Documents
drwx------+ 89 501  staff  3026 10 Jul 14:00 Library
drwx------+  8 501  staff   272 30 Apr  2017 Movies
drwx------+  8 501  staff   272  7 Feb 21:55 Music
drwx------+ 26 501  staff   884 12 Jun 15:00 Pictures
drwxr-xr-x@  4 501  staff   136  3 Jul  2015 Public
drwxr-xr-x@ 21 501  staff   714 11 Jul 10:45 Sites
drwxr-xr-x@  5 501  staff   170 21 Dec  2018 Software
drwx------+  7 501  staff   238 10 Jul 11:31 VirtualBox VMs
-rw-r--r--@ 15 501  staff  3134 24 Jan 11:06 sunknudsen.asc

So the folders in question have the wrong uid... how can I change their owner to 502?

Tried chown -R sunknudsen:wheel but getting "Operation not permitted".

Using macOS Mojave. Thanks!

  • Who is user 501 on the new machine – user151019 Jul 22 at 12:23
  • I believe user 501 does not exist on the clean install (it has been deleted). – sunknudsen Jul 22 at 12:28
0

Ok, this might break Time Machine so only follow these steps if you don’t plan on inheriting the backup on the new computer (my MacBook Pro in the above use case).

Step 1. Navigate to a folder with broken file permissions in a terminal as root (let’s call the folder Things).

sudo bash
cd /Volumes/G-DRIVE\ USB/Backups.backupdb/Sun’s\ MacBook\ Pro/2019-07-15-144502/Macintosh\ HD/Users/sunknudsen/Things

Step 2. Press enter. (If the cd command fails, you probably need to enable Full Disk Access for your terminal, I use iTerm).

Full Disk Access

Step 3. Once in the folder with broken file permissions (confirm you are in the right folder by running pwd), run the following command.

sudo find . -user 501 -exec sudo chmod -h -N {} \; -exec sudo chown -h `whoami` {} \; -exec sudo chmod -h +a "group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown" {} \;

sudo find . -user 501 will find all files owned by user with uid 501 in the current folder.

-exec sudo chmod -h -N {} \; is the secret sauce. It will remove access-control list (ACL) rules which prevent us from running a familiar chown -R `whoami` . command to change file ownership.

-exec sudo chown -h `whoami` {} \; will change the ownership of the files found by find to the user who is running the command.

-exec sudo chmod -h +a "group:everyone deny add_file,delete,add_subdirectory,delete_child,writeattr,writeextattr,chown" {} \; will restore the default Time Machine ACL rules (which is optional).

You should now have access to the Things folder!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .