I don’t use tar very often. However every time I do, I don’t remember the switches and options. So I am making this post in order to remember the basics of the tar command.
Store files in a new archive (option -c), in file name arch.tar (option -f indicates file name), while show all output (-v).
tar -c -v -f arch.tar .
This will be the same as :
tar -cvf arch.tar .
From now on will use a short way of giving commands to the tar.
To archive files with compression add switch for compression. For gzip add -z:
tar -cvzf arch.tar .
List files (-t) within the archive (-f) arch.tar, while showing verbose output (-v) :
tar -tvf arch.tar
Extract files (-x) from archive (-f) arch.tar, while showing verbose output (-v):
tar -xvf arch.tar
Extract to specific directory use -C switch.
tar -xvf arch.tar -C arch