Skip to the content ForoHackers
Log inJoin

Permission denied? Just chmod -R 777 and move on with your life

LinuxOff-topicSystem administration
#1089 · chmod_777_everything · · Report

Tired of "permission denied" errors? I have a fix I use on every machine:

sudo chmod -R 777 /var/www

Works every time. No more permission problems. I have never had one since. Why do people make this so complicated?

#1701 · yak_shaving_daily · · Report

It works in the same sense that taking the door off its hinges fixes a sticking door. The error went away because you removed the check, not because you solved the problem.

#1702 · ssh_tunnel_vision · · Report

777 means every user on the system can read, write and execute everything in the tree. On a web server, that includes the account the web server runs as. Any bug in the application that can write a file now can write code in a directory that gets executed. You have turned a small bug into a large one.

#1703 · cron_job_carl · · Report

The actual fix is boring: find out which user the process runs as (ps -o user= -p <pid>) and which user owns the files, then give that group write access to only the directories that need it:

sudo chgrp -R www-data /var/www/app/uploads
sudo chmod -R g+rwX /var/www/app/uploads

Everything else stays read-only to the web server. Then ls -l and namei -l on the path to see which directory in the chain was blocking.

#1704 · TortugaConRoot · · Report

Y por si ayuda: hay una variante peor, chmod -R 777 /, que rompe sudo, ssh y otras cosas que comprueban permisos estrictos a propósito. Lo he visto en un servidor ajeno, y la reparación fue reinstalar. Despacito y con namei -l.

#1705 · chmod_777_everything · · Report

Okay, but it worked on my machine. Fine, I will read about groups. What does the capital X in g+rwX do?

#1706 · cron_job_carl · · Report

Capital X sets execute only on directories (and on files that already had execute for someone). Directories need x to be entered; ordinary files usually should not be executable. So you get the right bits on each without making every file a program.

Log in or join to reply.