Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 590
  • Last Modified:

chmod for multiple users

I am running a script (capistrano if that matters) that connects via ssh to another server, does some file transfers then tries to set permissions with chmod.  it works fine for me since I was the only one working on them and I was the owner.  I need to be able to do this now with 2 users, but we get operation not permitted when the other user tries to run it.  

I am sure this is a simple solution, but I don't know how to fix it.  I tried setting the group to admin (since we are both in the admin group), but that didn't work.

let me know if I am leaving anything out.
0
beefnorthwest
Asked:
beefnorthwest
  • 3
2 Solutions
 
mccrackyCommented:
on the server you can do a few things:

Set the primary group for both of you to the admin group (similar to this article: http://articles.techrepublic.com.com/5100-22_11-5349294.html).

If you are using chmod all the time, you might want to look into the umask and just set that.

On the directory where you are putting the files you can set the setgid bit (e.g. chmod 2775 on the directory) so all files created in the directory get the group of the directory itself.

there's probably more, but that's a start.
0
 
heygarCommented:
Because of the ownership and the current permissions, you may have to do a chown before you do the chmod.  

Or you can change the way the files are transferred so that they transfer with the correct ownership before you do the chmod.  

If you do a chmod on files you don't own, the permissions already have to be somewhat permissive or you have to be root.
0
 
T1750Commented:
The correct way to do it is to setup a umask as mccracky said. An easy one-liner for you to get the umask is this:

(chmode="750" ; printf '%04o\n' $((8#${chmode}^8#777)))

Just put the mode you want into chmode instead of 750 and it will spit out the umask you need to set for that mode to happen. Note, it's clever enough to know if you specify 7 not to set executable bits on the files, only on the directories. So changing the umode on the server is the best solution since then there is no need to chmod anymore.
0
 
T1750Commented:
The command to change umask is umode.
0
 
T1750Commented:
Actually that's complete rubbish, ignore my last comment.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now