Expired How to download files from Google Drive to Linux Machine?

Status
Not open for further replies.

Vertigo

⍥????
Staff member
Administrator
This tutorial is outdated and doesn't work anymore.

You cannot download files from Google Drive directly on your Linux Machine using wget command. Which is a pain if you want to download your server files or any other file on your Linux Machine or VPS.

I am providing here a quick method to download the files directly using Terminal or Putty. This method will work for both small and large files.

A public download URL for files on Google Drive looks like this : https://drive.google.com/file/d/1yDhqEkXZPdq9Ln_ABD34_oUdNta0YUU/view
The highlighted yellow part in the above URL is the File ID of the file on the Google Drive. We will use this File ID in the download process.

Step 1: Login to your Linux Machine using Putty.
Step 2:
cd into some directory or folder where you want the file to be downloaded.
Step 3: Now enter below commands one by one to download the file from Google Drive. Make sure to replace the FILE_ID in first command with the actual ID of the file like shown above, and replace the FILE_NAME in second command with the name of the file (You can use any name, for example: serverfiles.zip).
Bash:
# Replace the FILE_ID with actual ID of the file. You can find the ID in google drive download link.
curl -c /tmp/cookies "https://drive.google.com/uc?export=download&id=FILE_ID" > /tmp/intermezzo.html

# Replace the FILE_NAME with any name you want (For example: serverfiles.zip). After the download is complete, your downloaded file name will be the name which you provided in this command.
curl -L -b /tmp/cookies "https://drive.google.com$(cat /tmp/intermezzo.html | grep -Po 'uc-download-link" [^>]* href="\K[^"]*' | sed 's/\&/\&/g')" > FILE_NAME
Step 4: Your file should be downloaded now. Check in current directory.


Note : If you get error Unknown command 'curl'. Then you need to install curl first.
Bash:
# For Debian/Ubuntu users
apt install curl

# For RHEL/CentOS users
yum install curl

Credits: This method is taken from Martin Pecka's answer on Stack Overflow website.
 
Last edited:
Status
Not open for further replies.
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock