Find the answer to your Linux question:
Results 1 to 4 of 4
Like Tree2Likes
  • 1 Post By atreyu
  • 1 Post By atreyu
I'd like to script something that installs some RPMs and I want it to check if the server is an RPM or DEB based system first. I've searched this forum ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Posts
    9

    Is there a concrete way to determine if the distro is RPM based?


    I'd like to script something that installs some RPMs and I want it to check if the server is an RPM or DEB based system first. I've searched this forum and found some close things, but they've been to specific. I don't care about distro, I just want the script to basically ask, "Are you RPM based?" If not, it'll return an error and exit. I'm trying to avoid ugly if statement structures that try to parse which distro the server is. That's too specific for my needs. I just want to know if it's RPM based or not. Any easy way to do this?

    Thanks

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    this will tell you pretty quick:

    Code:
    rpm --version
    if it says: "command not found", then likely it is NOT RPM-based.
    conversely, this command:
    Code:
    apt-get --version
    will tell you if it is likely Debian-based.

    of course, you can have both package managers installed on the same system. it is just not likely!
    xatxtal likes this.

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    9
    Thank you. This was my first thought, was to check for if the rpm command was extant, but just like you said, I thought that the possibility of both being installed on the system was possible, however unlikely. Love the username! Great band.

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by pgymjp View Post
    Thank you. This was my first thought, was to check for if the rpm command was extant, but just like you said, I thought that the possibility of both being installed on the system was possible, however unlikely.
    yep. how about this? if both are installed, see how many packages have been installed via each package manager, e.g.:

    for deb-based:
    Code:
    dpkg -l|wc -l
    for rpm-based:
    Code:
    rpm -qa|wc -l
    Love the username! Great band.
    even better movie! okay, maybe...
    xatxtal likes this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •