LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 04-05-2011, 10:04 AM   #1
etika
Member
 
Registered: Dec 2010
Posts: 38

Rep: Reputation: 0
performing admin task like changing owner of a file through shell script


hey

i want to automate my tasks of administrator using shell scripts
like changing owner of a file which usually only the super user which requires password can change
i want to do this thing using shell script how to do?
please guide me..

Last edited by etika; 04-05-2011 at 10:07 AM.
 
Old 04-05-2011, 10:59 AM   #2
zordrak
Member
 
Registered: Feb 2008
Distribution: Slackware
Posts: 595

Rep: Reputation: 116Reputation: 116
Quote:
man crontab
cron is designed for doing this. Add entries for what you want to schedule in root's crontab and it will do it for you as root.
 
Old 04-09-2011, 06:27 AM   #3
etika
Member
 
Registered: Dec 2010
Posts: 38

Original Poster
Rep: Reputation: 0
hey
i don't want to schedule my task ,i just want to do once

(i want to change the ownership of a file from tomcat to abc not using sudo but using shell script)

any idea of doing so .. pls tell
 
Old 04-10-2011, 05:17 AM   #4
etika
Member
 
Registered: Dec 2010
Posts: 38

Original Poster
Rep: Reputation: 0
these are the details of etika.sh
-rw-rw-r--. 1 etika etika 83 2011-04-10 12:05 etika.sh

contents of etika.sh
chown abc:abc /home/etika/Desktop/etika.txt
ls -l /home/etika/Desktop/etika.txt

details of etika.txt file
-rwxrwxrwx. 1 etika etika 83 2011-04-10 12:04 etika.txt

i have made etika as sudoers

now i ran my script
etika@etika Desktop]$ sh etika.sh
chown: changing ownership of `/home/etika/Desktop/etika.txt': Operation not permitted
-rwxrwxrwx. 1 etika etika 83 2011-04-10 12:04 /home/etika/Desktop/etika.txt

i wanted this to happen where abc is also a user on my system
-rwxrwxrwx. 1 abc abc 83 2011-04-10 12:04 /home/etika/Desktop/etika.txt

why its saying operation not permitted i have made etika as a sudoer then why still it is showing problem



even i tried by changing the ownership of etika.sh to root

[etika@etika Desktop]$ sudo chown root:root etika.sh
[sudo] password for etika:
[etika@etika Desktop]$ ls -l etika.sh
-rw-rw-r--. 1 root root 83 2011-04-10 12:05 etika.sh
[etika@etika Desktop]$ sh etika.sh
chown: changing ownership of `/home/etika/Desktop/etika.txt': Operation not permitted
-rwxrwxrwx. 1 etika etika 83 2011-04-10 12:04 /home/etika/Desktop/etika.txt

still there is a problem


i hope i have stated my problem clearly


(
i will be running this script from jsp page through tomcat and i want my script to change the ownership of my file etika.txt which is owned by tomcat to etika user .... but all this ownership changing work is done by root iam unable to change the ownership of the file)
 
Old 04-10-2011, 05:25 AM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Just putting a user into a sudoers-file isn't enough, you also have to start your script via sudo
Code:
sudo etika.sh
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
performing regex on shell script variable? ocicat Programming 3 07-17-2007 02:10 PM
shell script for changing a txt file content Flobsi Linux - Newbie 3 10-06-2006 03:10 AM
File ownership - changing a whole dir to different owner sKAApGIF Linux - Desktop 6 08-21-2006 08:25 AM
Owner of file in shared directory changing Gunbunny Linux - General 4 01-13-2006 07:00 PM
Changing owner and group of file surfbass Linux - General 2 12-12-2005 02:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration