LinuxCommandLibrary

gdrive

Manage Google Drive files from the command line

TLDR

Upload a local path to the parent folder with the specified ID

$ gdrive upload [[-p|--parent]] [id] [path/to/file_or_folder]
copy

Download file or directory by ID to current directory
$ gdrive download [id]
copy

Download to a given local path by its ID
$ gdrive download --path [path/to/folder] [id]
copy

Create a new revision of an ID using a given file or folder
$ gdrive update [id] [path/to/file_or_folder]
copy

SYNOPSIS

gdrive command [options] [arguments]

PARAMETERS

list
    Lists files and folders in Google Drive.

upload file
    Uploads a local file to Google Drive.

download file ID
    Downloads a file from Google Drive using its ID.

delete file ID
    Deletes a file from Google Drive using its ID.

mkdir folder name
    Creates a new folder in Google Drive.

share file ID
    Shares a file or folder with specified permissions.

info file ID
    Displays detailed information about a specific file in Drive.

about
    Displays information about your Google Drive account (storage used, etc.).

auth
    Initializes the authentication process with Google Drive.

-h, --help
    Shows help message and exit.

-v, --version
    Shows the version of the gdrive command.

DESCRIPTION

The gdrive command is a command-line interface for interacting with Google Drive. It allows users to perform various operations such as uploading, downloading, listing files, creating folders, sharing files, and managing permissions directly from the Linux terminal.

This is particularly useful for automating backups, scripting file management tasks, and integrating Google Drive with other command-line tools. It interacts with the Google Drive API, and thus requires appropriate authentication and authorization setup initially. This involves obtaining credentials from Google Cloud Console and authorizing the application via OAuth 2.0 flow.

Note that many third-party implementations and wrappers exist, so it's vital to use a trusted and verified version (e.g., from a reputable GitHub repository).

CAVEATS

Authentication requires a web browser for the initial OAuth flow. Ensure you have a GUI available, or you're using a headless server configuration with appropriate port forwarding.

Deletion is permanent by default; there may be no trash recovery depending on the implementation.

AUTHENTICATION

Proper authentication is crucial. When you first use the command, you'll be prompted to authenticate through your web browser. The command will store your authentication credentials locally (usually in a hidden directory) so it can access your Google Drive without requiring you to log in every time. It is important to protect those credentials.

RATE LIMITS

Google Drive API enforces rate limits. Be aware that frequent operations may trigger API limits, resulting in temporary access restrictions. Consider implementing delays or batching operations in your scripts to avoid exceeding these limits.

FILE IDS

Many commands require a "file ID" instead of the file name. You can obtain file IDs by using the gdrive list command.

HISTORY

The 'gdrive' command has evolved over time, often as independent open-source projects developed to provide command-line access to Google Drive. Its usage is typically driven by the need for automation and scripting around Google Drive's file management capabilities. Early versions often had limitations in functionality or security, but modern implementations strive for a more robust and secure experience.

SEE ALSO

rsync(1), curl(1), wget(1)

Copied to clipboard