Uncategories

Linux – How to Compress and Extract Files Using the tar Command

To compress:

tar -czvf name-of-archive.tar.gz /path/to/directory-or-file

  • c: Create an archive.
  • z: Compress the archive with gzip.
  • v: Display progress in the terminal while creating the archive, also known as “verbose” mode. The v is always optional in these commands, but it’s helpful.
  • f: Allows you to specify the filename of the archive.

To compress directory:

tar -czvf archive.tar.gz /usr/local/folder

To compress multiple file:

tar -czvf archive.tar.gz /home/ubuntu/Downloads /usr/local/stuff /home/ubuntu/Documents/notes.txt

To extract:

tar -xzvf archive.tar.gz

More: https://www.howtogeek.com/248780/how-to-compress-and-extract-files-using-the-tar-command-on-linux/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s