Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
i have recently created a script that performs an rsync between 2 directories. it then ensures that the directory that was "sync'ed" has the correct permissions (it is a web directory so needs apache permissions...)
so within my shell script, there is a call to an "rsync" and another to a "chown"
i can run this script fine when logged in as root (the creator of the file) and also when i have it scheduled as a cron job (as it runs as root).
i would like any other user to be able to manually run it at any time though (in case they cannot wait for the next 5 mins!!)
i changed the SUID so the file perms are:
this should allow any person to run the script with correct perms. but i recieve the following outputted errors:
[user@hostname ftp]$ ./syncweb.sh
RSYNCing the FTP and apache areas
building file list ... opendir(images): Permission denied
IO error encountered - skipping file deletion
wrote 270 bytes read 20 bytes 580.00 bytes/sec
total size is 54667 speedup is 188.51
rsync error: some files could not be transferred (code 23) at main.c(620)
Changing Permissions in web directory
chown: `/var/www/html/images': Permission denied
have i set this up right? do i need to set the SUID on both the rsync and chown apps aswell so that they can be run in elevated priveleges? this is not something i want to do though!!
Shell scripts ignore the SUID bit. That's why you get the errors. I used to have a link to a page that said as much, but I can't dig it up. If you search for "shell script suid" on google, it might turn up something about it.
Some options you have:
1. Make the constituent programs suid. This is probably not what you want if normal users have access to rsync and definitely chown.
2. Write the script in a programming language, compile it as an executable, and set the executable's suid bit (i.e. turn the script into something other than a script)