LinuxQuestions.org
Visit Jeremy's Blog.
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, 01:23 AM   #1
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,541

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
rosehosting.com
Member
 
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
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,541

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
zeebra
Member
 
Registered: Dec 2011
Distribution: Mageia, Slackware, Maemo
Posts: 432
Blog Entries: 1

Rep: Reputation: Disabled
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 12:20 PM.
 
1 members found this post helpful.
Old 12-07-2018, 02:50 PM   #5
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,204

Rep: Reputation: 688Reputation: 688Reputation: 688Reputation: 688Reputation: 688Reputation: 688
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, 10:25 AM   #6
alexpaton
Member
 
Registered: Jul 2009
Distribution: Ubuntu & ClearOS
Posts: 115

Rep: Reputation: 32
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 Yesterday, 04:48 AM   #7
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,541

Original Poster
Rep: Reputation: 262Reputation: 262Reputation: 262
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.
 
  


Reply


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

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

All times are GMT -5. The time now is 02:43 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration