الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

subscription-manager

Register a RHEL system with Red Hat, and turn Red Hat repositories on or off.

المستوى
امتحان RHCSA
المجموعة
حزم البرامج
يحتاج root
نعم
الحزمة
subscription-manager

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

A RHEL system must be registered to get software and updates from the Red Hat Content Delivery Network (CDN). subscription-manager connects the system to your Red Hat account (or your company's Satellite server) and manages the repositories it can use.

Today Red Hat uses Simple Content Access: after registration the system can use the repositories at once. The old steps to "attach" a subscription are no longer needed.

In a company, systems are usually registered with an organization ID and an activation key, so no personal password is used in scripts.

طريقة الكتابة

subscription-manager COMMAND [OPTIONS]
subscription-manager register [--username=USER] [--password=PASS] | [--org=ORG --activationkey=KEY]
subscription-manager repos [--list | --list-enabled | --enable=REPO | --disable=REPO]

الأجزاء الرئيسية

register
Connect this system to Red Hat (or Satellite).
unregister
Remove the system from the account and delete its identity.
status
Show if the system is registered and its content access state.
identity
Show the system ID and the organization.
repos
List, enable and disable repositories.
refresh
Get the newest data from the server.
release
Pin the system to a minor release (like 10.0) or remove the pin.
syspurpose
Set role, usage and service level of the system.
facts
Show the hardware and system facts that are sent to the server.
config
Show or change the settings in /etc/rhsm/rhsm.conf.
clean
Remove all local subscription data (without telling the server).
version
Show the versions of the tool and the server.

الخيارات 23

الأكثر استخدامًا

register

--username=user
The Red Hat account name.
--password=pass
The password (it is asked when you leave it out).
--org=id
The organization ID, used with an activation key.
--activationkey=key
Register with an activation key instead of a password.
--name=name
The name of the system in the account (default: the hostname).
--force
Register again, even if the system is already registered.
--serverurl=url
The server to register with (for Satellite).
--baseurl=url
The URL to get content from.
--release=ver
Pin the system to a minor release while registering.
--environments=list
Content environments (Satellite).
--proxy=host:port
Use a proxy server.
--proxyuser=user, --proxypassword=pass
Login for the proxy.
--insecure
Do not check the SSL certificate of the server (only for tests).

repos

--list
List all repositories the system may use.
--list-enabled
List only the enabled repositories.
--list-disabled
List only the disabled repositories.
--enable=repo
Enable a repository. Wildcards (*) are allowed.
--disable=repo
Disable a repository. Wildcards (*) are allowed.

release

--show
Show the current release pin.
--list
List the releases you can pin to.
--set=ver
Pin to this release, like 10.0.
--unset
Remove the pin and follow the newest minor release.

general

-h, --help
Show help (also after a command: subscription-manager repos --help).

أمثلة 12

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Register with your Red Hat account

    subscription-manager register --username your-rh-user

    The password is asked. After this, the BaseOS and AppStream repositories work.

  2. 2Register with an activation key (for automation)

    subscription-manager register --org 1234567 --activationkey web-servers

    No personal password in scripts. The key decides which repositories and settings the system gets.

  3. 3Check if the system is registered

    subscription-manager status

    Shows "Content Access Mode is set to Simple Content Access" on a working system.

  4. 4List the enabled repositories

    subscription-manager repos --list-enabled

    Faster than the full list. Compare with dnf repolist.

  5. 5Enable an extra repository

    subscription-manager repos --enable codeready-builder-for-rhel-10-x86_64-rpms

    CodeReady Builder has development packages that some build tools need.

  6. 6Disable all repositories, then enable only what you need

    subscription-manager repos --disable '*' --enable rhel-10-for-x86_64-baseos-rpms --enable rhel-10-for-x86_64-appstream-rpms

    A small set of repositories means a smaller attack surface and predictable updates.

  7. 7Pin a server to one minor release

    subscription-manager release --set=10.0
    dnf clean all

    Some certified software supports only one minor release. The pin stops updates to 10.1 until you remove it.

  8. 8Show the system ID

    subscription-manager identity

    Needed when you open a support case or remove an old system from the account.

  9. 9Register again after cloning a virtual machine

    subscription-manager clean
    subscription-manager register --org 1234567 --activationkey web-servers --force

    A cloned VM keeps the identity of the original. Clean it so both systems are not counted as one.

  10. 10Remove the system from the account before you delete it

    subscription-manager unregister

    Keeps the inventory in your Red Hat account clean.

  11. 11Register through a proxy

    subscription-manager register --org 1234567 --activationkey web-servers --proxy proxy.example.com:3128

    Servers in a protected network often reach the internet only through a proxy.

  12. 12Show which facts are sent to Red Hat

    subscription-manager facts --list | head -20

    Good to know for a privacy or security review.

انتبه

  • The exam systems are not registered. Software comes from repositories that the exam gives you.
  • --password on the command line ends up in the shell history. Leave it out so it is asked, or use an activation key.
  • After clean, the server still thinks the system exists. Use unregister when the system is still online.
  • Pinning a release stops security updates of newer minor releases. Remove the pin when the reason is gone.

الملفات

/etc/rhsm/rhsm.conf
Settings: server, proxy, repository options.
/etc/pki/consumer/
The identity certificate of the registered system.
/etc/yum.repos.d/redhat.repo
The Red Hat repositories, written by subscription-manager.
/var/log/rhsm/rhsm.log
Log file of the subscription tools.

نصائح للحفظ

  • Order: register → status → repos → dnf upgrade.
  • Company servers: org + activation key. Your lab: username.