Solved

chmod for multiple users

Posted on 2010-09-08
5
574 Views
Last Modified: 2012-05-10
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
Comment
Question by:beefnorthwest
  • 3
5 Comments
 
LVL 12

Accepted Solution

by:
mccracky earned 250 total points
ID: 33631718
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
 
LVL 2

Expert Comment

by:heygar
ID: 33631743
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
 
LVL 3

Assisted Solution

by:T1750
T1750 earned 250 total points
ID: 33632111
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
 
LVL 3

Expert Comment

by:T1750
ID: 33632635
The command to change umask is umode.
0
 
LVL 3

Expert Comment

by:T1750
ID: 33632637
Actually that's complete rubbish, ignore my last comment.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now