LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 12-07-2018, 12:23 AM   #1
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
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, 12:32 AM   #2
rosehosting.com
Member
 
Registered: Jun 2012
Location: Missouri, USA
Posts: 236

Rep: Reputation: 64
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, 01:43 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
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, 11:18 AM   #4
zeebra
Senior Member
 
Registered: Dec 2011
Distribution: Slackware
Posts: 1,830
Blog Entries: 17

Rep: Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638Reputation: 638
https://unix.stackexchange.com/quest...issions-intact

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

--preserve[=ATTR_LIST]
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.

Quote:
-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 11:20 AM.
 
1 members found this post helpful.
Old 12-07-2018, 01:50 PM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
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:
Code:
from /etc/passwd 
scasey:x:1000:1000:Sean Casey:/home/scasey:/bin/bash
from /etc/shadow
scasey:$OL7jPFOTg598KpTXg::0:99999:7:::
from /etc/group
scasey:x:1000:scasey
(the password field in /etc/shadow posted here is not real)

Actually for /etc/group I'd do something like
Code:
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.
Old 12-11-2018, 09:25 AM   #6
alexpaton
Member
 
Registered: Jul 2009
Distribution: Ubuntu & ClearOS
Posts: 163

Rep: Reputation: 47
I have previously taken the disk out of an old "retired" computer, and put it in the new one. 99% of things just worked. As I remember, the last time I did that, I believe that the only thing that didn't work was sound, which was easily fixed.
 
Old 12-14-2018, 03:48 AM   #7
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Wink

Quote:
Originally Posted by alexpaton View Post
I have previously taken the disk out of an old "retired" computer, and put it in the new one. 99% of things just worked. As I remember, the last time I did that, I believe that the only thing that didn't work was sound, which was easily fixed.
This would be good if you are not upgrading the size of your hard drive or the hard drive is quite new.

But if hard drive size is increased or the hard drive is showing some issue then I guess this method is not ideal.
 
Old 12-15-2018, 12:12 PM   #8
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
When migrating from one machine to other, historically, I have relied on backups (tar or at times commercial products which under the hood runs tar).
Tar does preserve permissions, but mostly I restore from backups because that is also one way I can test that my backups are working correctly.
 
Old 12-17-2018, 04:41 AM   #9
alexpaton
Member
 
Registered: Jul 2009
Distribution: Ubuntu & ClearOS
Posts: 163

Rep: Reputation: 47
Quote:
Originally Posted by JJJCR View Post
This would be good if you are not upgrading the size of your hard drive or the hard drive is quite new.

But if hard drive size is increased or the hard drive is showing some issue then I guess this method is not ideal.
In that situation, I MIGHT copy the partition over with gParted, and then tinker with fstab to amend the UUIDs. It depends how much software I would need to install on a fresh install, I suppose.
 
  


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 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 03:43 AM
Permissions: giving specific groups write access to a directory kinetik Linux - General 3 07-06-2006 08:30 AM
File and directory permissions or groups kuplo Linux - Newbie 1 11-11-2005 03:06 AM
Groups members of other groups bentz Linux - Security 6 06-22-2003 11:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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