Tar: Difference between revisions
Created page with "tar xvf filename.tar -> untar gzip -dfvr -> un-gzip Assume floppy drive is a 3.5" drive at /dev/fd0 Copy to disk: tar -c -f /dev/fd0 -L1440K -M <File-Name> Copy from disk:..." |
|||
Line 39: | Line 39: | ||
== [HOWTO COMPRESS with tar zip tar.gz tgz] == | == [HOWTO COMPRESS with tar zip tar.gz tgz] == | ||
Back up a directory of files and preserve the path. | Back up a directory of files and preserve the path. | ||
tar -zcvf | tar -zcvf archive.tar.gz sourcefiles | ||
* -z compress using zip | * -z compress using zip | ||
* -c create | * -c create | ||
Line 46: | Line 46: | ||
You can add -p to preserve absolute names, so that the path will begin with the root / and all the way to the directory location. This is really only useful for doing backups/ | You can add -p to preserve absolute names, so that the path will begin with the root / and all the way to the directory location. This is really only useful for doing backups/ | ||
If you are within a directory, and you want to archive all files and subdirectories without having the root directory itself in the archive path, you can do the following: | |||
tar -zcf ../archivename.tgz . | |||
In this example we are archiving the contents of a directory called ./sourcefiles while we are within the directory itself, aka our path is ~/sourefiles/ and we run the command within the directory. Variations, tgz works the same as tar.gz and we left out the v for verbose. |
Revision as of 20:48, 28 February 2025
tar xvf filename.tar -> untar
gzip -dfvr -> un-gzip
Assume floppy drive is a 3.5" drive at /dev/fd0
Copy to disk:
tar -c -f /dev/fd0 -L1440K -M <File-Name> Copy from disk:
tar -x -f /dev/fd0 -L1440K -M <File-Nam
[LIST CONTENTS OF COMPRESSED TAR ARCHIVE]
List contents of filename.tar to the screen
tar -tvf filename.tar
List the contents of a gnuzip (gzip) compressed tar archive.
tar -ztf name-of-file.tgz
Verbosely
tar -ztvf name-of-file.tgz
Search the archive
tar -ztf name-of-file.tgz | grep -i "search string"
Verbosely
tar -ztvf name-of-file.tgz | grep -i "search string"
Online Resources
[HOWTO EXTRACT xz / tgz FILE IN LINUX]
The xz format is a single-file compression format that is based on the LZMA2 algorithm. Requires xz toos. Mint/Ubuntu install
sudo apt install xz-utils
extract/unzip xz tar file
tar -xvf userfiles.tar.xz
Archive types tar.gz and tar.xz are both compressed tar-files, however, using variations on the compression method. For the user there is no difference when extracting either type of file, with the exception of extraction speed. The compression method for xz produces a more densely compact file resulting in a higher level of compression at the expense of speed. It may take longer, or even significantly longer to extract files from a xz archive.
[HOWTO COMPRESS with tar zip tar.gz tgz]
Back up a directory of files and preserve the path.
tar -zcvf archive.tar.gz sourcefiles
- -z compress using zip
- -c create
- -v verbose
- -f archive file to create
You can add -p to preserve absolute names, so that the path will begin with the root / and all the way to the directory location. This is really only useful for doing backups/
If you are within a directory, and you want to archive all files and subdirectories without having the root directory itself in the archive path, you can do the following:
tar -zcf ../archivename.tgz .
In this example we are archiving the contents of a directory called ./sourcefiles while we are within the directory itself, aka our path is ~/sourefiles/ and we run the command within the directory. Variations, tgz works the same as tar.gz and we left out the v for verbose.