0

In my Amazon Lynux Debian. By default you get admin user and the recomendation is dont use root user instead use sudo command and you have to follow a serie of steps to get it.

Of course when try to copy files to /var/www I get a denied permission message because the owner is root

So after some research found need to change permision to 777

sudo chmod -R 777 www

drwxr-xr-x  4 root root  4096 Jun  7  2015 spool
drwxrwxrwt  2 root root  4096 Jun  7  2015 tmp
drwxrwxrwx  3 root root  4096 Sep 18 16:53 www

Even when solve my problem I know what 777 mean ... Read Write Execute for Owner Groop and Others. Im not really familiar with Lynux because more than a Windows user. But know give permission to everyone isnt the usual way to solve permisions issues.

I read another option is change the ownership of the folder to admin (have to research how) but then Im wondering why the system start with root as owner of www folder.

If help, right now Im the only user of the machine.

So what is the best practice for this scenario?

  • 4
    Giving 777 permissions is a terrible idea as it makes the entire directory and its contents world-writeable. You could have easily just used sudo to copy the files or if you needed to perform a few tasks that required root user rights, you could have just become root to do what you needed and then gone back to your normal user. Either would have been a better idea than making that entire directory world-writable. – Nasir Riley Oct 16 '18 at 2:11
0

Possible solutions:

  1. For very occasional use, use sudo cp.
  2. In the case of a web server, it may be necessary to give permanent write access to the id that runs the server (www-html for the Apache on my Ubuntu server). chown-ing to that web server is a good solution, because it is more restrictive than an chmod 777.
  3. In the general case, to give select userids write access to directories files, the usual way is to:

    • chown the directory/file to a group (the group can already exist or be created for that purpose using addgroup).

      chown owner:sharegroup {directory} 
      
    • give required access to the group

      chmod g+rw {directory}
      
    • add users to the group as necessary:

      usermod -a -G sharegroup
      

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.