Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-07-2018, 01:23 AM   #1
Senior Member
Registered: Apr 2010
Posts: 1,532

Rep: Reputation: 262Reputation: 262Reputation: 262
Question Linux Groups - File/Directory Permissions

Hello guys, if already set groups and users in one system.

If I need to retire the Linux box and I want to migrate to a new box.

How do I copy the groups and user settings?

For the files and directories, is there a way to retain same permissions on the new box after copying?

Thanks for any input.
Old 12-07-2018, 01:32 AM   #2
Registered: Jun 2012
Location: Missouri, USA
Posts: 226

Rep: Reputation: 63
You can use the rsync command to migrate your files and data over to your new server with the '--numeric-ids' option included.
1 members found this post helpful.
Old 12-07-2018, 02:43 AM   #3
Senior Member
Registered: Apr 2010
Posts: 1,532

Original Poster
Rep: Reputation: 262Reputation: 262Reputation: 262
i used rsync before to copy files and folders for backup, it does retain permission settings.

But i haven't try rsync to a new system, let's say if I have a group "Sales", "QC", "Deliveries" and each group has members.

Do i need to copy the /etc/config/group in the old system and copy to the new system?

Basically, the one is empty. So, if i used rsync even though it will retain permissions but it won't match anything on the new system since no users or groups has been created.

I think one question would be: how to copy users and group permissions to the new system?
Old 12-07-2018, 12:18 PM   #4
Registered: Dec 2011
Distribution: Mageia, Slackware, Maemo
Posts: 419
Blog Entries: 1

Rep: Reputation: Disabled

-p same as --preserve=mode,ownership,timestamps

preserve the specified attributes (default: mode,ownership,timestamps),
if possible additional attributes: context, links, xattr, all
This is in the CP manual if you need to verify.

-H, --hard-links preserve hard links
-p, --perms preserve permissions
-E, --executability preserve executability
-A, --acls preserve ACLs (implies -p)
-X, --xattrs preserve extended attributes
-o, --owner preserve owner (super-user only)
-g, --group preserve group
--devices preserve device files (super-user only)
--specials preserve special files
-t, --times preserve modification times

Last edited by zeebra; 12-07-2018 at 12:20 PM.
1 members found this post helpful.
Old 12-07-2018, 02:50 PM   #5
Senior Member
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,168

Rep: Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681
Yes. If you cp -p or rsync -a files from the old system to the new system, they will retain the UIDs and GIDs of the old system. If those are unused on the new system, ls will display the IDs instead of a username.

If you create a user on the new system with one of those IDs, the files will then belong to that user.

What I've done in the past is selectively copy those /etc/passwd (and related /etc/shadow) and /etc/group entries to support the user files I've copied over. Not a good idea to copy over every user/group in those files, as the new system may have different assignments for system users than the old system did.

Example: To copy the user scasey who has a group scasey, I'd take these lines:
from /etc/passwd 
scasey:x:1000:1000:Sean Casey:/home/scasey:/bin/bash
from /etc/shadow
from /etc/group
(the password field in /etc/shadow posted here is not real)

Actually for /etc/group I'd do something like
grep scasey /etc/group > scaseygrp.txt
to capture all groups of which scasey is a member

That would preserve and transfer the users to the new system.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
invalid group id redhat linux as 5 - all groups in group file are invalid groups nlong1 Red Hat 1 02-15-2009 04:43 AM
Permissions: giving specific groups write access to a directory kinetik Linux - General 3 07-06-2006 09:30 AM
File and directory permissions or groups kuplo Linux - Newbie 1 11-11-2005 04:06 AM
Groups members of other groups bentz Linux - Security 6 06-23-2003 12:23 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:07 PM.

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