LinuxCommandLibrary

suspend

Enter system suspend (sleep) mode

TLDR

Suspend the current shell (useful for when you are in nested shells like su)

$ [bash] <Enter> suspend
copy

Continue from suspension if suspend was used in a non-nested shell (run this in a separate terminal)
$ pkill -CONT [bash]
copy

Force suspension even if this would lock you out of the system
$ suspend -f
copy

SYNOPSIS

systemctl suspend

PARAMETERS

No direct parameters for 'suspend' action.
    The suspend action itself, when invoked via systemctl, does not typically accept direct parameters. However, the systemctl command, which is used to trigger suspend, supports various global options:
--force: Force the action, even if it's considered unsafe or normally prevented. Use with caution.
--no-block: Do not wait for the operation to finish. The command will return immediately.
--no-wall: Do not send wall message before halting/rebooting/powering off.


DESCRIPTION

The suspend functionality in Linux refers to putting the system into a low-power state, typically Suspend-to-RAM (STR), also known as Sleep or Standby. In this state, the system powers down most components except RAM, where the current system state is preserved. This allows for a very quick resume (usually within seconds) back to the exact point where the system was suspended, consuming significantly less power than when running, but more than when hibernated or powered off.

While there isn't a single universal standalone suspend binary command for system-wide suspension across all Linux distributions (like ls or grep), the most common and recommended method in modern Linux systems utilizing systemd is to use the systemctl utility. Specifically, the command systemctl suspend triggers this power-saving mode. Older systems or those not using systemd might use tools like pm-suspend (part of pm-utils) or direct kernel interfaces.

The primary benefits of suspending are rapid startup and reduced power consumption, making it ideal for short breaks or closing a laptop lid. It's crucial to note that the system state is held in volatile RAM, so a complete power loss (e.g., battery depletion on a laptop) will result in loss of unsaved work.

CAVEATS

Requires Privileges: Initiating a system suspend typically requires root privileges (e.g., using sudo systemctl suspend).
Volatile State: The system state is stored in RAM. If power is lost (e.g., battery runs out), all unsaved work will be lost. This is a key difference from hibernation.
Potential for Failure: Certain processes, open network connections, or mounted filesystems (especially NFS or CIFS) might prevent a clean suspend. Services can also block suspend via inhibitions.
Hardware/Driver Issues: Suspend and resume functionality heavily relies on proper hardware and driver support. Issues with graphics drivers, USB devices, or other peripherals can sometimes prevent successful suspend or cause instability upon resume.
Shell Built-in vs. System Suspend: Be aware that some shells (like bash or zsh) have a built-in suspend command, which, when executed directly, suspends the current shell or foreground job, not the entire system. This is invoked by Ctrl+Z and managed by fg/bg.

THE <CODE>SUSPEND</CODE> SHELL BUILT-IN

The suspend Shell Built-in
It is important to distinguish the system-wide suspend functionality from the suspend command that is a built-in feature of many interactive shells, such as bash or zsh. When you type suspend in a shell, it attempts to suspend the current shell instance or the foreground job. This is equivalent to pressing Ctrl+Z. This action puts the shell or job into a stopped state, allowing you to use job control commands like fg (foreground) or bg (background) to resume or continue its execution. This built-in command does not affect the overall system's power state.

HISTORY

The ability to suspend a Linux system has evolved significantly over time. Initially, direct interaction with ACPI (Advanced Configuration and Power Interface) interfaces or legacy tools like apm (Advanced Power Management) were used. With the advent of more sophisticated power management, utilities like pm-utils, which included the pm-suspend command, became standard for handling suspend and hibernate functionality across various hardware configurations.

With the widespread adoption of systemd as the init system for most major Linux distributions, power management was integrated into systemd's functionalities. The systemd-suspend.service unit, triggered by the systemctl suspend command, became the modern and recommended way to manage system suspend. This integration provides a more robust and unified approach to power management, allowing services to react to suspend events and ensure a cleaner system state before entering the low-power mode.

SEE ALSO

systemctl(1), systemd(1), hibernate(8), reboot(8), shutdown(8), pm-suspend(8), fg(1), bg(1)

Copied to clipboard