What is the easiest way to list all the user:group found in a tarball?
11
votes
2
answers
1595
views
I'm installing some of my data from my old server to my new server.
Since I had my old server for ages, I have a huge amount of legacy data with, most certainly, legacy user and group names.
When extracting, tar does its best to match the user and group info by name and uses the identifiers as a fallback or the current user as a last resort.
What I'd like to do is make sure that all the users and groups exist before I do the extraction. That way all the files get the correct ids.
To do that, the best way I can think of is to list all the user and group names found in the tar file. I know I can use the
tar tvf backup.tar
command to list all the files, but then I'd have to come up with a way to extract the right two names.
I'm wondering whether there would be a simpler way than using the tv
option. Some tool or command line options that only extracts the user name and group name, then I can use sort -u
to reduce the list to unique entries.
Anyone knows of such a feature?
---
**Update:**
For those interested in fixing the ownership after extraction (or in my latest case, after re-installing the OS, so no tar involved), I created a tool to do that safely on an entire tree:
https://github.com/AlexisWilke/alex-tools/blob/main/tools/fix-ownership.cpp
Asked by Alexis Wilke
(3095 rep)
Oct 14, 2019, 07:52 PM
Last activity: Apr 12, 2025, 01:41 PM
Last activity: Apr 12, 2025, 01:41 PM