Skip to main content
replaced http://cs50.stackexchange.com/ with https://cs50.stackexchange.com/
Source Link

EDIT2: Here's a more detailed explanation, based on an answer I wrote elsewhereelsewhere:

EDIT2: Here's a more detailed explanation, based on an answer I wrote elsewhere:

EDIT2: Here's a more detailed explanation, based on an answer I wrote elsewhere:

added 28 characters in body
Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30
cd ~/workspace/pset7
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640
chmod 644 public/index.html
chmod 644 public/css/*
chmod 644 public/img/*
chmod 644 public/fonts/*
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/*
cd ~/workspace/pset7
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640
chmod 644 public/index.html
chmod 644 public/css/*
chmod 644 public/img/*
chmod 644 public/fonts/*
cd ~/workspace/pset8
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640
find . -name *.js | xargs chmod 644
chmod 644 public/css/*
chmod 644 public/fonts/*
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/*
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/*
Added a detailed explanation of the find | xargs pipeline, with examples.
Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30

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.

cd ~/workspace/pset7
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640
chmod 644 public/index.html
chmod 644 public/css/*
chmod 644 public/img/*
chmod 644 public/fonts/*

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.

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, and font files.

cd ~/workspace/pset7
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640
chmod 644 public/css/*
chmod 644 public/fonts/*

Also, I've answered many similar questions in greater detail, so feel free to poke around in my Answer history for more info.

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.

cd ~/workspace/pset7
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640
chmod 644 public/index.html
chmod 644 public/css/*
chmod 644 public/img/*
chmod 644 public/fonts/*

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.

Updated to include pset8 instructions
Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30
Loading
added 273 characters in body
Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30
Loading
added 273 characters in body
Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30
Loading
Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30
Loading