Geody Labs


# Main Index: Debian Linux Magic Spells Cheat Sheet (one liners, how to, tips and tricks)

# Archiving and Compression

Install archivers:
apt-get install bzip2
apt-get install zip unzip
apt-get install zoo # requires a contrib non-free repository
apt-get install lha # requires a contrib non-free repository
apt-get install rar # requires a contrib non-free repository
apt-get install unp

Archiving with ISO:
dd if=/dev/dvd of=dvd.iso # Create an ISO file from a DVD
dd if=/dev/cdrom of=cd.iso # Create an ISO file from a CD-ROM
dd if=/dev/scd0 of=cd.iso # Create an ISO file from a SCSI CD-ROM
mkisofs -o /PATH_DEST/cd.iso /PATH_SOURCE/ # Create an ISO file from a directory tree

Archiving with TAR:
tar -cvf file.tar text.txt # archive text.txt as file.tar
tar -cvf file.tar *.txt # archive all files ending with ".txt" in the current directory as file.tar
tar -xvf file.tar # extract all files from file.tar in the current directory

Compressed TAR archives (tarball):
# Use tar to compress a directory tree into a single file, and gzip or bzip2 to compress each file into a directory tree
tar -cjvf file.tbz text.txt # TAR+BZIP2 compression (canonical extension .tbz or .tar.bz2)
tar -xjvf file.tbz # extract all files from a TAR+BZIP2 compressed archive
tar -czvf file.tgz text.txt # TAR+GZIP compression (canonical extension .tgz or .tar.gz)
tar -xzvf file.tgz # extract all files from a TAR+GZIP compressed archive

Compression with GZIP:
gzip -9vk text.txt # compress text.txt as text.txt.gz using highest compression and verbose output, keeping the original uncompressed file
gzip -9v text.txt > file.gz # compress text.txt as file.gz using highest compression and verbose output, keeping the original uncompressed file
gzip -9v text.txt # compress text.txt as text.txt.gz using highest compression and verbose output, deleting the original uncompressed file 
gzip -r9v file.txt file2 file3 /home/docs # compress file.txt file2 file3 and every file in /home/docs (if such directory exists), deleting the original uncompressed files
gzip -l file.gz # show the content of the compressed file
gzip -dk file.gz # extract the content of file.gz in the current directory and keep the compressed file (file.gz)
gzip -d file.gz # extract the content of file.gz in the current directory and delete the compressed file (file.gz)

Compression with BZIP2:
bzip2 text.txt # compress text.txt as text.txt.bz2
bunzip2 file.bz2 # extract the content of file.bz2 into the current directory

Compression with ZIP:
zip file.zip file.txt # add file.txt to the compressed file file.zip (if it doesn't exist, it will created)
zip -r file.zip /home/docs # compress the whole content of the directory /home/docs into file.zip
zip -r filename.zip file.txt file2 file3 /home/docs # compress file.txt file2 file3 and the content of /home/docs (if such directory exists) into file.zip
zip -F brokenfile.zip # try to fix a broken zipped file (use -FF to try even harder)
unzip file.zip # extract the content of file.zip into the current directory
unzip file.zip -d PATH_DEST # extract the content of file.zip into the specified directory

Encrypted Compression with ZIP:
# Note that Zip encryption is not very strong
zip -e file.zip file.txt # encrypt file.txt into file.zip prompting for a password
zip -P PASSWORD FILE.zip file.txt # encrypt file.txt into file.zip with the given PASSWORD (beware of shoulder surfing)
unzip file.zip # extract the content of file.zip and prompt for password if encrypted
unzip -P PASSWORD file.zip # unencrypt and extract the content of file.zip with given PASSWORD (beware of shoulder surfing)

Compression with LHa (LHarc) / LZH:
lha a file.lha text.txt # compress text.txt as file.lha (or add text.txt to an already existing file.lha compressed archive)
lha e file.lha # extract the content of file.lha into the current directory (will prompt for existing files)

Compression with ZOO:
zoo a file.zoo text.txt # compress text.txt as file.zoo (or add text.txt to an already existing file.zoo compressed archive)
zoo e file.zoo # extract the content of file.zoo into the current directory (will ignore existing files)

Compression with RAR (RAR is shareware):
rar a file.rar text.txt # compress text.txt as file.rar (or add text.txt to an already existing file.rar compressed archive)
rar e file.rar # extract the content of file.rar into the current directory (will prompt for existing files)

Unpack most common formats:
unp FILE # Supported extensions and formats: tar[.gz,.bz2], gz, bz2, Z, ar/deb, rpm, shar, rar, arj, zip, LHa, cab, ace, tnef, uu (mail, news), mime, hqx, sea, zoo, pmd, cpio, afio, lzop




Please DONATE to support the development of Free and Open Source Software (PayPal, Credit Card, Bitcoin, Ether)

Page issued on 25-Sep-2022 05:14 GMT
Copyright (c) 2022 Geody - Legal notices: copyright, privacy policy, disclaimer