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

nproc

Print the number of CPUs (cores/threads) that the current process can use.

المستوى
لينكس اليومي
المجموعة
معلومات النظام
يحتاج root
لا
الحزمة
coreutils

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

ماذا يفعل

nproc prints how many processing units are available — limited by CPU affinity and cgroup settings. Use it to compare with the load average, or to choose the number of parallel jobs.

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

nproc [OPTION]...

الخيارات 4

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

--all
All installed processors, not only the available ones.
--ignore=N
Leave out N processors.
--help
Show help.
--version
Show the version.

أمثلة 10

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

  1. 1Number of CPUs

    nproc
    2

    Usable now.

  2. 2All installed CPUs

    nproc --all
    4

    More than nproc = some are limited (affinity, cgroup, offline).

  3. 3Parallel build

    make -j"$(nproc)"

    One job per core.

  4. 4Keep one core free

    make -j"$(nproc --ignore=1)"

    The system stays usable.

  5. 5Compare with the load

    uptime; nproc

    Load above nproc = processes wait.

  6. 6Parallel compression

    xz -T"$(nproc)" big.tar

    All cores.

  7. 7In a container with a CPU limit

    podman run --rm --cpuset-cpus=0 registry.access.redhat.com/ubi10/ubi nproc
    1

    Containers see the limit.

  8. 8Limit a command to 2 CPUs

    taskset -c 0,1 nproc
    2

    CPU affinity changes the result.

  9. 9More details

    lscpu | grep -E '^(CPU\(s\)|Thread|Core|Socket)'

    Sockets, cores and threads.

  10. 10Script sizing

    WORKERS=$(( $(nproc) * 2 )); echo $WORKERS

    A common rule for web workers.

رموز الخروج

0 :: Done. 1 :: Error.

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

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

في الطرفية: man nproc