How can I pipe any data to audio output? For example, i want to listen to a file -- an archive, a drive backup, a program. Or I want to listen to my HDD -- I vaguely remember reading something about this being possible about 7 years ago, but can't find anything now.

So, files, disk reads, even network connections -- I want to be able to listen to anything. I know that it's definitely possible with Linux. How can I do it? Using Lubuntu 20.04


I find piping things into aplay works well.

journalctl | aplay doesn't sound pretty but does work surprisingly well.

Here's an example from aplay(1):

aplay -c 1 -t raw -r 22050 -f mu_law foobar
              will play the raw file "foobar" as a 22050-Hz, mono, 8-bit, Mu-Law .au file.

It can be found as part of the alsa-utils package on debian/ubuntu.

Here's a 1-liner that I like which echos a small C program into gcc, and runs the compiled version, piping it to aplay. The result is a surprisingly nice 15-minute repeating song.

echo "g(i,x,t,o){return((3&x&(i*((3&i>>16?\"BY}6YB6$\":\"Qj}6jQ6%\")[t%8]+51)>>o))<<4);};main(i,n,s){for(i=0;;i++)putchar(g(i,1,n=i>>14,12)+g(i,s=i>>17,n^i>>13,10)+g(i,s/3,n+((i>>11)%3),10)+g(i,s/5,8+n-((i>>10)%3),9));}"|gcc -xc -&&./a.out|aplay
  • 16
    Here's a 1-liner that I like [...] Sooo ... just how long have you been in lockdown ?-) – TomRoche May 16 '20 at 20:49
  • 1
    @TomRoche you have to give it a bit of time, it starts out slow then it gets kind of catchy :) – Clumsy cat May 17 '20 at 10:55
  • 1
    I first read "... and pipes the compiled version to aplay", and wondered what compiler hacks you were using to get a compiled program sound nice. – Paŭlo Ebermann May 17 '20 at 15:47
  • Holy hell, it sounds amazing!!! Oh I'm so glad I asked this question. Have any more? – Роман Мавроян May 20 '20 at 17:35
  • 1
    @bew yes, I got this on the second read, that's why I wrote "I first read". – Paŭlo Ebermann Nov 11 '20 at 19:40

It was possible with /dev/dsp, which is part of OSS, which hasn't been part of the Linux kernel a very long time. It used to be as easy as cat some_file >/dev/dsp or some_program >/dev/dsp.

PulseAudio provides padsp.

padsp starts the specified program and redirects its access to OSS compatible audio devices (/dev/dsp and auxiliary devices) to a PulseAudio sound server.



  • random data

    </dev/urandom padsp tee /dev/dsp >/dev/null
  • regular file

    </etc/fstab padsp tee /dev/dsp >/dev/null
  • network activity

    sudo tcpdump | padsp tee /dev/dsp >/dev/null
  • block device

    sudo cat /dev/sda | padsp tee /dev/dsp >/dev/null

In my Ubuntu 18.04.4 LTS padsp is from the pulseaudio-utils package.

  • 3
    That's a pretty roundabout way to do what you could equally well do by piping into pacat. – hobbs May 17 '20 at 2:58
  • @hobbs Well, I knew /dev/dsp, didn't know pacat. It seems you can write a good answer. – Kamil Maciorowski May 17 '20 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.