What is the command(s) to uncompress tar archive?!?

Owen Townend owen.townend at gmail.com
Tue Oct 7 07:00:56 BST 2008


2008/10/7 Peter Williams <pewtas at gmail.com>:
> Hi All,
>
> I have a tar archive "user_backup_20080918.tgz" -- which is 19.4 GB of data
> which was previously my home folder, with many sub-folders, for my (old)
> user name 'user'.
>
> I have since reinstalled Linux... actually a new installation of Linux
> Ubuntu Mint. Now I want to uncompress the archive to my new home folder with
> my new user name of 'peter'.... what are the commands I need to do to
> achieve this?!?
>
> note that the archive contains:
>
> user_backup_20080918.tgz (19.4 GB filesize)
>  + user (folder)
>      + many folder and sub-folders here, as well as hidden files with
> leading dots in their filenames.
>
> eg. would need to uncompress folders inside 'user' folder (old user name) to
> current 'peter' user (home) folder.
>
> I'm guessing that I'd need to use the chown (change owner) command -- but I
> don't know how it works... I think I'd need to run it recursively on
> sub-folders... correct?!? How do I do this?
>
> Regards,
>        PEW  ;-)))
>

Hey,

tar will change the owner of the files as they are extracted to be
owned by the current user.
(Except root, where the default is to preserve the owner)
So all you need then is read the man page...
or:
decompress (-z)
extract (-x)
strip off the top directory 'user' (--strip 1)
output to your current home directory (-C /home/peter)
specify the archive (-f /path/to/user_backup_20080918.tgz)

Combined:
tar -zx --strip 1 -f user_backup_20080918.tgz -C /home/peter

cheers,
Owen.



More information about the ubuntu-au mailing list