Close Menu
    Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (Twitter) Instagram
    TecAdmin
    You are at: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

    By RahulJune 10, 20221 Min Read

    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

    Related Posts

    How to Install Google Chrome on Ubuntu 22.04

    Setting up an SFTP Server on Ubuntu

    The Ultimate Guide to Backing Up and Restoring Your Ubuntu System

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Install PIP on macOS: A Comprehensive Guide
    • Find Objects Between Two Dates in MongoDB: A Practical Guide
    • How to Check Packages Update History in Ubuntu
    • How to Grep for Contents after a Matching Pattern
    • How to Change Port in Next.Js
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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