LinuxCommandLibrary

gnome-session-quit

Log out or shut down GNOME session

SYNOPSIS

gnome-session-quit [OPTIONS]

Common options:
    --logout
    --power-off
    --reboot
    --shutdown
    --suspend
    --force
    --no-prompt

PARAMETERS

--logout
    Initiates a logout of the current GNOME user session. This is the default action if no other action is specified.

--power-off
    Commands the system to power off completely.

--reboot
    Commands the system to restart.

--shutdown
    An alias for the --power-off option, also commanding the system to power off.

--suspend
    Instructs the system to enter a suspend (sleep) state.

--force
    Forces the specified action immediately, bypassing any blocking applications and the confirmation dialog.

--no-prompt
    Prevents the display of the graphical confirmation dialog, proceeding directly with the action.

DESCRIPTION

gnome-session-quit is a command-line utility used within the GNOME desktop environment to initiate various session termination actions. It allows users to log out of their current session, shut down the computer, reboot it, or suspend it. Unlike direct system commands (e.g., shutdown, reboot), gnome-session-quit interacts with the GNOME session manager and PolicyKit to gracefully handle application closures and ensure proper system state transitions. It typically presents a graphical confirmation dialog, giving applications a chance to save unsaved work. Options are available to bypass this prompt or forcefully terminate applications. This command is an integral part of the user experience, providing a consistent and user-friendly way to manage the session lifecycle.

CAVEATS

This command is designed for the GNOME desktop environment and relies on its session manager. It may not function correctly or at all in other desktop environments or if GNOME components are not running.
It uses D-Bus for communication with the session manager and underlying system services. If D-Bus is not operational, the command will fail.
System-wide actions like power-off, reboot, and suspend require appropriate privileges, typically handled by PolicyKit and systemd-logind. If these services are misconfigured or unavailable, these actions might fail or require root privileges.
Applications can potentially block the quit action until they are closed or the --force option is used.

INTERACTION WITH D-BUS AND POLICYKIT

gnome-session-quit does not directly execute power commands like shutdown or reboot. Instead, it communicates with the GNOME session manager (often gnome-session) via D-Bus. The session manager then, in turn, interacts with underlying system services like systemd-logind (using PolicyKit for privilege escalation if needed) to perform the actual system-wide power operations. This indirect method ensures proper authorization, integration with system services, and graceful handling of active sessions.

GRAPHICAL USER INTERFACE (GUI) VS. COMMAND LINE

While gnome-session-quit is a command-line tool, its primary design intent is often to back the graphical "Log Out", "Shut Down", or "Restart" options found in the GNOME desktop's user menu. When invoked without --no-prompt or --force, it typically displays the same graphical dialog box seen when initiating a quit action through the GUI. This consistency ensures a unified user experience regardless of the invocation method.

HISTORY

The gnome-session-quit command has been a staple of the GNOME desktop environment since its early versions, evolving alongside the desktop itself. Initially, its functionality might have been more directly tied to X-server termination. Over time, as Linux systems adopted systemd and its logind component, the command's role shifted to primarily interact with the GNOME session manager, which then delegates the actual system-level power operations to logind via D-Bus and PolicyKit. This layered approach ensures consistency, proper privilege management, and integration with modern Linux system architecture, providing a robust and secure way to manage the user's session lifecycle.

SEE ALSO

Copied to clipboard