Table of Contents >> Show >> Hide
- Before You Start: Are You Using X11 or Wayland?
- Method 1: Record the Screen with FFmpeg on X11
- Method 2: Record Screen and Audio with FFmpeg
- Method 3: Record Wayland Sessions with wf-recorder
- Method 4: Use GStreamer from the Command Line
- Method 5: Configure GNOME’s Built-In Screen Recorder from the Terminal
- Best FFmpeg Settings for Quality and Performance
- How to Stop Recordings Cleanly
- Common Problems and Fixes
- Practical Command Examples
- Command-Line Screen Recording Tips from Real Experience
- Conclusion
There are two kinds of Linux users: the ones who record their screen with a friendly button that says “Start Recording,” and the ones who open a terminal, type one command, and feel like they just launched a small satellite. This guide is for the second group, but do not worry if you are new to the command line. Recording your screen from the Linux terminal is not black magic. It is mostly about choosing the right tool, knowing whether your desktop session uses X11 or Wayland, and saving the output in a format that does not make your video editor cough dramatically.
Whether you are making a tutorial, capturing a bug report, documenting a server workflow, recording gameplay, or proving to a coworker that “yes, the button really did disappear,” Linux gives you several reliable command-line screen recording options. The most popular tools include FFmpeg, wf-recorder, GStreamer, and built-in desktop tools that can be controlled or configured from the terminal.
This article explains how to record your Linux screen from the command line using practical examples. You will learn how to capture the full desktop, record a selected region, include microphone or system audio, optimize quality, reduce lag, and troubleshoot common problems. No wizard robe required, although a comfortable hoodie does improve terminal confidence by at least 12%.
Before You Start: Are You Using X11 or Wayland?
The first thing to check is your display server. On Linux, screen recording commands behave differently depending on whether your desktop session is running on X11 or Wayland. X11 is older, very flexible, and easy for tools like FFmpeg to capture directly. Wayland is newer, more secure, and often requires screen capture through portals, PipeWire, or compositor-specific tools.
Run this command:
If the result is:
x11: You can usually use FFmpeg withx11grab.wayland: Use tools such aswf-recorder, OBS with PipeWire, GNOME’s built-in recorder, or compositor-friendly solutions.
This matters because many “why is my recording black?” mysteries begin with someone trying to use an X11-only command on Wayland. Linux will let you try, because Linux believes in personal growth through mild suffering.
Method 1: Record the Screen with FFmpeg on X11
FFmpeg is the Swiss Army knife of multimedia. It can convert files, stream video, extract audio, resize clips, encode almost anything, and, yes, record your Linux screen from the command line. On X11, FFmpeg uses the x11grab input device to capture the display.
Install FFmpeg
On Ubuntu, Debian, or Linux Mint:
On Fedora:
On Arch Linux or Manjaro:
Find Your Screen Resolution
Before recording, check your current display size:
You might see something like:
That means your screen size is 1920x1080. You will use that value in the FFmpeg command.
Record the Full Screen
Here is a basic full-screen recording command for X11:
Here is what each part means:
-video_size 1920x1080tells FFmpeg the capture size.-framerate 30records at 30 frames per second.-f x11grabselects the X11 screen capture input.-i :0.0captures display:0.0, which is the usual desktop display.output.mp4is the saved video file.
To stop recording, press Ctrl+C in the terminal. FFmpeg will finalize the file. Do not close the terminal window like a movie villain cutting the power; let FFmpeg finish properly so your video does not become a digital pancake.
Record a Specific Area of the Screen
To record only part of the screen, add an offset after the display value. For example:
This records a 1280x720 rectangle starting 100 pixels from the left and 80 pixels from the top of the screen. This is useful when you want to capture a browser window, a terminal, or a specific application area without showing your entire desktop, including that folder named “definitely_not_memes.”
Use xwininfo to Get Window Coordinates
If you want to record a specific window on X11, you can use xwininfo to find its size and position:
Your cursor will change. Click the window you want to inspect. Look for values such as width, height, and upper-left coordinates. Then plug those numbers into your FFmpeg command.
Example:
Method 2: Record Screen and Audio with FFmpeg
A silent screen recording can be useful, but tutorials usually need audio. FFmpeg can capture both video and sound if you add an audio input. The exact command depends on whether your system uses PulseAudio, PipeWire with PulseAudio compatibility, or ALSA.
Record Microphone Audio
On many Linux systems, this command records the screen plus the default PulseAudio input:
This captures your screen and microphone. If your voice sounds like it is coming from inside a cereal box, check your microphone gain in your sound settings or use pavucontrol to select the correct input.
Record System Audio
To record internal desktop audio, list your audio sources:
Look for a source ending in .monitor. It may look something like this:
Then use it as the audio input:
If you are using PipeWire, pactl may still work because many modern distributions provide PulseAudio compatibility through PipeWire. That means old commands often continue to work, which is one of those rare Linux moments where compatibility quietly saves the day instead of hiding in a cave.
Record Microphone and System Audio Together
Combining microphone and system audio can be trickier. The cleanest approach is often to route audio using PulseAudio or PipeWire tools, then capture the combined monitor source. For many tutorial creators, using pavucontrol to choose the right recording source is the fastest practical solution.
A common workflow is:
- Start the FFmpeg recording command.
- Open
pavucontrol. - Go to the Recording tab.
- Select the source you want FFmpeg to capture.
Install it if needed:
Method 3: Record Wayland Sessions with wf-recorder
If you are using Wayland, FFmpeg’s classic x11grab command will not behave the same way. Wayland has a stronger security model, so applications cannot freely spy on every pixel unless the compositor allows it. This is good for privacy. It is slightly annoying when you are trying to record your screen at 2 a.m. and your only audience is future-you.
For wlroots-based Wayland compositors such as Sway, Wayfire, Hyprland, River, and similar environments, wf-recorder is one of the best command-line tools.
Install wf-recorder
On Ubuntu or Debian-based systems, package availability may vary:
On Fedora:
On Arch Linux:
Record the Full Screen on Wayland
Stop recording with Ctrl+C. The file will be saved as wayland-recording.mp4.
Select a Region with slurp
Many Wayland users pair wf-recorder with slurp, a tool that lets you select a screen region interactively.
Install slurp:
Then record a selected region:
This is one of the smoothest command-line workflows for Wayland. You run the command, drag over the area you want, and the recording begins. It feels almost too convenient, which means somewhere a Linux elder just adjusted their suspenders suspiciously.
Record Audio with wf-recorder
Depending on your setup and build options, you may be able to include audio with options supported by your installed version. Check the help output:
If audio capture is not available or does not behave as expected, you can record audio separately with FFmpeg, parec, or another PipeWire/PulseAudio tool, then combine the tracks afterward.
Method 4: Use GStreamer from the Command Line
GStreamer is another powerful multimedia framework. It is not as beginner-friendly as FFmpeg, mostly because its commands look like someone taught a robot to build plumbing. However, it is flexible, scriptable, and useful for advanced workflows.
Install GStreamer Tools
On Ubuntu or Debian:
Record the X11 Screen with GStreamer
The ximagesrc element captures the X display. The video is converted, encoded with H.264, packed into an MP4 container, and written to a file. For simple everyday screen recording, FFmpeg is usually easier. For custom pipelines, live processing, embedded systems, or experimental capture setups, GStreamer is excellent.
Method 5: Configure GNOME’s Built-In Screen Recorder from the Terminal
GNOME includes a built-in screen recorder that can be triggered with a keyboard shortcut, commonly Ctrl+Alt+Shift+R. It is not a pure command-line recorder in the same way FFmpeg is, but you can configure some behavior from the terminal.
For example, older GNOME setups limited recordings to 30 seconds by default. You can check the maximum screencast length with:
To change it to 10 minutes:
To remove the limit:
This is useful if you want quick recordings without installing extra tools. The trade-off is that you get fewer encoding options than FFmpeg or wf-recorder.
Best FFmpeg Settings for Quality and Performance
The perfect screen recording command depends on your hardware, resolution, frame rate, and final purpose. A tutorial for YouTube does not need the same settings as a lossless capture for later editing.
Balanced MP4 Recording
This command gives you a good balance between quality, file size, and compatibility. The -crf value controls quality. Lower means better quality and larger files. Common values are between 18 and 28. For most tutorials, 22 or 23 is perfectly reasonable.
High-Quality Recording for Editing
Using .mkv is often safer during recording because it is more resilient if something crashes. You can convert it to MP4 later:
Smaller File Size
This creates a smaller file, but it may take more CPU and reduce visual quality. If your recording shows text, code, or terminal output, avoid making the file too compressed. Blurry code is how tutorials become accidental eye exams.
How to Stop Recordings Cleanly
Most command-line recorders stop with Ctrl+C. This sends an interrupt signal, allowing the program to finalize the file. With FFmpeg, you can also press q in the terminal window to stop recording gracefully.
For scripts, you may want to run a recorder in the background and stop it later. Example:
In another terminal, find the process:
Then stop it:
Use -INT rather than aggressively terminating the process. Your video file will thank you by remaining playable.
Common Problems and Fixes
Problem: The Recording Is Black
This often happens when you use an X11 capture command inside a Wayland session. Check your session:
If it says wayland, use wf-recorder, a PipeWire-based recorder, or switch to an X11 session from your login screen if your distribution allows it.
Problem: Audio Is Missing
List your sources:
Then choose the correct microphone or monitor source. If you are using a GUI audio mixer such as pavucontrol, check the Recording tab while FFmpeg is running.
Problem: The Video Lags
Try reducing the frame rate:
Or use a faster encoding preset:
You can also record to .mkv, lower the resolution, close heavy applications, or record a smaller region instead of the entire desktop.
Problem: The File Is Huge
Increase the CRF value:
Or re-encode after recording:
Practical Command Examples
Simple X11 Recording
X11 Recording with Microphone
Wayland Recording with wf-recorder
Wayland Region Recording
Convert MKV to MP4 Without Re-Encoding
Command-Line Screen Recording Tips from Real Experience
After using Linux command-line screen recording tools for tutorials, bug reports, software demos, and the occasional “watch this weird thing happen” clip, one lesson becomes obvious: the best command is not always the fanciest command. It is the one you can run quickly, understand later, and trust when something important is happening on-screen.
For X11, FFmpeg remains the dependable workhorse. A simple x11grab command can capture a full desktop with very little setup. But it is worth creating a small shell script instead of retyping a long command every time. For example, a script named record-screen.sh can store your resolution, frame rate, audio source, and output folder. That way, when you need to record quickly, you are not searching your shell history like an archaeologist with caffeine.
Another useful habit is recording to .mkv first, especially for longer sessions. MP4 is widely compatible, but MKV is forgiving if the process ends unexpectedly. If your laptop battery dies, your window manager crashes, or your cat steps on the keyboard and becomes the system administrator, MKV gives you a better chance of recovering the recording. Afterward, you can convert it to MP4 with ffmpeg -i input.mkv -c copy output.mp4.
For Wayland, the experience depends heavily on your desktop environment or compositor. On wlroots-based setups, wf-recorder feels clean and fast. The combination of wf-recorder and slurp is especially pleasant because you can select a region visually while still staying in a terminal workflow. On GNOME or KDE Wayland sessions, PipeWire and desktop portals play a bigger role. That security layer is good, but it means some tools ask for permission, some sources appear only after portal services are running, and troubleshooting may involve checking whether xdg-desktop-portal and the correct backend are installed.
Audio is usually the part that causes the most head-scratching. Video capture either works or it does not; audio can fail in sneaky ways. You may record the wrong microphone, capture silence, or accidentally record your laptop fan performing a dramatic solo. Before recording something important, make a ten-second test clip. Play it back. Confirm that your voice, system audio, and screen movement are all present. This tiny test saves enormous frustration.
Frame rate also deserves attention. Recording at 60 FPS looks smooth, but it creates larger files and uses more CPU. For coding tutorials, software walkthroughs, slide presentations, and bug reports, 30 FPS is usually enough. If you are recording games, animation, or fast UI motion, 60 FPS may be worth it. If your machine struggles, reduce the capture area before reducing everything else. Recording a 1280×720 region is often much easier than recording a full 4K desktop.
Finally, keep your commands readable. Split long FFmpeg commands across multiple lines with backslashes. Add comments in your scripts. Name files with dates, projects, or topics. A file called output.mp4 is fine once. After the twelfth version, it becomes a tiny museum of confusion. Use names like linux-terminal-demo-2026-05-17.mkv and future-you will send past-you a polite thank-you note.
Conclusion
Recording your screen from the Linux command line is powerful, flexible, and surprisingly practical once you know which tool fits your session. On X11, FFmpeg with x11grab is the classic choice for full-screen, region, and audio-enabled recording. On Wayland, tools like wf-recorder, PipeWire-based workflows, and desktop portal-aware applications are usually better options. GStreamer is available for advanced pipelines, while GNOME’s built-in recorder works well for quick captures.
The smartest approach is to start simple: identify whether you are using X11 or Wayland, run a short test recording, check your audio, and then adjust quality settings only when needed. Once you build a command or script that works on your machine, Linux screen recording becomes fast, repeatable, and wonderfully nerdy in the best possible way.
Note: This article is based on current Linux screen recording behavior and documentation for FFmpeg, FFmpeg devices, GStreamer, PipeWire, XDG Desktop Portal, wf-recorder, PulseAudio-compatible tools, X11 utilities, and common Linux distribution workflows.