Welcome to Our Community

Register on JustAnimeForum and start chatting about anime with like-minded people!

Sign Up / Login
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Thank you for the years of fun feel free to join the discord here! Please enjoy the forum for the short time it may be up feel free to make an account here or see what forums you dont need to make an account here
    with love,
    shedninja the sites biggest bug

Linux Oslevel Command

Discussion in 'Tech Temple' started by Cpt_K3nny, May 3, 2017.

  1. Cpt_K3nny Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    963
    Joined:
    Sep 28, 2015
    Likes Received:
    288
    Trophy Points:
    225

    Ratings:
    +288 / 0 / -0
    Hi,

    Lets just get this started....


    I need a command that would give me the OS Level and OS type for linux.

    I am currently writing a script to run installs for all our UNIX boxes unfortunately we have several versions of UNIX on our systems. (AIX, Linux SUSES & Linux Redhat)

    I can get the AIX OSLEVEL and version no problem as the command is simple.
    # oslevel -s
    7100-04-02-1614

    This command tells me I have AIX Version 7.1 Technology Level 4

    Simple and easy :)

    Linux on the other hand Urgh...........

    For SUSE I think I can get it with no issue as well bit more to process but should work.

    # lsb_release -a|grep Description|awk -F' ' '{print $2}'
    SUSE
    # lsb_release -a|grep Description|awk -F'Server ' '{print $2}'|awk -F' ' '{print $1}'
    11
    # lsb_release -a|grep Description|awk -F'(' '{print $2}'|awk -F ')' '{print $1}'
    ppc64

    as long as the parameter for this command does not change this should work...

    But when I run the command lsb_release -a on Redhat I get command not found....

    Is there something similar to this command for redhat or am I doom to bang my head on a brick wall?
     
  2. ShadowLinks Hero of Time

    Rank:
    Rank:
    Rank:
    Messages:
    922
    Joined:
    Apr 20, 2013
    Likes Received:
    57
    Trophy Points:
    195

    Ratings:
    +57 / 1 / -0
    I think you have to install redhat-lsb-core on redhat and centos before you can do lsb commands.
     
    #2 ShadowLinks, May 3, 2017
    Last edited: May 3, 2017
  3. Cpt_K3nny Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    963
    Joined:
    Sep 28, 2015
    Likes Received:
    288
    Trophy Points:
    225

    Ratings:
    +288 / 0 / -0
    Yea I read that I was hopping to use yum to install it but

    THIS!!!!!

    ]# yum provides */lsb_release
    Loaded plugins: product-id, search-disabled-repos, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    No matches found

    So rather then having to jump through corporate hoops I decided there must be an easier way!:) but maybe that's just me being wishful.

    Thanks for the link to the website doh I read part of it and I might be able to manage....
     
  4. Vashnik Guest

    『   』
    Rank:
    Rank:
    Ratings:
    +0 / 0 / -0
    Not sure if this will help, but a bit of Google searching showed this: "cat /etc/redhat-release"
    Now, I don't have access to a demo/test copy to see if this works so I can't say for sure if this is one part you're looking for or not and it's from a thread/post on a forum that's from 2007, so I don't know if they've changed their list of commands or not either. I also don't know if it will give you the OS level or not.

    I've also seen "uname -a" being mentioned a few times in a Unix Stack Exchange Q&A/help thread, so I'm not sure if that will work on Red Hat or not.
     
  5. Cpt_K3nny Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    963
    Joined:
    Sep 28, 2015
    Likes Received:
    288
    Trophy Points:
    225

    Ratings:
    +288 / 0 / -0
    yea the problem with the uname command is that it does not tell me if its Redhat or SUSE

    IE
    root# uname -a
    Linux $SERVERNAME 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux

    The issue with the cat /etc/redhat-release is that its strictly for redhat and that cat cannot be used for SuSE it would need to be cat /etc/SuSE-release for it to work.

    Also looking at the cat /etc/redhat-release

    root# cat redhat-release
    Red Hat Enterprise Linux Server release 7.3 (Maipo)

    it does not tell me if its 64_86 or PPC64 etc....

    I mean I could code around that but I would like it to be one simple command for both for generic sake maybe I am just being to picky....

    But thanks for the suggestion..... I might just use the uname -a and the cat /etc/*-release command for now until I can get the lsb command installed on our redhat enviroment...


    Also dont want to brag or anything but this script will be epic!!!! :) or atleast I hope so... just so I can run the script than slack off the job lol just kidding :)


    Thanks for the input @Vashnik & @ShadowLinks I appreciate it....
     
  6. Vashnik Guest

    『   』
    Rank:
    Rank:
    Ratings:
    +0 / 0 / -0
    Keep in mind that some Linux will use /etc/*_version instead, so if you run into a problem with *-release, try *_version.

    Also, I looked up "Red Hat command architecture" since the x86_64 was a clue to what you were looking for and the search provided "uname -m" in almost every result (for me) so you may try using "uname -a|uname -m" in your script and see if that works better for you, at least until you're able to find a more easier, efficient way.
     
    • Like Like x 1
  7. Cpt_K3nny Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    963
    Joined:
    Sep 28, 2015
    Likes Received:
    288
    Trophy Points:
    225

    Ratings:
    +288 / 0 / -0

    I will try the uname -m for redhat and let you know....
     
  8. Cpt_K3nny Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    963
    Joined:
    Sep 28, 2015
    Likes Received:
    288
    Trophy Points:
    225

    Ratings:
    +288 / 0 / -0
    Urgh Linux has defeated me....I could not slay the huge Penguin!!! or make it bend to my will.....

    Linux in its infinite glory and wisdom has decided that me installing the RPM i want, via a nim server, with an ssh command has decided to crap out on me but if I take that same RPM file and manually install it on the server Houray it works what the hell is the difference if I ran the command through SSH or physically on the box urgh I have been defeated by a cute penguin can life get any worse?


    EDIT***

    Actually I have slain the penguin..... just put that command in a shell script and call the shell script and it installs fine ...... Penguin has been slained!!

    Thanks for all the help guys!
     
    #8 Cpt_K3nny, May 5, 2017
    Last edited: May 5, 2017
  9. Vashnik Guest

    『   』
    Rank:
    Rank:
    Ratings:
    +0 / 0 / -0
    It's because it was you. It wanted to harass you and make you work for it rather than it work for you. It's becoming self-aware. ... Ok, maybe it's not, it's just a stubborn OS. lol

    Glad it worked out for you though.
     
    • Like Like x 1
  10. Cpt_K3nny Trophy Hunter

    Rank:
    Rank:
    Rank:
    Messages:
    963
    Joined:
    Sep 28, 2015
    Likes Received:
    288
    Trophy Points:
    225

    Ratings:
    +288 / 0 / -0
    Indeed it is.... but I am just happy that its over with :p
     

Share This Page