Linux

How to Tar/Untar Files and Folders In Linux. Manage Folders

In Linux from the command line, you can tar-untar, or as most people will know zip and unzip files and directories. This is useful if you want to, for example, move a WordPress site to a different account. Or, for this guide, let’s assume you want to move the whole public_html folder under the user test to a user on the same NVMe VPS that has the username transfer.

First, let’s get to the user’s home directory. Using the CD command;

cd /home/test

Then let’s tar or zip the public_html folder and place the file that’s created in the new user home directory.

tar /home/test/public_html /home/transfer/

Once complete you can then move the new user home directory

cd /home/transfer

List the directory contents

ls

You should see the public_html.tar.gz file in the directory. Let’s untar-unzip the file overwriting any files already in the directory.

Extract .tar.gz file

tar -xvf public_html.tar.gz

That account should now have an exact copy of the public_html folder from the user test. That’s it. In this guide, you have learnt the Windows equivalent of zipping a folder into a zip file and then unzipping the folder in a new directory.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button