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_addressEnter your password or use your SSH key when prompted to log in.
Navigate to the File Directory
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/directoryYou can list the files in the current directory to confirm the
archive is present using the ls command.
lsExtract 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.gzReplace 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.
lsYou can now proceed to use or configure the extracted files on your
Ubuntu server. When finished, type exit to close the SSH
connection.