Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Root permission for bash script

    Hello, I am trying to write a script that will create a directory, copy files to it, zip them, move the zip file to the desktop and clean up. However, when I run the script, it comes back stating that I do not have permission to make the directory.

    I wanted to know how to add the permission into the script to allow for access to whoever runs the script to pull the logs, but won't leave the system in the root user?

    here is what I have for code so far:

    host= 'hostname'
    mkdir /home/savelogs
    cp /var/logs/* /home/savelogs
    zip -r Asset_$ /home/savelogs
    cp /home/SeaChange/Asset*.zip /home/SeaChange/Desktop
    rm -r /home/savelogs

    Any help would be greatly appreciated.

  2. #2
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Make sure the user that runs this script has all the permissions needed:

    1] +w /home/savelogs
    2] +r /var/logs/*
    3] +r /home/SeaChange/Asset*.zip
    4] +w /home/SeaChange/Desktop

    Remark 1: one should NEVER tinker with the home directories of other users.
    Remark 2: read the manual pages about the unix file permissions. It is vital for everyone that writes scripts or works within unix environments to understand them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts