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

getenforce

Show the SELinux mode (getenforce), or switch between enforcing and permissive until the next reboot (setenforce).

المستوى
امتحان RHCSA
المجموعة
SELinux والأمان
يحتاج root
للتغييرات
الحزمة
libselinux-utils
يُسمّى أيضًا
setenforce

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

ماذا يفعل

getenforce prints Enforcing, Permissive or Disabled. setenforce 0 switches to permissive (log only), setenforce 1 back to enforcing. It does not work when SELinux is disabled, and it does not change the boot mode — that is SELINUX= in /etc/selinux/config.

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

getenforce
setenforce Enforcing|Permissive|1|0

الخيارات 2

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

1, Enforcing
Enforce the policy.
0, Permissive
Only log denials.

أمثلة 10

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

  1. 1Show the mode

    getenforce
    Enforcing

    The normal state.

  2. 2Permissive for a test

    setenforce 0
    getenforce
    Permissive

    If the problem is gone now, SELinux was the cause.

  3. 3Back to enforcing

    setenforce 1

    Never forget this step.

  4. 4Mode at boot

    grep ^SELINUX= /etc/selinux/config
    SELINUX=enforcing

    Change here for the next boot.

  5. 5Test a service quickly

    setenforce 0; systemctl restart httpd; curl -I localhost; setenforce 1

    Compare the result with enforcing.

  6. 6Better: only one domain permissive

    semanage permissive -a httpd_t

    The rest of the system stays protected.

  7. 7Disabled system

    setenforce 1
    setenforce: SELinux is disabled

    Needs a config change, relabel and reboot.

  8. 8In a monitoring check (security)

    [ "$(getenforce)" = Enforcing ] || echo "ALERT: SELinux not enforcing on $(hostname)"

    Attackers often switch SELinux off.

  9. 9Check the kernel arguments

    grep -o 'selinux=[01]\|enforcing=[01]' /proc/cmdline

    selinux=0 disables SELinux; enforcing=0 boots permissive.

  10. 10Logged mode changes

    ausearch -m MAC_STATUS -ts today

    Who changed the mode and when.

رموز الخروج

0 :: Done. 1 :: Error (for example SELinux disabled).

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man 8 getenforce