DEV Community

Madalin Ignisca
Madalin Ignisca

Posted on • Originally published at madalin.me on

How to reset correct directories and files permissions recursive in linux

Here is what you need to do to reset the right way all files and directories in Linux. Works also on Macos and FreeBSD.

Sad eggs

Open the terminal. Change directory to the directory containing all you want to fix permissions.

We will fix also the owner, optionally.

I am setting OTHERS to 0, but if some services need read access to your directories or files, use 755, respectively 644. I am just a bit more restrictive and set correct the groups depending on how they will be used.

Fix directories:

find . -type d -exec chmod 750 {} \;

Fix the files:find . -type f -exec chmod 640 {} \;

Fix owner:

chmod -R [replace with user]:[replace with group] .

If this are my local files, usually I replace user and group with my username.

If this are in a web project, on a web server, I set user for the user running the application and group for a group the web server belongs to. I normally ensure both belong to that group. Make note you must set your application platform to do an umask of 027. PHP it is in the ini settings ;-)

ACI image

ACI.dev: The Only MCP Server Your AI Agents Need

ACI.dev’s open-source tool-use platform and Unified MCP Server turns 600+ functions into two simple MCP tools on one server—search and execute. Comes with multi-tenant auth and natural-language permission scopes. 100% open-source under Apache 2.0.

Star our GitHub!

Top comments (0)

Tiger Data image

🐯 🚀 Timescale is now TigerData: Building the Modern PostgreSQL for the Analytical and Agentic Era

We’ve quietly evolved from a time-series database into the modern PostgreSQL for today’s and tomorrow’s computing, built for performance, scale, and the agentic future.

So we’re changing our name: from Timescale to TigerData. Not to change who we are, but to reflect who we’ve become. TigerData is bold, fast, and built to power the next era of software.

Read more

👋 Kindness is contagious

If this **helped, please leave a ❤️ or a friendly comment!

Okay