Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Distributions»Debian»How to find Ubuntu Version, Codename and OS Architecture in Shell Script

    How to find Ubuntu Version, Codename and OS Architecture in Shell Script

    RahulBy RahulSeptember 14, 20151 Min ReadUpdated:June 10, 2022

    While working with the bash shell scripting, Many times you may require to get your system version or codename or operating system architecture. In this article, you will learn, how to find Ubuntu Version, Codename, and OS Architecture in a shell script.

    1. Get Ubuntu Version

    To get ubuntu version details, Use -r with lsb_release command.

    $ lsb_release -r
    
    Release:	14.04
    

    Also use -s or --short to get details in short format

    $ lsb_release -r --short
    
    14.04
    

    2. Get Ubuntu Codename

    To get ubuntu version details, Use -c with lsb_release command.

    $ lsb_release -c
    
    Codename:	trusty
    

    Also use -s or --short to get details in short format

    $ lsb_release -c --short
    
    trusty
    

    3. Get OS Architecture Details

    To find the operating system architecture details using uname command with -m parameter.

    $ uname -m
    
    x86_64
    

    4. Shell Script – Store Values in Variable

    Now if we need to use these values in a shell script, store these values in variables. Below example, the shell script will help you to store the output of commands in variables and use them

    #!/bin/bash
    
    Version=$(lsb_release -r --short)
    Codename=$(lsb_release -c --short)
    OSArch=$(uname -m)
    
    echo "Version = $Version"
    echo "Codename = $Codename"
    echo "OS Architecture = $OSArch"
    
    
    architecture codename Ubuntu uname version
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Create Disk Partitions in Linux
    Next Article How to Install Unetbootin (Bootable USB Creator) on Ubuntu & LinuxMint

    Related Posts

    How to Install Composer on Ubuntu 22.04

    Updated:June 24, 20223 Mins Read

    Setup Selenium with Python and Chrome on Ubuntu & Debian

    Updated:June 20, 20224 Mins Read

    How to Setup Squid Proxy Server on Ubuntu and Debian

    Updated:June 17, 20225 Mins Read

    How to Install Apache Kafka on Ubuntu 22.04

    Updated:June 5, 20225 Mins Read

    Setting Up Environment Variables on Ubuntu

    Updated:May 28, 20222 Mins Read

    How to Install Apache Maven on Ubuntu 22.04

    Updated:June 2, 20223 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    • What is the /etc/nsswitch.conf file in Linux
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.