144

I just wanted to test something out real quick. So I ran a docker container and I wanted to check which version I was running:

$ docker run -it ubuntu    
root@471bdb08b11a:/# lsb_release -a
bash: lsb_release: command not found
root@471bdb08b11a:/# 

So I tried installing it (as suggested here):

root@471bdb08b11a:/# apt install lsb_release
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package lsb_release
root@471bdb08b11a:/# 

Anybody any idea why this isn't working?

2
  • 18
    the command is lsb_release (with underscore) but the package to install is lsb-release (with an hyphen) Nov 25, 2020 at 10:29
  • 1
    @RubenLaguna i wonder who thought it is a good idea to have two different names...
    – Black
    Jun 8, 2022 at 7:36

6 Answers 6

236

It seems lsb_release is not installed.

You can install it via:

apt-get update && apt-get install -y lsb-release && apt-get clean all
5
  • 3
    I only needed to install the package lsb-release. lsb-core works too, but it brings in a whole bunch of dependencies I don't need. Nov 22, 2019 at 1:31
  • 18
    This is why I love Linux - black magic resulting in several screens of output just to see OS version! Feb 16, 2020 at 6:55
  • 16
    @AlexanderChristov you can just run uname --all for kernel version or cat /etc/os-release for distribution info, if you don't want to do it the recommended way
    – smac89
    May 23, 2020 at 14:41
  • 37
    I guess is worth noting that the command is lsb_release (with underscore) but the package to install is lsb-release (with hyphen) Nov 25, 2020 at 10:30
  • this doesn't solve the problem Apr 2 at 19:54
17

Just use cat /etc/os-release and that should display the OS details.

Screenshot from debian.

enter image description here

Screenshot from ubuntu.

enter image description here

Screenshot from fedora.

enter image description here

6

This error can happen due to uninstalling or upgrading the default python3 program version in ubuntu 16.04

The way to correct this is by reinstalling the original python3 version which comes with ubuntu and relinking again. (in ubuntu 16.04 - the default python3 version is python 3.5

sudo rm /usr/bin/python3
sudo ln -s /usr/bin/python3.5 /usr/bin/python3
1
  • I'd be careful messing with the potential symlinks in /usr/bin/python3. You really should be using sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 35 #or whatever priority. That being said, mine is there, but the shebang is for python, not python3 May 27, 2022 at 4:16
2

lsb_release.py lives in /usr/share/pyshared which to me doesn't look like python3.6 and above is referencing.

I found the following will create a link back from a later Python install to this /usr/share script:

sudo ln -s /usr/share/pyshared/lsb_release.py /usr/lib/python3.9/site-packages/lsb_release.py
1

In case one is trying to deal with lsb_release: command not found on fedora or redhat, the package to install is redhat-lsb-core , so sudo dnf install redhat-lsb-core

0

While writing Dockerfile we can add lsb-release package - like this

RUN apt-get update -y \
    && apt-get upgrade -y \
    && apt-get install lsb-release -y \
    && apt-get clean all

Assuming OS is Ubuntu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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