Press "Enter" to skip to content

Get Ubuntu release code name in Script

$ lsb_release -h
Usage: lsb_release [options]

Options:
  -h, --help         show this help message and exit
  -v, --version      show LSB modules this system supports
  -i, --id           show distributor ID
  -d, --description  show description of this distribution
  -r, --release      show release number of this distribution
  -c, --codename     show code name of this distribution
  -a, --all          show all of the above information
  -s, --short        show requested information in short format


$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy


$ lsb_release -sc
jammy

$ lsb_release -sr
22.04

Use it in Shell Script

echo "deb http://apt.kubernetes.io/ kubernetes-$(lsb_release -sc) main kubernetes-$(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
Leave a Reply

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