6

How can I access this repository from terminal? It is the access to my google drive account from the desktop. Is there a way to make it accessible from \home

enter image description here

graham
  • 10,436

4 Answers4

10

You should use rclone (use apt install rclone to install it) and configure it for "Google Drive". Detailed information on how to configure rclone for "Google Drive" is given at https://rclone.org/drive/.

You can follow the recommendation at the step Google Application Client Id. Check out Making your own client_id, it provides a great guide for setting up client_id (as of June 2023).

Once you've completed the configuration, mount your "Google Drive" with the following command:

rclone -v --vfs-cache-mode writes mount "$rdrive": "$ldrive"

Here $rdrive is the remote: string configured in the reference given above; $ldrive is a local empty directory (like ~/MyGoogleDrive). You should, mkdir "$ldrive" first as rclone won't do that itself. Once executed, the mount command will not return, which means it is working correctly. The specified remote: will be mounted until you press Ctrl+C.


Similarly you can configure and use "Microsoft One Drive" and many other cloud providers. A complete list of the cloud providers supported by rclone can be found at https://rclone.org/.

FedKad
  • 10,515
  • It says Error: unknown flag: --vfs-cache-mode – notaprogrammertoday Apr 17 '21 at 16:37
  • What is your version of rclone? See: http://manpages.ubuntu.com/manpages/focal/man1/rclone.1.html – FedKad Apr 17 '21 at 17:41
  • @FedKad it seems that you have typo in rclone command, it should be rclone mount --daemon --vfs-cache-mode writes my_rclone_gdrive: /home/user/my_fs_dir_for_gdrive – Divelix Feb 19 '22 at 12:19
  • @Divelix If you are talking about the --daemon option, I deliberately used the "foreground mode" of rclone, so that it will be terminated via Ctrl+C. – FedKad Feb 19 '22 at 12:53
  • @FedKad, sorry, I meant that when I used flags (-v --vfs-cache-mode writes) before mount, it didn't work for me. There's nothing about --daemon, I just added it by mistake. – Divelix Feb 19 '22 at 13:05
  • @FedKad, I just tried again and it works fine as you wrote it too. Probably my problem was in something else at first try. – Divelix Feb 19 '22 at 13:12
  • that seems to be the way out, indeed. – Rubem Pacelli Dec 05 '22 at 14:47
4

Such Google Drive location is placed in directory like

/run/user/$UID/gvfs/google-drive:host=gmail.com,user=username/

But it is useless because of crypted file names like 1N-QaxXtI-N3PimnrqloO3uNl7Thq3PUB.

N0rbert
  • 99,918
  • Is there a way to have an alias in /home It is not that usefull to access run/user/$UID/gvfs/google-drive:host=gmail.com,user=username/ – notaprogrammertoday Apr 17 '21 at 15:52
  • You can mount this folder manually and then create symlink for it. Or use rclone as stated in other answer. But my recommendation is to use DropBox with its great integration to file-managers. Google does not release official normal Drive client for linux. – N0rbert Apr 17 '21 at 16:08
0

As far as I know, the synchronism by GNOME is done via gio, which has the path google-drive://username@gmail.com/ on a GUI file manager, but it is actually stored at /run/user/... on your GNU/Linux filesystem.

GIO (Gnome Input/Output) seems to not be optimized to work on terminal. You can even ls through your directories by using gio list -d google-drive://username@gmail.com/path/to/directory, but it does not seem possible to make more sophisticated stuffs, such as symlink...

In nutshell, if you are like me and have a full-based terminal workflow, then maybe I had better to use rclone, which is a terminal program that allows you to get a full control of your files from terminal. It is a little bit trickier to set this up, but it is much more powerful.

0

Based on @FedKad solution above. Posting a new answer because I exceeded the limit for a comment.

Steps:

  1. I installed rclone in Ubuntu (sudo apt install rclone)
  2. Followed the instructions at https://rclone.org/drive/ (choosing Google Drive, option 13, and the rest mostly defaults),
  3. Got redirected to my Google account, signed in and got authenticated, and finished the rest of the setup.

To mount was a bit more trickier but after seeing this issue https://forum.rclone.org/t/what-does-poll-interval-is-not-supported-by-this-remote-mean/4771 I opted to dump all the other flags and just did

rclone mount "GoogleDrive:" "NameOfMyDriveOnMyLocalMachine"

and it worked wonders.

I am now able to navigate via the Terminal with proper file and directory names.

Do note that you must first create "NameOfMyDriveOnMyLocalMachine" and that's where you'll find your drive files. Also note that the colon after your drive vendor name is necessary inside the quotes.

As stated above, leave the command above hanging, and work from another terminal in a tab or new application.

Hope that simplifies @FedKad's solution above.