Difference between revisions of "Linux command: tar"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) m Tag: visualeditor |
Rafahsolis (talk | contribs) m (→With password) Tag: visualeditor |
||
| Line 19: | Line 19: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | === With password === | + | ===With password=== |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| − | tar -czf - * | openssl enc -e -aes256 -out secured.tar.gz | + | tar -czf - * | openssl enc -e -aes256 -pbkdf2 -out secured.tar.gz |
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 36: | Line 36: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | ==== With password ==== | + | ====With password==== |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| − | openssl enc -d aes256 -in secured.tar.gz | tar xz -C target_dir | + | openssl enc -d -aes256 -in secured.tar.gz | tar xz -C target_dir |
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 07:45, 26 April 2019
Compression
.tar.gz
tar -zcvf /var/my-backup.tar.gz /home/rafa/
.tar.gz split with max size
tar cvzf - dir/ | split --bytes=200MB - sda1.backup.tar.gz.
tar cvzf - dir/ | split -b 200m - sda1.backup.tar.gz.
tar cvzf - /Applications/Install\ macOS\ Sierra.app/ | split -b 4294967295 - /Volumes/UNTITLED/install_macos_sierra.tgz.
.tar.gz exclude files
tar --exclude='./folder' --exclude='./upload/folder2' -zcvf /backup/filename.tgz .
tar --exclude='./backup' -zcvf - . | split --bytes=1024MB - backup/content.sdf.backup.tar.gz.
With password
tar -czf - * | openssl enc -e -aes256 -pbkdf2 -out secured.tar.gz
Extraction
View .tar.gz contents
tar -ztvf file.tar.gz
Extract .tar.gz
tar -zxvf archive.tar.gz
With password
openssl enc -d -aes256 -in secured.tar.gz | tar xz -C target_dir
Extract .txz
tar Jxvf file.txz
Extract .tar.xz
tar -xvf file.tar.xz
Extract .tar.bz2
tar -jtvf file.tar.bz2
Extract all files in subdirectories
DEST=<Destination Folder>
SRC=<Src Folder>
find $SRC -name "*.tar.gz" -or -name "*.tgz" -exec tar xzvvf -C $DEST {} \;
Note: .gz files are decompressed with gunzip file.gz