2

OK - so I open terminal and I want to use chown to change permissions / ownership recursively. I want to use

sudo chown -R username:group directory

The folder I want to change permissions on is opt/lampp what would be the correct replacement for 'directory' to change permissions on opt/lampp - if the following was my command to recursively replace ownership on the parent directory all subfolders and all files for the lampp directory and I am a sudo user, the command would be

sudo chown -R myname:sudo what goes here ?

please tell me what I would enter in terminal instead of 'what goes here'

Thanks

  • I would suggest you first cd to /opt and then run sudo chown -R username:group ./lammp If you miss the space between / and opt when running chown, thatll be bad, so it's better to cd first – Sergiy Kolodyazhnyy Jul 10 '17 at 4:43
  • @Sergiy Kolodyazhnyy Perfect !!! Please post as answer and I can accept - cheers mate ! – kerry Jul 10 '17 at 4:54
  • OK. Turned my common into a full answer – Sergiy Kolodyazhnyy Jul 10 '17 at 5:00
  • Please explain why you want this? Software in /opt/ is installed by unpacking a tar file. Tar has this inherent feature of maintaining permissions so there should be no reason for you to mess with the permissions. The software in /opt/ should be as is (set to "root:root"). You use a "service" to create access to the software. ALL user related content for a LAMP server should be outside of /opt/ (probably /var/www/). – Rinzwind Jul 10 '17 at 7:21
  • @Rinzwind - thanks for taking the interest to explore my reasons. Sergiy answered my question correctly which helped to educate me. – kerry Jul 10 '17 at 8:50
6

I would suggest you first cd /opt and then run sudo chown -R username:group ./lammp .

The reason for that is simple: if you by accident add space between / and opt when running sudo chown -R username:group /opt/lammp , that'll be bad. In fact this is a common error we see on Ask Ubuntu a lot - new users do this mistake by accident and as a result their system becomes extremely difficult to recover. Thus , cd first, chown second

  • I disagree. The whole idea for software in /opt/ is for it to be owned by ROOT and where you use a service to start and stop this software (and that service is owned by root too). – Rinzwind Jul 10 '17 at 7:19
  • @Rinzwind not necessarily owned by root. Consider a particular application which may be have to be owned a non-login user. Webservers like Apache use www user, if my memory is correct. While for the most part items in /opt should be owned by root, it's not always needed. Besides, I'm merely giving the user what they asked for. The question isn't about what should and shouldn't be done – Sergiy Kolodyazhnyy Jul 10 '17 at 7:36
  • The only file when you install apache in /opt/ that needs to be owned by the user would be the "my.cnf" file and when installing in /opt/ that file should be created in /home/$USER. Installing in /opt/ is done through a tar file and the maintainer already set all the permissions as they should be. Any change to that is setting security lower than needed (especially when dealing with a website hosted on your machine). – Rinzwind Jul 10 '17 at 7:41
  • OK, I can agree with that – Sergiy Kolodyazhnyy Jul 10 '17 at 8:47
  • Thank you all - I understand what you are saying - my initial problem is different cause to what I expected but Rinzwind did answer my actual question which helped educate me - so I will accept his answer but appreciate people thinking outside the box and asking why and giving me ideas and reasons to think differently - thanks guys - all of you – kerry Jul 10 '17 at 8:59

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.