Difference between revisions of "TAR guidelines"
P.petrelli (talk | contribs) (Created page with " == '''<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">Tar: Tape ARchive cheat sheet</span></span>''' == === '''<span style="font-size:m...") |
P.petrelli (talk | contribs) |
||
Line 4: | Line 4: | ||
=== '''<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">Some options</span></span>''' === | === '''<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">Some options</span></span>''' === | ||
− | * | + | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">c – create archive file.</span></span> |
− | <span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">c – create archive file.</span></span> | + | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">u - update archive file.</span></span> |
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">x – extract a archive file.</span></span> | ||
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">v – show the progress of archive file.</span></span> | ||
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">f – filename of archive file.</span></span> | ||
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">t – viewing content of archive file.</span></span> | ||
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">j – filter archive through bzip2.</span></span> | ||
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">z – filter archive through gzip.</span></span> | ||
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">r – append or update files or directories to existing archive file.</span></span> | ||
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">p - preserve-permissions</span></span> | ||
+ | *<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">--acls - preserve acls </span></span> | ||
− | + | '''<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;">Create tar archive</span></span>''' | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;"> tar -cvf archive.tar testdir</span></span> | <span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;"> tar -cvf archive.tar testdir</span></span> | ||
Line 100: | Line 78: | ||
<span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;"> tar -rvf archive.tar readme.txt</span></span> | <span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;"> tar -rvf archive.tar readme.txt</span></span> | ||
− | <span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;"> tar -rvf archive.tar anotherdir</span></span> | + | <span style="font-size:medium;"><span style="font-family:Arial,Helvetica,sans-serif;"> tar -rvf archive.tar anotherdir</span></span><br/> |
− | <br/> |
Latest revision as of 01:56, 30 July 2021
Contents
Tar: Tape ARchive cheat sheet
Some options
- c – create archive file.
- u - update archive file.
- x – extract a archive file.
- v – show the progress of archive file.
- f – filename of archive file.
- t – viewing content of archive file.
- j – filter archive through bzip2.
- z – filter archive through gzip.
- r – append or update files or directories to existing archive file.
- p - preserve-permissions
- --acls - preserve acls
Create tar archive
tar -cvf archive.tar testdir
Create compressed tar archive
tar -cvzf archive.tar.gz testdir
Or for more compression but slower writing/uncompressing
tar -cvfj archive.tar.bz2 testdir
Exclude only files or directories with pattern
tar -cvf archive.tar --exclude=”*.txt” testdir
There are many exclude options check with: man tar
Update tar archive
tar -uvf archive.tar testdir
Will add for example previously excluded files and update any file which changed
Untar archive
tar -xvf archive.tar
tar -xvf archive.tar.gz
tar -xvf archive.tar.bz2
tar -xvf archive.tar -C /home/uncompress/here
List archive content
tar -tvf archive.tar
Extract one file from tar archive
Need to use the full path for the file
So if you did:
tar -cvf archive.tar testdir
You use
tar -xf archive.tar testdir/readme.txt
Extract multiple files from tar archive
tar -xvf archive.tar readme.txt another.txt
Or using wildcards
tar -xvf archive.tar *.txt
Add files or directories to tar archive
tar -rvf archive.tar readme.txt
tar -rvf archive.tar anotherdir