Solved

chmod for multiple users

Posted on 2010-09-08
5
585 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

691 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