Linux Screenshot CLI
Use scrot or gnome-screenshot to capture screenshots on Linux. This is a Linux alternative to macOS Peekaboo.
Setup
Install scrot (recommended):
sudo apt-get install -y scrot
Or install gnome-screenshot:
sudo apt-get install -y gnome-screenshot
Or install maim (more features):
sudo apt-get install -y maim slop
Capture Screenshots with scrot
Full screen
scrot ~/Pictures/screenshot-%Y%m%d-%H%M%S.png
Full screen with delay (3 seconds)
scrot -d 3 ~/Pictures/screenshot-%Y%m%d-%H%M%S.png
Select region/window interactively
scrot -s ~/Pictures/screenshot-%Y%m%d-%H%M%S.png
Current focused window
scrot -u ~/Pictures/window-%Y%m%d-%H%M%S.png
Include window border
scrot -ub ~/Pictures/window-%Y%m%d-%H%M%S.png
Capture and copy to clipboard
scrot -s - | xclip -selection clipboard -t image/png
Set quality (JPEG)
scrot -q 90 ~/Pictures/screenshot.jpg
Capture Screenshots with gnome-screenshot
Full screen
gnome-screenshot -f ~/Pictures/screenshot.png
With delay
gnome-screenshot -d 3 -f ~/Pictures/screenshot.png
Select area
gnome-screenshot -a -f ~/Pictures/screenshot.png
Current window
gnome-screenshot -w -f ~/Pictures/screenshot.png
To clipboard
gnome-screenshot -c
Capture Screenshots with maim
Full screen
maim ~/Pictures/screenshot.png
Select region
maim -s ~/Pictures/screenshot.png
Select window
maim -i $(xdotool getactivewindow) ~/Pictures/window.png
Specific region (x,y,width,height)
maim -g 100x100+500+300 ~/Pictures/region.png
High quality
maim -m 10 ~/Pictures/screenshot.png
Screen Recording
Record screen with ffmpeg
ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -c:v libx264 -preset ultrafast output.mp4
Stop recording
Press q in the terminal or Ctrl+C.
Record with audio
ffmpeg -video_size 1920x1080 -framerate 30 -f x11grab -i :0.0 -f pulse -i default -c:v libx264 -preset ultrafast -c:a aac output.mp4
Notes
- Linux-only (alternative to macOS Peekaboo).
scrotis lightweight and widely available.maimoffers more advanced features.gnome-screenshotintegrates well with GNOME desktop.- For Wayland, use
griminstead ofscrot.
