Archiving and Searching Files
Archiving Commands
zip
zip- package and compress files into archiveszip files archive a number of files into a single file
zip compress the files so the archive takes less space
zip /tmp/backup-notes.zip words.txt words2.txt
ls -l /tmp/
-rw-rw-r-- 1 user user 499 ago 28 20:11 backup-notes.zip
zip -r /tmp/backup-dirs.zip dir1 dir2
# -r option must be used to include the files in the sub-directoriesunzip
unzip- list, test and extract compressed files in a zip archive
# List archive files without extracting anything.
unzip -l /tmp/backup-notes.zip
Archive: /tmp/backup-notes.zip
Length Date Time Name
--------- ---------- ----- ----
128 2022-08-28 19:27 words.txt
87 2022-08-28 19:35 words2.txt
--------- -------
215 2 filestar
tar- creates an archive file from multiple files and directories, without compression by defaultsupports a vast range of compression algorithms
.tarand.gzfiles are more commonly used in Linux than zip files.
gzip
gzip- compress or uncompress single filesis 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.
Searching Commands
find
find- search for files in a directory hierarchya starting point for the search is necessary
locate
locate- find files by name, using a databaseit can be faster than
findcommand
which
which- locate a commandit displays the full path of the command with its associated name
whereis
whereis- locate the binary, source code and manual page for a command
Last updated
Was this helpful?