LinuxCommandLibrary

gio

Access virtual file systems

TLDR

Open a file with the default application (e.g. PDF, image)

$ gio open [path/to/file]
copy

List files in a directory
$ gio list [path/to/directory]
copy

Show information about a file
$ gio info [path/to/file]
copy

Copy a file
$ gio copy [path/to/source] [path/to/destination]
copy

Send a file to the trash (reversible)
$ gio trash [path/to/file]
copy

SYNOPSIS


gio COMMAND [OPTIONS] [ARGUMENTS...]

This utility executes various GIO operations. Common COMMANDs include cat, copy, info, list, mount, open, trash, and rename. Each COMMAND has its own specific options and arguments.

PARAMETERS

COMMAND
    Specifies the GIO operation to perform (e.g., cat, copy, list, mount, open, trash). Each command has its own specific options and arguments.

ARGUMENTS...
    Arguments specific to the chosen COMMAND, often including URIs or file paths.

-v, --version
    Display the GIO version information.

-h, --help
    Display a general help message or help for a specific COMMAND if provided (e.g., 'gio help mount').

--debug
    Enable debugging output (specific to some GIO contexts).

DESCRIPTION

gio is a versatile command-line utility part of the GLib library, providing access to GIO functionality. GIO is a modern, asynchronous I/O framework used primarily by GNOME and GTK applications. It abstracts various file systems, network locations (like FTP, HTTP, SFTP, SMB), and other URI schemes, allowing applications to interact with them uniformly.

The gio command acts as a wrapper, offering various subcommands to perform operations such as listing directory contents, copying/moving files, trashing, mounting, and managing MIME types, all using the GIO abstraction. This makes it a powerful tool for scripting and interacting with system resources in a consistent manner, regardless of the underlying protocol or location.

CAVEATS

  • gio commands primarily operate on URIs (Uniform Resource Identifiers). While local file paths work, they are internally converted to file:/// URIs.
  • The exact set of supported URI schemes depends on the installed GIO modules and backend providers (e.g., GVfs for desktop environments).
  • Errors are often related to permissions, network issues, or unsupported URI schemes.

URI ABSTRACTION

gio commands operate on URIs, allowing seamless interaction with various protocols like http://, ftp://, sftp://, smb://, nfs://, and file:// (for local files). This provides a consistent interface regardless of the storage backend.

INTEGRATION WITH DESKTOP ENVIRONMENTS

In desktop environments like GNOME or Cinnamon, gio leverages services like GVfs (GNOME Virtual File System) to manage mounts, network shares, and trash operations, often without requiring root privileges for common tasks.

ASYNCHRONOUS OPERATIONS

While the gio command-line utility executes synchronously, the underlying GIO library is designed for asynchronous operations, which is crucial for responsive GUI applications.

HISTORY

gio is part of the GIO library, which was introduced in GLib 2.16 (released around 2007) as a modern, asynchronous I/O framework. It was designed to replace older, less flexible I/O mechanisms within GNOME and GTK applications, offering a unified API for local and remote file systems. The gio command-line utility provides a direct way to interact with this framework, serving as a scripting interface to GIO functionality that applications utilize. Its development is tied to the evolution of GLib and the GNOME desktop environment.

SEE ALSO

gvfs-cat(1), gvfs-info(1), gvfs-mount(1), ls(1), cp(1)

Copied to clipboard