zip files archive a number of files into a single file
zip compress the files so the archive takes less space
zip/tmp/backup-notes.zipwords.txtwords2.txtls-l/tmp/-rw-rw-r--1useruser499ago2820:11backup-notes.zipzip-r/tmp/backup-dirs.zipdir1dir2# -r option must be used to include the files in the sub-directories
unzip
unzip - list, test and extract compressed files in a zip archive
# List archive files without extracting anything.unzip-l/tmp/backup-notes.zipArchive:/tmp/backup-notes.zipLengthDateTimeName----------------------------1282022-08-2819:27words.txt872022-08-2819:35words2.txt----------------2152files
tar
tar - creates an archive file from multiple files and directories, without compression by default
supports a vast range of compression algorithms
.tar and .gz files are more commonly used in Linux than zip files.
tar-cvfarchive.tarfile?.txtdir?# Create and compress the archive with gziptar-czfarchive.tar.gzfile1.txtfile2.txt# List archive contentstar-tvfarchive.tar-rw-rw-r--user/user62022-09-0300:16file1.txt-rw-rw-r--user/user72022-09-0300:16file2.txt-rw-rw-r--user/user82022-09-0300:16file3.txtdrwxrwxr-xuser/user02022-09-0300:11dir1/-rw-rw-r--user/user62022-09-0300:11dir1/file1.txtdrwxrwxr-xuser/user02022-09-0300:11dir2/-rw-rw-r--user/user72022-09-0300:11dir2/file2.txtdrwxrwxr-xuser/user02022-09-0300:11dir3/-rw-rw-r--user/user82022-09-0300:11dir3/file3.txt# Extract file from an archive in the current directorytar-xvfarchive.tar# Helptar--help [...]Compressionoptions:-a,--auto-compressusearchivesuffixtodeterminethecompressionprogram-I,--use-compress-program=PROGfilterthroughPROG (must accept-d)-j,--bzip2filterthearchivethroughbzip2-J,--xzfilterthearchivethroughxz--lzipfilterthearchivethroughlzip--lzmafilterthearchivethroughxz--lzopfilterthearchivethroughlzop--no-auto-compressdonotusearchivesuffixtodeterminethecompressionprogram-z,--gzip,--gunzip,--ungzipfilterthearchivethroughgzip--zstdfilterthearchivethroughzstd-Z,--compress,--uncompressfilterthearchivethroughcompress [...]
gzip
gzip - compress or uncompress single files
is most often used to compress text files, .tar archives, and web pages.
by default, it keeps the original file timestamp, mode, ownership, and name in the compressed file.
gzip-karchive.tar# -k to keep the original file# Check the compressed file dimension:-rw-rw-r--1useruser10240set300:16archive.tar-rw-rw-r--1useruser151set300:24archive.tar.gz# Decompress a file and keep the input file:gzip-dkarchive.tar.gzgunziparchive.tar.gz
Searching Commands
find
find - search for files in a directory hierarchy
a starting point for the search is necessary
find.-name'file*.txt'# . = current directory and subdirectories starting point./file1.txt./file2.txt./dir1/file1.txt./dir3/file3.txt./file3.txt./dir2/file2.txtfind.-iname'file*.txt'# -iname for case insensitive search