LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-18-2018, 07:07 AM   #1
LinuGeek
Member
 
Registered: Jun 2008
Posts: 126

Rep: Reputation: 0
Change the group ownership of directories from A --> B


Hello Experts,

i am working on a find command that can recursive find and change the group ownership of all the files/directories from A ---> B ?

A project directory has 100s of Dirs and Files with groupid=50 (proj). We wish to change groupid of only those files/dirs to newgroupid=150(Develop). Ofcourse without affecting other dir/files.

Would following command be suffice?

Quote:
find projdir -group proj -exec chgrp -c Develop "{}" \;

A question, how to take care of symlinks in this case?


Thanks.


Regards.

Last edited by LinuGeek; 10-18-2018 at 07:15 AM.
 
Old 10-18-2018, 08:57 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
yes, try in stable test environment, adjust as needed of course.
Code:
user_name=

find / -group  1002 -exec chgrp -h $user_name {} \;

find / -user 1002 -exec chown -h $user_name {} \;
Quote:
Originally Posted by Man Page
-h, --no-dereference
affect symbolic links instead of any referenced file (useful
only on systems that can change the ownership of a symlink)

Last edited by BW-userx; 10-18-2018 at 09:01 AM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sub-Directories not picking up correct group permissions for new files/directories JockVSJock Linux - Newbie 4 05-07-2017 10:52 AM
Creating files/directories a different group inherits it, how to change JockVSJock CentOS 2 11-22-2014 11:00 AM
Why can't I change ownership of files/directories in Debian Linux? bmartisius Linux - Newbie 3 04-05-2013 07:55 AM
Changing group ownership rayn0r Linux - Networking 1 11-28-2007 04:35 PM
ownership of directories cwolf78 Linux - Software 3 05-08-2005 11:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration