• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

zip Command Examples in Linux

by admin

The zip command is another compression utility, but unlike gzip, xz, and bzip2, it also features file archiving functionality. In fact, zip is a combination of an older compression utility called compress and the tar archive command. Files compressed with zip frequently have the .zip file extension. The zip command has several options.

Option Used To
-d Delete entries in a .zip archive.
-e Encrypt the contents of an archive.
-F Fix a corrupted .zip archive.
-r Enable recursion.
-T Perform an integrity check on the archive file.

Syntax

The syntax of the zip command is:

# zip [options] [file names]

zip Command Examples

1. Add files/directories to a specific archive ([r]ecursively):

# zip -r path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

2. Remove files/directories from a specific archive ([d]elete):

# zip -d path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

3. Archive files/directories e[x]cluding specified ones:

# zip -r path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ... -x path/to/excluded_files_or_directories

4. Archive files/directories with a specific compression level (`0` – the lowest, `9` – the highest):

# zip -r -0-9 path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

5. Create an [e]ncrypted archive with a specific password:

# zip -r -e path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

6. Archive files/directories to a multi-part [s]plit zip file (e.g. 3 GB parts):

# zip -r -s 3g path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

7. Print a specific archive contents:

# zip -sf path/to/compressed.zip

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to Permanently set the ethtool settings in CentOS/RHEL 6
  2. How to calculate recommended value of vm.min_free_kbytes Kernel Tuning Parameter
  3. authconfig Command Examples in Linux
  4. Apache HTTP server – most commonly used containers (special configuration directives)
  5. “Read-only locking type set. Write locks are prohibited. Can’t get lock for [volume group]” – error during lvextend
  6. btrfs inspect-internal Command Examples in Linux
  7. chacl Command Examples in Linux
  8. CentOS / RHEL 5 : How to Configure kdump
  9. renice: command not found
  10. virt-install: Command Not Found

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright