• Home
  • Store
  • Blog
  • Contact
  • Home
  • Store
  • Blog
  • Contact
  • #linux
  • |
  • #commandline
  • |
  • #softwareengineering
  • |
  • #embeddedsystems
  • |
  • #compilers
  • ...
  • View All >>

Intro To 'uname' Command In Linux

2023-05-10 - By Robert Elder

     I use the 'uname' command as a quick way to see information about my operating system:

uname

     and the output is:

Linux

     Typically, I run the uname command with the '-a' flag to show all of the system information that this command can provide:

uname -a

     and the output is:

Linux robert-ThinkPad-P15v-Gen-1 5.15.0-60-generic #66~20.04.1-Ubuntu SMP Wed Jan 25 09:41:30 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

     The uname command supports various flags to show certain fields individually, such as the kernel release version and the hardware platform:

uname --kernel-name
uname --nodename
uname --kernel-release
uname --kernel-version
uname --machine
uname --processor
uname --hardware-platform
uname --operating-system

     the output from running all of the commands above is:

Linux
robert-ThinkPad-P15v-Gen-1
5.15.0-60-generic
#66~20.04.1-Ubuntu SMP Wed Jan 25 09:41:30 UTC 2023
x86_64
x86_64
x86_64
GNU/Linux

     This ability to print individual fields could be useful for scripting purposes.  Here, I have an example of a script called 'do_install.sh' that verifies the hardware platform before attempting to start an install process that only works on the 'x86_64' platform:

#!/bin/bash

if [ "$(uname --machine)" == "x86_64" ]
then
        echo "arch was x86_64"
        echo "... Run x86_64 install commands..."
else
        echo "arch was something else, install cannot continue."
fi

     If I try to run the above script on a platform where the machine name is 'x86_64' the output will be the following:

arch was x86_64
... Run x86_64 install commands...

     but if the machine name has some other value (such as 'i386'), the output will be the following:

arch was something else, install cannot continue.

     And that's why the 'uname' command is my favourite Linux command.

Intro To 'stty' Command In Linux
Published 2023-10-04
$1.00 CAD
Terminal Block Mining Simulation Game
Intro To 'nproc' Command In Linux
Published 2023-07-15
Intro To 'comm' Command In Linux
Published 2023-09-06
How To Force The 'true' Command To Return 'false'
Published 2023-07-09
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01
Intro To 'chroot' Command In Linux
Published 2023-06-23
Join My Mailing List

Privacy Policy
Why Bother Subscribing?
  • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
  • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
  • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
© 2025 Robert Elder Software Inc.
Privacy Policy      Store Policies      Terms of Use