Tar
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 .tar / .tgz / tar.gz FILE IN LINUX]
extract/unzip tar file with minimal switch syntax (tar linux does not care if you precede with a dash.) tar will assume the z (compression) flag is it determines the tar file is compressed.
tar xf userfiles.tar.xz
You should technically specify compression (if gzip use -z). Optionally add -v verbose to see file extraction output.
tar -xzvf userfiles.tar.xz
When you use the command tar xzvf archivename.tgz to extract a .tgz (tar gzip) archive, the tar utility will extract the files contained within the archive into the current working directory by default. If the archive contains a file with the same name as an existing file in the directory you're extracting to, the existing file will be overwritten without any warning, unless you explicitly modify the behavior with additional options. If you want to prevent overwriting existing files you have several options like: --skip-old-files --keep-old-files --backup --no-overwrite
tar xzvf archivename.tgz --no-overwrite
[HOWTO EXTRACT LZMA2 tar xz FILE IN LINUX]
The xz format is a single-file compression format that is based on the LZMA2 algorithm. Requires xz tools. 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.