Does tar Preserve Permissions if User IDs Change?

linuxtar

I need to backup some data with the "p" option on tar command. The problem is the place I'm going to restore this data will have all the same users, but those users may have different IDs. Does that make any difference to tar or will it restore permissions correctly by user name?

Best Answer

tar records permissions based on the UID and GID, not on the string associated with them. So if the UID on one server was 3300 and that was linked to 'bob', on the new server the file will be owned by the user who has the UID 3300.

Virtual everything (I want to say everything, but you can never be 100% sure) on UNIX uses the UID:GID values, because that's what is actually stored at the filesystem level. The name is just a simple lookup in the passwd file, the underlying checks are done using the numeric values.