0

I'm starting to learn more about Linux and Ubuntu while I'm building a home server. But when reading a tutorial I was suggested to add sudo chmod 777 -R /home/USER/docker in the terminal for the docker to get permission to read and write to that folder. But now reading about what chmod 777 does I'm having second thoughts about it. What I know is that chmod 777 gives permission for anyone (even public) to read and write.

Would it be dangerous to have it still there or is there a way to revert it? I'm worried getting hacked and people using my server for malicious action. I do have a vpn setup with my dockers (NordVPN)

Best regards, Tommy

1
  • The easy way to revert it is to restore data (inc. file system metadata) from your backups. The file-system flags impact only programs running on your machine, OR users of your machine
    – guiverc
    Jan 12 at 20:35

2 Answers 2

0

What I know is that chmod 777 gives permission for anyone (even public) to read and write.

It sets files and directories for user, owner, and others to read, write and execute. It is almost never a good idea to use 777. Generally 750 for directories and 640 for files is more than enough for a single user system. For a multi-user system 770 for dirs and 660 for files might be an option too. /tmp for instance uses 777 with the sticky bit (ie. anyone can put a file in /tmp but only the owner, or root can delete or rename it).

Would it be dangerous to have it still there or is there a way to revert it?

The only really perfect method would be to restore a backup but a generic method would be:

find  /home/USER/docker -type d -print0 | xargs -0 chmod 0755
find  /home/USER/docker -type f -print0 | xargs -0 chmod 0644

Mind that you then need to set executable files to "7" for the user option. If "644" for files stops you from using it switch to a slightly less secure chmod (744 to start and then 754 and then 774) but I doubt it is needed.

1
  • Thank you! I went with the safe route and reinstall Ubuntu. I've learned from this misstake and will stay away from 777 in the future.
    – Dextive
    Jan 12 at 22:12
0

In general, no. Your previous environment had carefully designed permission structure (allowing/disallowing access as appropriate), and SETUID, SETGID bits. By setting ALL of these to 777 (rwxrwxrwx) you have smashed this structure, losing information, and clearing all the SETUID, SETGID bits. You'll have to copy the permissions from a correct installation, or reinstall.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .