Linux Command for Uploading a Filoe in Google Drive
How to access your Google Drive business relationship from Linux command line using Gdrive
On this page
- Using Gdrive
- List contents
- Download and upload files
- Share files
- Show file info
- Conclusion
While Google Drive is no uncertainty one of the most popular (if not the almost pop) cloud storage services available today, what's actually sad is that there is no official Drive customer available for Linux. Merely that doesn't mean at that place are no alternatives - in fact the awesome Linux/open-source community has developed several unofficial Google Bulldoze clients, some of which nosotros've already discussed here at HowtoForge.
Expanding our coverage on such clients, in this article we will discuss some other tool, dubbed Gdrive. Please note that all the instructions and commands mentioned in this write-up have been tested on Ubuntu 16.04.
Gdrive
Gdrive is basically a tool that lets you admission your Google Drive account through the command line. Aye, that means yous need to run commands for whatsoever and every Drive operation that you want to perform. Just worry not, information technology'southward not at all difficult to use and the commands aren't difficult to recollect either.
Gdrive Download, Installation, and Setup
You can easily download and install Gdrive on your Linux box by heading to the tool's official GitHub page, and downloading the executable file for your organisation. For example, I downloaded a file named gdrive-linux-386 equally I work on a 32-bit Linux distribution.
One time downloaded, brand sure that the file has executable permissions. If not, grant it the permissions through the chmod control. For example, I used the post-obit command:
chmod +x gdrive-linux-386
Afterwards this, you demand to make certain that the tool is allowed to connect to your Google Drive business relationship. For this, you need to run the executable file with about statement. Hither'south the command:
./gdrive-linux-386 about
You will be asked to enter a verification code, which is obtained past heading to the url printed in the command's output and authenticating with the google account for the drive you want admission to. The following screenshots volition make the procedure articulate:
Clicking the 'Permit' button volition produce the required code on the spider web page itself. Afterwards the verification code is entered on the command line terminal, Gdrive will connect to your Google Drive account. For example, here is the complete output after I entered the code in my case:
Important annotation: The same authentication process will create a token file inside a binder - named .gdrive - located in your dwelling house directory. "Note that anyone with access to this file will likewise have access to your google bulldoze," the tool's official documentation says.
Using Gdrive
Hither are examples of some of the basic Google Bulldoze operations that yous can carry out using Gdrive. I am assuming that the Gdrive executable that yous download on your system is as well named gdrive-linux-386 and is kept in your electric current working directory.
List contents
To list the contents (files and directories) of your Google Drive, you can apply the post-obit command:
./gdrive-linux-386 list
If yous desire to limit the maximum number of files that can be displayed in the output (default is 30), you can add together the -m flag followed a number that represents the new maximum limit. For example:
./gdrive-linux-386 listing -1000 x
Y'all can also add a query for filtering the output based on your requirement. For example, If I only want specific files (say, that contain 'Gmail' in their proper noun) in the output, I can use the following command:
./gdrive-linux-386 list -m 10 --query "proper noun contains 'gmail'"
Hither's the output of the above command on my organisation:
Download and upload files
Given that Google Bulldoze is a cloud storage service, so needless to say that you'll want to employ Gdrive to upload and download files to/from your Bulldoze account. Here's how you can do these operations:
To upload a file, run the following command:
./gdrive-linux-386 upload [file-name]
To upload a file to a specific directory, use the post-obit command:
./gdrive-linux-386 upload --parent [dir ID] [filename]
The directory ID ([dir ID] in the command above) can exist obtained from the entry of that particular directory when yous listing your Drive contents using Gdrive. Advertisement
To create a new directory in your Google Drive, use the post-obit command:
./gdrive-linux-386 mkdir [directory-proper noun]
Of course, you can create a new directory and then apply its ID to upload a file to information technology.
Finally, you lot tin use the following command to download a file from your Google Drive account to your organization:
./gdrive-linux-386 download [file-name]
There are several flags that assist you with your download operations. For case, -f tells Gdrive to overwrite existing file of the same proper name (if any), -r tells the tool to download a directory recursively, and --delete makes sure the remote file gets deleted when download is successful. It'south worth mentioning that the last two flags also work with upload operations.
Gdrive also lets you share your Google Bulldoze files with others. For case, if you want to make a file readable to everyone, you lot can exercise it through the following command:
./gdrive-linux-386 share [file ID]
Of course, that'southward not what we always want. Mostly, nosotros share files with our friends or colleagues. So, for example, if you lot want to share a file with someone you know, you can practise so using the post-obit control:
./gdrive-linux-386 share [file ID] --blazon user --electronic mail [email add]
The above command will grant reader permission to your friend, whose email accost y'all have to provide in identify of [email add]. If y'all want to grant, say, writing or commenting permission, or even want to transfer the buying, then y'all'll accept to utilize the --role flag. Accepted values for this flag include 'owner', 'author', 'commenter', and 'reader'.
Here'southward an example of how I used this control to share a file with one of my friends as well equally grant write permission to them.
Show file info
Gdrive likewise lets you access information related to any of your Google Drive files. Hither's the command for it:
./gdrive-linux-386 info [file ID]
Here's an example:
For more Gdrive commands as well as details on how the tool works, head to the project's official GitHub page.
Conclusion
What I liked about Gdrive is the ease with which it tin be downloaded and installed, as well as the detailed documentation bachelor on the tool's GitHub project page. And not to mention the like shooting fish in a barrel-to-call up commands. However, on the flip side, the documentation itself says that "the electric current implementation is boring and uses a lot of retentiveness," significant there's a adept scope of improvement.
Suggested articles
This feature is simply bachelor to subscribers. Get your subscription here.
shipmanagnection93.blogspot.com
Source: https://www.howtoforge.com/tutorial/how-to-access-google-drive-from-linux-gdrive/
Post a Comment for "Linux Command for Uploading a Filoe in Google Drive"