How to Untar a File Without SSH Access
You have a tar.gz package that contains a lot of files for your website. Your web host doesn’t provide an easy option for you to untar it once it’s on the server. Uploading all of the files one by one is a very time consuming process and should be avoided if possible.
You could request SSH (secure shell) access from your hosting provider, which can be dangerous for those who do not understand exactly what they are doing. Also, some hosts will not give you this access. As a workaround, you can use this trick:
- Open your favorite text editor and create a new file with the following code:
<?php system("tar -zxvf my_tar_package.tar.gz") ?> - When entering the above code, replace “my_tar_package.tar.gz” with the name of your tar.gz file and name the file my_tar_gz.php.
- Upload both the tar.gz archive and the newly created my_tar_gz.php to the directory in which you want to unpack the files.
- Navigate to my_tar_gz.php in a web browser. The script will run and the tar.gz files will be unpacked with the quickness.
I used this solution on a site today and if I had to upload all of the files one at a time, it could have easily taken an hour or more. Instead, it was done in less than 5 minutes.
Hope it helps!
