# Linux ### [Show number of threads for a given process or total number threads across all processes](https://askubuntu.com/a/88983) Show number of threads for a given pid ```bash ps -o nlwp <pid> ``` To get the sum of all threads running in the system ```bash ps -eo nlwp | tail -n +2 | awk '{ num_threads += $1 } END { print num_threads }' ``` ### [Get maximum number of threads supported by the OS](https://stackoverflow.com/a/344292) ```bash cat /proc/sys/kernel/threads-max ``` Can be increased to e.g. `100000` like so: ```bash echo 100000 > /proc/sys/kernel/threads-max ``` However, memory allocated for maintaining a stack for each thread is usually the limiting factor.