I want to delete a file (/var/lib/pacman/db.lck) owned by root user from within a simple script owned by a non-privileged user:
#!/bin/bash
rm -f /var/lib/pacman/db.lck
But I don't want to run the script using sudo
in order to avoid typing password each time I execute the script as a non-privileged user. In order to achieve this I set the s
bit:
-rwsrwsrwx 1 popov users 41 04.02.2015 10:35 unlock.sh
But after running the script I get
rm: cannot remove ‘/var/lib/pacman/db.lck’: Permission denied
It seems that I wrongly understand the purpose of s
bit.
So the question is: How to setup the script permissions (and/or perhaps ownership of the script) which will let the script to delete a root-owned file when invoked by a non-privileged user?