According to this post on the CS50 Reddit, the permissions have changed since a recent update50
, and the documentation has not been updated to reflect the changes.
In my experience, you'll need a minimum of chmod 711
for directories, chmod 640
for PHP files and config.json
, and chmod 644
for HTML, CSS, JavaScript, images and font files.
Open a Terminal tab in the IDE, and execute the following commands:
cd ~/workspace/pset7
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640
chmod 644 public/css/*
chmod 644 public/img/*
chmod 644 public/fonts/*
If that does not work, execute the following commands for troubleshooting purposes:
cd ~/workspace/pset7
ls -l
ls -l public
Copy and paste the output of these commands into your original question above, then highlight the whole thing and press Ctrl-K (or click the Code Sample button in the editor, which looks like { }). Please don't paste your permissions in the comments -- edit your original question. Thanks!
EDIT: for Problem Set 8
Open a Terminal tab in the IDE, and execute the following commands:
cd ~/workspace/pset8
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640
find . -name *.js | xargs chmod 644
chmod 644 public/index.html
chmod 644 public/css/*
chmod 644 public/img/*
chmod 644 public/fonts/*
I think that should be sufficient. I'm on mobile now and can't test this out. Please let me know whether or not it works!
Also, I've answered many similar questions in greater detail, so feel free to poke around in my Answer history for more info.
EDIT2: Here's a more detailed explanation, based on an answer I wrote elsewhere:
To resolve the issue, you can spend a long time tinkering around with individual permissions on files and directories, which probably sounds like a big waste of time.
Luckily, there is a better way. You can very rapidly use the Linux find
utility to find all the files that need changing:
find ~/workspace/pset8 -type d
find ~/workspace/pset8 -name *.php
Try it yourself! That's exciting, isn't it? Note that the first command returns all the directories, and the second one returns all the PHP files. But then we need to "pipe" the output of that command to xargs
, which will execute a command using that output as its input.
In this example, we will list the permissions of all the PHP files:
cd ~/workspace/pset8
find . -name *.php | xargs ls -l
Note that this trick doesn't work the same way with directories. Think for a moment about what would happen if you executed find . -type -d | xargs ls -l
, or just try it for yourself. It doesn't show you the permissions on the directory!
Luckily, it is easy to use the find | xargs
pipeline to set the permissions:
cd ~/workspace/pset8
find . -type d | xargs chmod 755
find . -name *.php | xargs chmod 644
This version does work as expected, both with regular files and with directories.
Try that, and you will see how quick and easy it can be to resolve these permission issues in the future.
Unfortunately, once you have used chmod -R 777 *
, it's not so easy to reverse the damage. Imagine that you have a magic wand that can make anything change color to a single color of your choosing. You can use your magic wand to turn a rainbow all red! But you cannot use the same wand to make it change back to "rainbow" -- you can only make it all blue, or all yellow, or all green.