🧠 SynapseNotes

Search

Search IconIcon to open search

Zip all files including hidden in Linux

Last updated Jul 24, 2023

# Objective

To compress an entire folder and files inside including hidden on Linux, recursively.

# Command

You can use the tar command to create a compressed archive of all files and folders in a directory, including hidden files and folders, recursively. To do this, you can use the following command:

1
tar -czvf archive_name.tar.gz /path/to/directory

# Explanation:

This command will create a compressed tar archive (with gzip compression) named “archive_name.tar.gz” in the current working directory, containing all files and subdirectories, including hidden files and directories, from the specified directory.

# Example

For example, to compress all files and folders, including hidden ones, in the “/home/user/documents” directory, you can use the following command:

1
tar -czvf my_documents.tar.gz /home/user/documents

This will create a compressed archive named “my_documents.tar.gz” in the current working directory, containing all files and directories from the “/home/user/documents” directory.

# Other sources

https://linuxize.com/post/how-to-create-tar-gz-file/