[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Changing Permissions Recursively

Posted on 2006-11-20
5
Medium Priority
?
242 Views
Last Modified: 2010-04-20
Hello,

I have a directory with dozens of sub-directories and hundreds of files.

Some files have the ownership set to "nobody" and some have the ownership set to "dev".

How can I change ownership for ALL "dev" to "prod", for ALL files and directories, and for both the user and the group?

Thanks.

0
Comment
Question by:hankknight
[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
5 Comments
 
LVL 16

Author Comment

by:hankknight
ID: 17982527
I tried this:

         chown prod /home/mydir/* -R
         chgrp prod  /home/mydir/* -R

But it change ownership of ALL files, even ones that were owned by "nobody".  I ONLY want to change ownership where it was set to "dev"
0
 
LVL 35

Accepted Solution

by:
Duncan Roe earned 1200 total points
ID: 17982654
You can use the find command to select the files to change. First of all, determine the numeric user id od "dev". Let's call the result n. Now:

find . -type f -uid n -exec "chown {} newuser \;

will do the job. Type "man find" for an explanation of what the above command line does.
0
 
LVL 16

Author Comment

by:hankknight
ID: 17982794
Thanks!  

   ->> First of all, determine the numeric user id of "dev"

How do I  determine the numeric user id of "dev"?
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 400 total points
ID: 17984455
grep dev /etc/passwd|cut -f3 -d:

or

find . -user dev -exec chown {} prod:group {} \;

0
 
LVL 1

Assisted Solution

by:dnb
dnb earned 400 total points
ID: 17988774
The command "id dev" will tell you the uid of user dev but as Tintin pointed out using find's -user option with the username is easier.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.
Suggested Courses

650 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