0

In our org, we allow only "sudo apt-get" for a normal user. Now the problem is with those files created after this installation are with root:root permission, where this user cannot modify.

Appreciate if you share how you solved this problem using visudo. Let me know if you have any question.

Thanks

Shameer

1
  • First, this is apt-get install, which I dont know which all files are created. Second, this user only has sudo permission to run apt-get not for chown. Anyway to do using sudo settings.
    – santony
    May 7, 2020 at 9:46

1 Answer 1

0

You can use chown to change ownership of files and folders. The syntax is:

sudo chown <user>:<group> /path/to/files

So for example, if you wanted to make the user "john", the owner of ~/myfile.txt you would run:

sudo chown john:john ~/myfile.txt

The same goes for folders, however if you need all folders and subfolders changed at once, you would use the -R flag, like so:

sudo chown -R john:john /path/to/my/directory

(You can use pwd to find out the current directory)

This will work for any file and folder on the system, however you should not do this on system files or it can damage the entire OS (many programs depend on ownership and permissions being set correctly). However if there are files and folders that are incorrectly owned by root, you can use the above commands to change ownership of them.

5
  • First, this is apt-get install, which i dont know which all files are created. Second, this user only has sudo permission to run apt-get not for chown.
    – santony
    May 7, 2020 at 9:45
  • @santony The system administrator is the one that needs to run the chown commands. Also, you can use apt download followed by dpkg -x to extract the package locally and then you'll be able to see where all the files are installed to. So apt download the package, then run dpkg -x <packagename>.deb extracted, and look in extracted folder. You will see all the folders and files that the package would install. (may need to mkdir extracted before you can extract to it first).
    – Daniel M.
    May 7, 2020 at 10:02
  • Thank you Daniel, wont solve the problem completely.
    – santony
    May 8, 2020 at 4:45
  • I am wondering if there is an option to run sudo APT install as another user(not root) and then be this user and runas in a common group, so 660 would help this user to edit the file. Would somebody help in those aspects how to do in visudo, i am not a super expert here.
    – santony
    May 8, 2020 at 4:47
  • You can run a command as a different user using su <username> -c "<command>". You will be prompted to enter that user's password. However I'm not sure if apt will allow that user to install packages. But to allow them to edit the files, chmod them to 664, then add another group that will be allowed to edit the files (for example: tmpgrp) with sudo groupadd tmpgrp, then add the target user to that group with sudo adduser <username> tmpgrp, and then run chgrp on the files to change group access: sudo chgrp tmpgrp /path/to/file. Then the user in tmpgrp will have write access
    – Daniel M.
    May 8, 2020 at 11:49

You must log in to answer this question.

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