Commands.page Logo

How to Extract Tar.gz Via SSH on Ubuntu Server

This article outlines the steps to unpack a compressed tar.gz archive directly on a remote Ubuntu machine using Secure Shell. It covers connecting to the server, locating the file, and running the extraction command to access your data immediately without downloading it to your local computer.

Connect to the Remote Server

Open your terminal on your local machine and establish an SSH connection to your Ubuntu server. Replace username with your actual user account and ip_address with the server’s IP address.

ssh username@ip_address

Enter your password or use your SSH key when prompted to log in.

Once logged in, change the directory to the location where the tar.gz file is stored. Use the cd command followed by the path.

cd /path/to/directory

You can list the files in the current directory to confirm the archive is present using the ls command.

ls

Extract the Tar.gz File

Run the tar command to extract the archive. The -x flag extracts files, -z decompresses gzip files, -v shows the progress, and -f specifies the filename.

tar -xzvf filename.tar.gz

Replace filename.tar.gz with the actual name of your archive. The files will unpack into the current directory.

Verify the Extraction

List the directory contents again to ensure the files have been extracted successfully.

ls

You can now proceed to use or configure the extracted files on your Ubuntu server. When finished, type exit to close the SSH connection.