How to play Spotify from the command-line in the terminal with Librespot

Spotify music service supports the Linux operating system with the help of Snap, Flatpak, and Ubuntu applications. The app doesn't work well on PCs with minimal resources.


Spotify music service supports the Linux operating system with the help of Snap, Flatpak, and Ubuntu applications. However, the Spotify app does not work well on Linux PCs that have minimal resources.

Because of this, Librespot has come to the rescue so that users can listen to Spotify from their Linux terminal. This how-to guide will walk you through how to install Librespot and use it to listen to Spotify.

Installing Librespot

To install Librespot, the user will have to install several build-time dependencies. Dependencies will differ based on the Linux distributions that are used which can be followed below.


For Debian and Ubuntu, you need to install the “build-essential” package, the Rust programming language, and the “libasound2-dev” package. You will also need Git to interact with the source code. Install using the following command:

sudo apt-get install build-essential libasound2-dev

For Fedora users, you will need to install the “alsa-lib-devel” package, the “make” package, the “gcc” package and the Rust programming language. You will also need to install Git to interact with GitHub. Install using the following command:

sudo dnf install alsa-lib-devel make gcc

Arch Linux


For Arch Linux users, you will need to install several dependencies, but the good news is that the entire program is inside the Arch Linux AUR. First, you will install the Git and Base-devel packages on Arch with Pacman. Then you will need to clone the AUR package build of Trizen to make Librespot install quicker using Trizen. Follow the commands below to install the dependencies and Librespot on Arch.

sudo pacman -S git base-devel
git clone
cd trizen
makepkg -sri
trizen -S librespot-git

Arch Dependencies

Building the Software

With all of the dependencies taken care of you will need to use the following commands to clone the source code to your Linux PC using the git clone command. Then you will have to move the terminal window into the “librespot” folder with the CD command and build Librespot with the cargo command. Once the program has completed the build process, you will need to move the created files from the source code folder in a new location in the “opt” directory.

git clone
cd librespot
cargo build --release
cd librespot/target/release/
mkdir -p /opt/librespot/
sudo mv * /opt/librespot/

Building Software

Using touch, you will need to create a new script to run the software quickly, then open the file with Nano.

sudo touch /usr/local/bin/librespot
sudo nano -w /usr/local/bin/librespot

Nano Build 1

The next step is to add the code below into Nano.

##Librespot runner
cd /opt/librespot/
sudo ./librespot -n "librespot" -b 320 -c ./cache --enable-volume-normalisation --initial-volume 75 --device-type avr

Nano Build 2

Next, save Nano with Ctrl+O, then exit with Ctrl+X. Use the following chmod command to update the script file’s permissions.

sudo chmod +x /usr/local/bin/librespot
sudo chmod 755 /opt/librespot/

chmod commands

Then use the following command to start the Librespot application from the terminal window.


Using Librespot

Librespot works using Spotify connect. So to use the Librespot application, you will need to have Spotify installed on your smartphone. Once you have the Spotify app installed and set up, login into your account, and follow the following step-by-step instructions to play music through Librespot.

  1. Within the Spotify app on your smartphone, search for an artist, playlist, album, or song that you want to listen to, then tap play.
  2. Open the playback window at the bottom of your smartphone screen.
  3. Pause the music but don’t close the playback window.
  4. Look in the bottom left corner of the playback window and find the white icon that brings up the “Spotify Connect” window.
  5. The next window will say, “Connect to a device” and will list all connect-enabled devices.
  6. You will want to choose the device labeled “Librespot.”
  7. Press the play button on the app to unpause your music, and Spotify should start playing through the Linux terminal on your PC. Enjoy!
Divya Kiran Kumar
I'm the Editor of FOSS Linux. I worked as a Software Engineer before taking up blogging as my full-time job. I enjoy using Linux, and can't imagine anything else for my PC. Apart from writing for FOSS Linux, I enjoy reading non-fictional books. Sapiens was my favorite last read. I hope you enjoy reading and using this blog to enhance your Linux experience! Have a great day ahead!



Please enter your comment!
Please enter your name here




Top 20 Git Commands with Practical Examples

If you are here reading this post, there is a high probability that you have heard or interacted with Github, and you now want to learn Git. Before we continue with showing you some of the cool Git commands, let's understand the difference between Git and GitHub.

Top 10 New Features in Linux Kernel 5.7

Linus Torvalds has announced the release of Linux Kernel 5.7 after seven weeks of development. The release announcement comes as a piece of exciting news as it brings a host of new features for the hardware manufacturers as well as the developers.

How to install CMake on Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process.

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.


Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

5 Best Application Launchers for Ubuntu

Ubuntu is one of the most used Linux distributions worldwide. It is also the reason why it has the maximum number of available programs for itself. Today we are going to talk about one category of those programs, the application launchers.

Manjaro ‘Gellivara’ XFCE Edition (17.0.5) in 10 Screenshots

Want to take a quick virtual tour Manjaro XFCE edition instead of downloading GBs worth of ISO image and then making a Live USB of it? We will make it easy for you. Here are a series of screenshots of the important aspects of Manjaro Linux in XFCE edition. This is a light-weight edition, and aims to be fast and low on system resources. You will be amazed on how it is still visually appealing and user friendly.

10 Best PDF Editors for Linux

In this article, we will take a look at 10 of the best PDF editors and tools out there in 2019 that are available for Linux platforms. The editors are going to be judged on the basis of their functionalities, portability, ease of installation, price, and convenience.

10 top reasons to switch to Manjaro Linux

Manjaro is Linux distro based on Arch-Linux which follows a rolling release model. Is this distro good for you? Let's find out the main reasons for using Manjaro.