nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Chown command possible.

This is a discussion on Chown command possible. within the Shell scripting forums, part of the Development/Scripting category; Hi guys, Have a question i hope someone can help me with... Running a vps with with root access...have a ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 24-05-2009, 11:55 AM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
sammielea is on a distinguished road
Default Chown command possible.

Hi guys,

Have a question i hope someone can help me with...

Running a vps with with root access...have a client that has asked for shell access...i looked into the "jailed shell" and it seems this is the way to go on a shared server...however it seems he dosent have access to "chown" files under his account. Is there a way around this ..am i missing sumtin ?

appreciate any help
Reply With Quote
  #2 (permalink)  
Old 24-05-2009, 12:45 PM
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 82
Thanks: 0
Thanked 16 Times in 16 Posts
Rep Power: 3
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default


Only root can run chown.

If the files are in his directory he can copy them and delete the originals.
Reply With Quote
  #3 (permalink)  
Old 24-05-2009, 01:25 PM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
sammielea is on a distinguished road
Default

HI cfajohnson

thanks for the reply....yes the files he wants to chown are under his account.

Basically whats happening is, hes running smf (simple machines forum script) and is loosing ownership of files when he installs updates or modifications via the smf admin panel...i think the problem (if u wanna call it that) is that the webserver is running as user nobody.

anything u can suggest would be greatly appreciated.

Reply With Quote
  #4 (permalink)  
Old 24-05-2009, 02:35 PM
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 82
Thanks: 0
Thanked 16 Times in 16 Posts
Rep Power: 3
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default

Quote:
Originally Posted by sammielea View Post
HI cfajohnson
anything u can suggest would be greatly appreciated.

Have you tried the suggestion I made?
Reply With Quote
  #5 (permalink)  
Old 25-05-2009, 12:13 AM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
sammielea is on a distinguished road
Default

Hi cfajohnson

sorry...missed what u were saying...
is there a command he could run (jailed shell) to copy the files under "nobody" to get them under his userid on the server and then delete the originals that are under "nobody"...

or is this sumtin that would need to be done via ftp / cpanel ?

Thanks again
Reply With Quote
  #6 (permalink)  
Old 25-05-2009, 02:30 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

if chown is not provided in shell jail, use php or perl script via webbrowserto change file permission. Perl example:
Code:
chown $uid, $gid, @filenames;
chown - perldoc.perl.org
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #7 (permalink)  
Old 25-05-2009, 12:43 PM
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 82
Thanks: 0
Thanked 16 Times in 16 Posts
Rep Power: 3
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default

Quote:
Originally Posted by sammielea View Post
is there a command he could run (jailed shell) to copy the files under "nobody" to get them under his userid on the server and then delete the originals that are under "nobody"...

The same as anywhere else -- assuming access to the commands.

Code:
cp "$file" "$file-mine" &&
 mv "$file-mine" "$file"
Reply With Quote
  #8 (permalink)  
Old 25-05-2009, 12:47 PM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
sammielea is on a distinguished road
Default

Hi nixcraft,

thanks for the reply...ill admit im a little out of my dept here...

Is it possible to do the following...

chown -R user1:user1 /home/user1/public_html/*

upload this into MY ROOT account as a script somehow...would it be possible to call that script via a browser so it executes and corrects the chown problem for him without intervention from me...

So say he installs his mods to his forum...and the files get userid of nobody...he can simply type www.domainname/pathtofile/filename and get it to execute the above chown command ??

If its possible id really appreciate any help you can give it setting this up....
Reply With Quote
  #9 (permalink)  
Old 26-05-2009, 04:32 AM
Member
User
 
Join Date: May 2009
OS: Mandriva
Posts: 82
Thanks: 0
Thanked 16 Times in 16 Posts
Rep Power: 3
cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about cfajohnson has a spectacular aura about
Default

Quote:
Originally Posted by nixcraft View Post
if chown is not provided in shell jail, use php or perl script via webbrowserto change file permission. Perl example:
Code:
chown $uid, $gid, @filenames;
chown - perldoc.perl.org

chown doesn't change permissions; it changes ownership, and, on most file systems, it can only be run by root. Wrapping it in a script doesn't change that.
Reply With Quote
  #10 (permalink)  
Old 26-05-2009, 11:12 AM
Junior Member
User
 
Join Date: May 2009
OS: Debian
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
sammielea is on a distinguished road
Default

Hi cfajohnson,

u are correct i was after chown command.
I ended up setting up a cron job to run the following

*/1 * * * * chown -R username:username /home/username/public_html/foldername/*

its an acceptable workaround for now...appreciate the pointers and help guys.

Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
save command and command output savook CentOS / RHEL / Fedora 1 08-05-2009 05:33 PM
Automate command execution - reboot-command execution ganeshp@moris.org Shell scripting 2 03-12-2008 11:18 AM


All times are GMT +5.5. The time now is 05:38 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38