Thursday, March 7, 2019

linux - how to increase user's permissions while creating files/directories under same user (and not root)?




Is there a command that allows a user to temporarily have root permissions but files and directories created by the user still reflects the user rather than root?



For example, I have a user that needs to install some software (Glassfish), but the self-extracting installer returns an error "permission denied". Is there a way to give the user higher permissions to run the installer such that when the installer creates directories and files they are owned by the user doing the installation (rather than root)?



Is this even possible?


Answer



Generally speaking: No. There are a few ways to achieve the end result you're looking for though.



Basically Your installer needs to write to a directory that your user cannot write to, your options for achieving this (at a quick glance) are:





  1. Change the group ownership of the directory, give the group write privileges, and add the user to that group.

  2. Do the install as root. Correct permissions post-install.

  3. Make the directory world-writable.

  4. Set appropriate ACLs on the directory (Google Linux filesystem ACLs for more info)



Pretty much all of this requires that you be root - and the best solution is probably to install this software as root the way the designers intended unless you have a really good reason not to (among other things, having the installed files owned by root prevents malicious code running as the user modifying the installed software later).


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...