How can I access my Google Drive via the command line with Gnome Online Accounts?
Solution 1
First, you need to mount the remote filesystem, which can be done by clicking on your email in Gnome's file explorer. You can use the gvfs
commands Tony mentioned (now deprecated as they moved into gio
) to interact with the mounted Google Drive filesystem.
If you try to open the folder from the file explorer in your terminal, you will notice that the working directory is /run/user/...
and all the filenames and directory names are unreadable. I do not advise trying to manipulate the files through this path. Instead, the files can be accessed and manipulated through gio
via readable URLs once it is mounted; for example
google-drive://[email protected]/Directory%20One/File%20one.png
Some useful commands:
-
gio list [file_url] -ud
: likels
, shows the full readable urls for the directory or glob within your Google Drive -
gio copy [source local filepath or Google Drive file url] [destination local filepath or Google Drive file url]
: likecp
, and can be used to move files between your Google Drive and your disk. -
gio open [file_url]
: opens the file from your Google Drive in the default application
Note that accessing them either through the file explorer or this method is done just in time over the network rather than downloading your whole Google Drive to your disk. Because of this, repetitively accessing files can be slow.
It may be useful to:
- temporarily
gio copy
the files in question that you want to diff - compare them locally
- make any necessary changes to either drive through
gio
- remove the temporary files
Solution 2
I don't have a direct answer, and insufficient reputation to comment, but What is the difference between gvfs commands and common commands like cat, ls, cp? lists gvfs series commands for such situations.
Having said that, I'm using 16.04 and even gvfs-ls /run/users/xxxx/gvfs/google-drive:host=gmail.com,user=yyyy shows character lists in place of file and directory data.
Nautilus is able to interpret the character lists, but Calibre, OpenOffice and no doubt others cannot.
Related videos on Youtube
Ramon Suarez
Coworking, entrepreneurship, learning to code; Betacowork Coworking Brussels founder; The Coworking Handbook author; startups.be founder; chocolate ambassador; Brussels lover. My Twitter account is @ramonsuarez
Updated on September 18, 2022Comments
-
Ramon Suarez almost 2 years
I have two Google Drive accounts connected via Gnome Online Accounts (GOA). I can browse them with nautilus but I have not found how to access them through the command line. Shouldn't they be mounted somewhere even if they are network shares?
My objective is to be able to diff both to see if there are any files missing, as I'm copying files between them. I've tried copying the files directly via nautilus, but it stalls and whenever the window is not greyed out the message is that it will take months.
Thanks for your help
-
Ramon Suarez about 7 yearsTried navigating to
/run/user/<uid>/gvfs
as Christophe / Bladecoder suggested: twitter.com/BladeCoder/status/860453465180565505. All I can see is errors and hashes (not the name of the files), it takes a long time, no way to cd. -
BladeCoder about 7 yearsTry installing a modern FUSE driver for Google Drive, like: github.com/astrada/google-drive-ocamlfuse
-
Ramon Suarez about 7 yearsIt only works up to 16.04. Getting a lot of duplicates with insync + mover
-
Ramon Suarez about 7 years... And cleaning up all those duplicates when I have over 90GB of files is going to be hell...
-
-
novwhisky over 2 yearsFantastic answer! Is there any way to use these to mimic a local filesystem for adding as a media source in apps like Kodi?
-
Admin about 2 yearsIn fact, it is already mounted when you add it through Gnome Online Accounts; however, it is a little weird because it is done through gvfs. Not really sure on the intricacies here, but I have had similar bad experiences messing with it when trying to mount archives. The best answer in terms of mounting it goes to puffy. If you set up rclone for your Google Drive, you can then mount it property in a sane location with sane permissions with
rclone mount
. I've done this for Backblaze B2 and for Sharepoint for work. Truly an amazing tool.