know-how.dev

How to create tar.gz archive in linux or macos

3 years ago 860

Most Linux distros and macOS have tar program pre-installed by default, it can be used to create tar.gz archives. Command structure is next:

tar -czvf archive.tar.gz /path/to/file/or/dir

What these flags mean:

  • -c - instructs tar that we are going to create new archive;
  • -z - use gzip as compression method;
  • -f archive.tar.gz - specifies archive file name;
  • -v - enables verbose mode;
  • /path/to/file/or/dir - a list of files or directories to be included into archive, space-separated.