Skip to main content

14.9) Using "tar" To Gather Up An Account


In the home directory, try collecting all the files in your account by using the tar command. It will collect all the directory tree and files in those directories as well.
tar –cvf documents.tar documents
To tar your whole account into one file:
tar –cvf account.tar *
To get your files and directories back, i.e. untar, type:
tar –xvf account.tar
So to untar the ‘x’ in the options indicates to extract the files and directories. This has to be in the directory that account.tar resides, of course. Notice that there are two changes:

    1. the x is used as the option instead of c
    2. you only give the tar file name and nothing else

Note:
You may want to compress the files as they are added into the tar file.   Then you can use the z option.    For example,
tar -cvzf account.tar.gz *
Notice that you need to name the file with .tar.gz since it will be compressed as well as gathered up in a tar file.   To extract and uncompress then type:
tar -xvzf account.tar.gz
or do it separately using gunzip account.tar.gz and then tar -xvf account.tar.