Linux: Recursive ownership/permission change

Step-by-Step descriptions of how to do things.

Linux: Recursive ownership/permission change

Postby ^rooker » Wed Oct 26, 2016 3:49 am

Sometimes I have the situation where the access rights look like this:
Code: Select all
drwx------ 280 pi   pi   16384 Oct 25 11:29 Data

Now that's no problem for one folder, but "Data" has a thousands of subfolders and files... :?

Thanks to StackExchange answer by user "WombleGoneBad", here's a great 2-liner:
Code: Select all
$ find /path/to/folder -type d -exec chmod 755 {} \;
$ find /path/to/folder -type f -exec chmod 644 {} \;

The first line changes all folder to "drwxr-xr-x" (=755) and all files to "rw-r--r--" (=644).

NOTE: This removes executable rights from files.
This is usually not a problem with data-storage only folders, but definitely a no-go when applied to operating system folders and such.

Needed this 2-lines so often that I found it worth writing it down ;)

It's all in a day's work for "recursive find permission change"! :D
  • 0

Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
Site Admin
Posts: 1446
Joined: Fri Aug 29, 2003 8:39 pm
Reputation: 0

Return to HowTo's

Who is online

Users browsing this forum: No registered users and 1 guest

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: No registered users and 5 guests

Reputation System ©'