-1

I have a unix shell script file whose owner is "xyz" when run deletes some specific files.

I want to trigger this script to delete files in some other directory where the owner for the files to be deleted is different from the owner of the script. Is this possible? Is this possible to run this script as different user so that it can delete those new files?

EDIT : I use Autosys to periodically trigger this script.

user2133404
  • 1,816
  • 6
  • 34
  • 60

2 Answers2

0

Usually you use sudo for that:

sudo -u ANOTHER_USER /path/to/the/script.sh

However, your current account needs proper permissions to do so. You can configure those permissions using the file /etc/sudoers.

You'll find a ton of articles out there how to use sudo. This for example: http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:Ch09:_Linux_Users_and_Sudo

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
0

You can chmod the files that need to be deleted first if you have sufficient rights. Afterwards your script, no matter what user it executes, will succeed.

Examples : http://en.wikipedia.org/wiki/Chmod

Sono
  • 26
  • 3