code: def get_version_msg_from_the_cmd(package_name, cmd=None, use_rpm=None,
                                   max_lines_of_the_output=None):
      
      if use_rpm is None:
          use_rpm = is_rpm_installed()
      if use_rpm:
          rpm_version = get_rpm_version(package_name=package_name)
          if rpm_version:
              return "{} (rpm)".format(rpm_version)
  
      try:
          cmd = cmd or [package_name, "--version"]
          version_result = subprocess.run(cmd,
                                          stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE)
          if version_result.returncode == 0:
              version_output = version_result.stdout.decode().rstrip()
              if max_lines_of_the_output:
                  version_output = " ".join(version_output.split('\n')[:max_lines_of_the_output])
              return version_output
  
          else:
              return "{}: cannot get version with {}".format(package_name, cmd)
      except FileNotFoundError:
          return "{} not accessible!".format(package_name)
docs: Get str with the version (or string representation of the error).
  
      :param package_name: str
      :param cmd: str or [str] (defaults to [package_name, "--version"])
      :param use_rpm: True/False/None (whether to use rpm -q for getting a version)
      :param max_lines_of_the_output: use first n lines of the output
      :return: str