How to recursively set owner or permissions to 'everyone' for all folders and files?

44

26

I have an external hard drive attached, and I need to set permissions to be 'free' for the user MyUser.

I think I need to set the owner to MyUser also.

How can I do this via terminal?

stighy

Posted 2012-05-29T10:56:55.020

Reputation: 1 135

Answers

86

Find out the name of your external hard drive first, then navigate to:

cd /Volumes/your-drive/

Now, to give your current user ownership to all files:

sudo chown -R $(whoami) .

Or, alternatively

sudo chown -R MyUser .

That should allow you to do most operations, no need for any further modifications.


If you want to specifically have write permissions to all files and folders if they have been removed otherwise:

sudo chmod -R u+w .

And if you're really crazy and just want to give all permissions to everyone (as indicated by your title):

sudo chmod -R 777 .

But this shouldn't be necessary in most cases. Also, do note though that volumes with FAT32 file systems don't have that permissions concept.

In general, changing permissions like this on an external drive shouldn't be the solution to all of your problems though. Rather change the permissions based on a specific problem you face, for that particular folder only.

slhck

Posted 2012-05-29T10:56:55.020

Reputation: 182 472

1I should remember the command sudo chown -R $(whoami), have to look it up every time – Luca Steeb – 2015-08-28T13:37:37.190

1Be careful of the dot after chmod. Never ever ever run sudo chmod -R 777 / you will ruin everything – CoderBC – 2018-09-07T09:20:00.747