arecord

multimedialinux
The arecord command is one of the most frequently used commands in Linux/Unix-like operating systems. arecord The arecord command is a command-line sound recorder and player for the ALSA (Advanced Linux Sound Architecture) sound system. It can be used to record audio from various input sources such as microphones, line-in, and capture monitors.

Quick Reference

Command Name:

arecord

Category:

multimedia

Platform:

linux

Basic Usage:

arecord [options] [arguments]

Common Use Cases

  • 1

    Audio recording

    Record audio from microphones and other input devices

  • 2

    Sound testing

    Test audio input devices and verify recording capabilities

  • 3

    Audio capture

    Capture audio streams for processing or analysis

  • 4

    System audio recording

    Record system audio output for documentation or analysis

Syntax

arecord [options] [filename]

Options

Option Description
-h, --help Display help and exit
-l, --list-devices List all soundcards and digital audio devices
-L, --list-pcms List all PCM devices
-D, --device=NAME Select PCM device by name
-q, --quiet Quiet mode (no messages output)
-t, --file-type TYPE File type (voc, wav, raw, or au)
-c, --channels=# Number of channels
-f, --format=FORMAT Sample format (S8, S16_LE, S24_LE, etc.)
-r, --rate=# Sampling rate in Hz
-d, --duration=# Record for # seconds
-s, --sleep-min=# Min ticks to sleep
-M, --mmap Use mmap-based access
-N, --nonblock Use non-blocking mode
-F, --period-time=# Distance between interrupts in microseconds
-B, --buffer-time=# Buffer duration in microseconds
-A, --avail-min=# Min available space for wakeup in microseconds
-R, --start-delay=# Delay for automatic PCM start in microseconds
-T, --stop-delay=# Delay for automatic PCM stop in microseconds
-v, --verbose Show PCM structure and setup
-V, --vumeter=TYPE Enable VU meter (TYPE: mono or stereo)
-I, --separate-channels Write each channel to a separate file
--max-file-time=# Maximum time per file in seconds
--use-strftime Apply strftime function to output filename

Examples

How to Use These Examples

The examples below show common ways to use the arecord command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

Record audio to a WAV file (Ctrl+C to stop)
arecord -f cd output.wav
Record for a specific duration (5 seconds)
arecord -d 5 -f cd output.wav
Record with specific format, rate, and channels
arecord -f S16_LE -c 2 -r 44100 output.wav
List all available sound cards and digital audio devices
arecord -l
List all available PCM devices
arecord -L

Advanced Examples:

Record from a specific sound card and device
arecord -D hw:1,0 -f cd output.wav
Record using a specific PCM device name
arecord -D plughw:1,0 -f cd output.wav
Record to a compressed audio format using a pipe
arecord -f cd | lame -r - output.mp3
Record with volume meter in VU mode
arecord -V stereo -v -f cd output.wav
Record with a specific buffer size and period
arecord -B 4096 -P 1024 -f cd output.wav
Record from multiple channels but only store specified ones
arecord -f cd -c 4 --channels-matrix='0,1' stereo-from-surround.wav
Continuous recording with 30-minute segments
arecord -f cd --max-file-time 1800 --use-strftime %Y-%m-%d-%H-%M-%S.wav
Record to FLAC format directly
arecord -f cd -t wav | flac - -o output.flac
Record system audio output (what you hear) using a loopback device
arecord -D hw:0,0 -f cd system-audio.wav

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Command Overview:

The arecord command is a part of the ALSA (Advanced Linux Sound Architecture) utilities, used for recording audio on Linux systems. It's a versatile command-line tool that provides direct access to the ALSA sound system without requiring additional sound servers like PulseAudio.

Audio Formats:

The -f or --format option specifies the sample format:

  • S8: Signed 8-bit
  • U8: Unsigned 8-bit
  • S16_LE: Signed 16-bit Little Endian (common format)
  • S16_BE: Signed 16-bit Big Endian
  • S24_LE: Signed 24-bit Little Endian
  • S24_BE: Signed 24-bit Big Endian
  • S32_LE: Signed 32-bit Little Endian
  • S32_BE: Signed 32-bit Big Endian
  • FLOAT_LE: 32-bit Float Little Endian
  • FLOAT_BE: 32-bit Float Big Endian

Common Format Shortcuts:

  • -f cd: Equivalent to -f S16_LE -c 2 -r 44100 (CD quality)
  • -f dat: Equivalent to -f S16_LE -c 2 -r 48000 (DAT quality)

File Types:

The -t or --file-type option specifies the audio file format:

  • wav: Microsoft WAV format (default)
  • raw: Raw data (no header)
  • voc: Creative Labs VOC format
  • au: Sun/NeXT AU format

Device Selection:

The -D or --device option allows you to specify which audio device to use:

  • hw:0,0: First sound card, first device (direct hardware access)
  • plughw:0,0: First sound card, first device (with format conversion)
  • default: Default audio device
  • pulse: PulseAudio sound server (if available)

Finding Available Devices:

Before recording, it's often necessary to identify the available audio devices:

  • Use arecord -l to list all sound cards and physical devices
  • Use arecord -L to list all PCM (Pulse Code Modulation) devices including virtual ones

Common Uses:

  • Simple recording: arecord -f cd output.wav
  • Timed recording: arecord -d 10 -f cd output.wav (record for 10 seconds)
  • Format conversion: arecord -f cd | lame - output.mp3 (WAV to MP3)
  • System monitoring: arecord -vv -f cd /dev/null (test input levels without saving)
  • Scheduled recording: arecord --use-strftime %Y-%m-%d-%H-%M-%S.wav -f cd (timestamp filenames)

Related Commands:

  • aplay: The counterpart to arecord, used for playback
  • alsamixer: Terminal-based mixer for ALSA
  • amixer: Command-line mixer for ALSA
  • alsactl: Control tool for ALSA

Capturing System Audio:

To record system audio output ("what you hear"), you need to set up a loopback device:

  1. Load the snd-aloop module: sudo modprobe snd-aloop
  2. Configure the capture from the loopback device: arecord -f cd -D hw:Loopback,1,0 output.wav

Buffer Settings:

For advanced usage, buffer size is important to prevent overruns or underruns:

  • Use -B or --buffer-time to set the buffer size
  • Use -P or --period-time to set the period size
  • Larger buffers reduce the risk of dropouts but increase latency

Important Notes:

  • Recording may require appropriate permissions; use sudo or add your user to the audio group
  • Use Ctrl+C to stop a recording session when no duration is specified
  • By default, arecord records to WAV format unless otherwise specified
  • To record from a microphone, ensure it is not muted in alsamixer
  • For most desktop systems with PulseAudio, you may need to specify -D pulse for proper recording
  • To record continuously with manageable files, use --max-file-time with --use-strftime
  • For compressed formats like MP3, pipe arecord output to an encoder

Common Use Cases

Audio recording

Record audio from microphones and other input devices

Sound testing

Test audio input devices and verify recording capabilities

Audio capture

Capture audio streams for processing or analysis

System audio recording

Record system audio output for documentation or analysis

Audio quality testing

Test audio quality and troubleshoot recording issues

Related Commands

These commands are frequently used alongside arecord or serve similar purposes:

Use Cases

1

Audio recording

Record audio from microphones and other input devices

2

Sound testing

Test audio input devices and verify recording capabilities

3

Audio capture

Capture audio streams for processing or analysis

4

System audio recording

Record system audio output for documentation or analysis

5

Audio quality testing

Test audio quality and troubleshoot recording issues

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the arecord command works in different scenarios.

$ arecord
View All Commands