Delete files from root owned folders without sudo

There is an application that creates logs owned by root user (this cannot be changed, at least in my work environment) in the directory logs:enter image description here

This app is executed through a docker-compose and Makefile, and it will be stopped and resumed several times. So I want to execute the app, it will generate logs, stop the app and delete the logs and after a certain amount of time, execute the app again, which will generate new logs.

Deleting the logs (all the subfolders and files that are within the logs folder) has to be done with the command rm -rf logs, without sudo involved, because it is made by a Makefile that is also executed in Mac computers. In Mac, if you have a sudo command, it will ask for a password, and I don't want that.

I have added write permissions to the folder with sudo chmod a+rwx and sudo chmod 777 (have tried both because didn't make it work), which according to a few questions might be enough.

I have also added the ubuntu user to the root group as stated in for example , with:

adduser ubuntu root

And

usermod -aG root sysadmin

Following this, , I have restarted the server after that.

But still, I am unable to remove the files. How could I do this?

6

1 Answer

Use sudo chown -R user: directory_name

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like