1. Home
  2. Linux
  3. Record your screen from the linux command line

How To Record Your Screen From The Linux Command Line

Need to record your screen on a Linux desktop but you aren’t satisfied with the screen recorders that are available? Consider using the powerful FFMPEG encoding tool. It’s very versatile and can do multiple things, including screen capture on the Linux desktop.

SPOILER ALERT: Scroll down and watch the video tutorial at the end of this article.

The setup for FFMPEG is a little more complex than hitting a “record” button in a program, but the tradeoff is that it offers up some real power, automation, and customization that other GUI recording tools on Linux don’t offer.

Installing FFMPEG


sudo apt install ffmpeg


sudo apt-get install ffmpeg

Arch Linux

sudo pacman -S ffmpeg


sudo dnf install ffmpeg


sudo zypper install ffmpeg

Other Linuxes

The FFMPEG encoding utility is one of the most used video tools on Linux and operating systems in general. It is because of this, the tool is supported on nearly every Linux distribution out there. If for some reason, the Linux operating system you use doesn’t support FFMPEG with a binary package, the best course of action is to install the software manually, from the FFMPEG Github repository.

To do this, first, make sure you have the git tool installed. Once installed, open up a terminal and do the following to build the software:

git clone https://github.com/FFmpeg/FFmpeg.git

Enter the FFMPEG directory with the CD command.

cd FFmpeg

Before you begin compiling the software, you’ll need to create a new configuration file. This is so that the software knows your system and can build correctly.


Having issues with ./configure? Try:

./configure --help

The next step in the compiling process is to use the make command. Make does the majority of the building, and its the most critical step in installing FFMPEG.


Lastly, install the software on the system with the install command.

sudo make install

Record Your Screen

The FFMPEG software is very versatile and can be configured to do just about anything, including video capture. That said, the default type of visual capture that is possible works by capturing every screen available. It’s crude, but it works. To use it, open up a terminal window. Inside the terminal, before starting capture, it’s a good idea to make a special folder to work in. This way all recordings go there, rather than in random places.

Using the mkdir command to create a new capture folder inside of ~/Videos.

mkdir -p ~/Videos/ffmpeg-capture/

Then, move the terminal into the new directory, so that the capture will take place there, rather than another location.

cd ~/Videos/ffmpeg-capture/

You can now start recording your screen. Here is the basic capture command:

ffmpeg -f x11grab -y -r 30 -s 1920x1080 -i :0.0 -vcodec huffyuv out.avi

Be sure to change the resolution in the command to correspond with the monitor you are recording on. In the command shown above,  the resolution is set to 1920×1080 and it is set to record the desktop at 30 frames per second, and output it to a file named capture.mp4. For the most part, screen-casting at 25 FPS is fine. However, if you’re looking to record something that requires a high frame rate (like video games, or moving images), consider changing the 30 to 60. Keep in mind that changing the FPS from 30 to 60 will result in slower performance on weaker computers. Before doing this, try and find out if your Linux computer can handle the up in performance beforehand.

Quit the recording at any time by tapping the ‘q’ key on the keyboard.

Record Screen And Webcam

It is possible to capture the desktop in FFMPEG and record from your webcam at the same time. To do so, you’ll need to use two separate commands. The first command to use will display the active webcam currently connected to Linux. The second command is the screen capture.

For the first command, open a terminal window and enter the following:

ffplay -f video4linux2 -i /dev/video0 -video_size 320x240 -fflags nobuffer

This setup will display a webcam window with almost no latency directly on the screen with a 320×240 screen resolution. Don’t worry about the size, as it’ll look just fine on the recording. Feel free to grab the cam window and put it in any place you’d like. Additionally, if your window manager supports hiding, consider making the camera window controls disappear for a better effect.

Note: if you dislike the 320×240 resolution, consider changing it to something else. Look into the webcam’s manual to find the perfect resolution to use, but remember, don’t use a higher resolution than the device can handle or things will break.

While the first terminal is open, your webcam will be displayed on the desktop. Next, open a second terminal window to start the actual recording:

cd ~/Videos/ffmpeg-capture/
ffmpeg -f x11grab -r 30 -s cif -i :0.0 capture.mp4

As long as these two terminal windows are open, you’ll be recording the desktop at 30 FPS, and displaying a webcam.

To stop the recording, go to the FFMPEG window and press “q” to quit, then move on to the FFPLAY terminal (the one broadcasting the cam) and press Ctrl + Z.

Finished recordings are saved in ~/Videos/ffmpeg-capture/


  1. Hi guys, since I’m a Linux user, I used the AceThinker Screen Grabber Pro whenever I need to record my computer screen. It helps me make a video demo about software that I need to review. The good thing about this tool is it can record in 720p up to 1080p quality video and audio. Also, you can record your computer screen in full-screen, regional, webcam, or around the mouse. You can surely capture any activities on your Linux computer screen.

  2. An easier solution I use is recordmydesktop.

    On Debian based system, install it via apt:

    sudo apt-get install recordmydesktop

    Then start recording just by enter command:


    Then in terminal press CTRL+C to stop/save recording

    By default, it doesn’t encode on the fly so it can take time to save depending on length of video. To encode on the fly use command:

    recordmydesktop –on-the-fly-encoding

    When encoding in the fly it only takes under 3 seconds to save.

    For list of more commands use: recordmydesktop –help

    I find this solution easier than ffmpeg recording

  3. Hi,
    tnx for the tutorial.
    Everything works fine. But when using the command

    ffplay -f video4linux2 -i /dev/video0 -video_size 320×240 -fflags nobuffer

    I get (amongst other info):
    “WARNING: library configuration mismatch”. It seems to have no ill effect though.
    Could you tell me what´s going on here? Something to be worried about?
    System: Linux Lubuntu 16.04.3 LTS, 64 bit


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.