Linux: Get Ubuntu Distribution Codename

Objective: Get Ubuntu distribution codename such as trusty for 14.04 and xenial for 16.04

To get the codename of a Ubuntu release, use the lsb_release command.

# lsb_release -c
Codename:	xenial

Another way is to cat the /etc/os-release file.

# cat /etc/os-release | grep UBUNTU_CODENAME

The third option is to extract the codename from the /etc/lsb-release file.

# cat /etc/lsb-release | grep CODENAME

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, perl, php, python, java, javascript, nodejs, angular, react); plays_on(xbox, ps4); linux_desktop_user(true); }