Lock Your Screen from the Terminal (loginctl lock-session)
Use loginctl lock-session to lock the current desktop session, or lock-suspend to lock and suspend in one step.
01Command
$ loginctl lock-session02What it does
The command sends the session lock signal to whatever screen locker your desktop uses (GNOME Screensaver, KDE screen locker), so it behaves exactly like pressing Super+L. `loginctl lock-suspend` locks and then suspends the machine in one step — useful as a custom laptop-lid or keybinding action. On XFCE use `xflock4` instead, and `loginctl list-sessions` shows which sessions are active.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- loginctl(1) - Linux manual pageEvidence: loginctl lock-session activates the session lock, and lock-suspend locks before suspending; the desktop session's screen locker responds to the lock signal.
Last verified: 2026-09-18 · Category: System & Settings
06Related solutions
Generate a modern Ed25519 public/private key pair in ~/.ssh for authenticating to servers and Git platforms without passwords.
Add or remove read, write, and execute permission for the owner, group, or others using symbolic or octal modes.
Add a UFW rule to permit inbound traffic on a TCP or UDP port, such as SSH on port 22.