I have a custom requirement by a specific user , that he wants me to write a shell script to move files from one folder to another folder . These two folders have different owners

Now, I managed to do that by logging in as root, but want to achieve this without giving root privileges to user.

I am not allowed to do any new package installation, Not allowed to use any another shell than Korn .

Please suggest a solution. Yeah I know this is not a safer way and a bad approach, still am curious about satisfying the need of a user ..

1

There are 1 answers

2
Ram On
  1. Write a script to move files.
  2. change the ownership of the script to root
  3. Update the /etc/sudoers file to give the user permissions to run the script as root:
    user ALL = NOPASSWD: /opt/script.sh
  4. User can execute the script:
    sudo /opt/script.sh

    That shouldn't ask for root password, but give the user privileges to run the script as root.