3

I just run chmod 765 -r ./ hoping the last part(./) would enable me to run the command on the current working directory. That current working directory was my laravel project. Now I couldn't access it and when I run ls -l I see d--------- in front of it.

Does that mean I don't have any control over it? Including running another chmod 777 command because when I try to do it, I get permission denied.

5
  • 2
    d------ means directory and you removed all permission to it hence the -------. Do a chmod -R 775 /path/to/dir Aug 29 '19 at 17:11
  • 2
    Try sudo chmod. I wouldn't use -r and / in the same command a typo can destroy your system. I use chmod a+x script_name instead. Aug 29 '19 at 17:16
  • Yes, looks like I freaked out, I run sudo chmod -R 777 /path/to/dir/ like you guys suggested and all is good.
    – altsyset
    Aug 29 '19 at 17:22
  • 1
    777 is bad mojo. do 755 or 750, instead.
    – rm-vanda
    Aug 29 '19 at 18:56
  • Definitely, I have reverted back to 750 now. Thanks.
    – altsyset
    Aug 30 '19 at 6:57
5
$ chmod 0000 Foo
$ ls -l
d---------  2 myuser mygroup 4.0K Aug 29 20:33 Foo

d--------- means a directory with 0000 permissions

Here is how i 'repair' permissions on a 'in /home/$USER' directory:

# recursively Restore ownership of directory
sudo chown -R $USER:$USER /home/$USER/Path/To/Dir/

# Set perms on directories
find ~/Path/To/Dir/ -type d  -exec chmod 0750 {} \;

# Set perms on files
find ~/Path/To/Dir/ -type f  -exec chmod 0640 {} \;

# Set perms on sh script files
find ~/Path/To/Dir/ -type f -iname '*.sh' -exec chmod 0750 {} \;
2
  • 1
    it's notable that 755 & 644 will be acceptable for most people. the 0 at the end does make the security a bit more strict, but that's not necessary for most people.
    – rm-vanda
    Aug 29 '19 at 18:56
  • 1
    @rm-vanda to be honest, i edited 755 & 644 to 750 & 640 because it was too low sec for a practice. But you are right according to the default mask.
    – cmak.fr
    Aug 29 '19 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.