Skip to content

Instantly share code, notes, and snippets.

@henri
Last active November 18, 2025 20:48
Show Gist options
  • Select an option

  • Save henri/bf8cbcb1fc08c64742d4ba0b4de75ae5 to your computer and use it in GitHub Desktop.

Select an option

Save henri/bf8cbcb1fc08c64742d4ba0b4de75ae5 to your computer and use it in GitHub Desktop.

Revisions

  1. henri revised this gist Nov 18, 2025. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions open_files_linux_cheat_sheet.txt
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,10 @@
    # show the limits in place on the system
    ulimit -a

    # system wide ulmits
    ulimit -Sn # soft limit
    ulimit -Hn # hard limit

    # list open files for all processes and sort them by how many files are open
    for pid in /proc/[0-9]*; do echo "PID = $(basename $pid) : $(ls $pid/fd 2>/dev/null | wc -l) open files"; done | sort -n -k5,5

  2. henri revised this gist Nov 18, 2025. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions open_files_linux_cheat_sheet.txt
    Original file line number Diff line number Diff line change
    @@ -3,3 +3,9 @@ ulimit -a

    # list open files for all processes and sort them by how many files are open
    for pid in /proc/[0-9]*; do echo "PID = $(basename $pid) : $(ls $pid/fd 2>/dev/null | wc -l) open files"; done | sort -n -k5,5

    # list all open files (provided not to many
    lsof | wc -l

    # list open files outout blocking - may not provide accurate counts
    lsof -b 2>&1 | wc -l
  3. henri created this gist Nov 18, 2025.
    5 changes: 5 additions & 0 deletions open_files_linux_cheat_sheet.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # show the limits in place on the system
    ulimit -a

    # list open files for all processes and sort them by how many files are open
    for pid in /proc/[0-9]*; do echo "PID = $(basename $pid) : $(ls $pid/fd 2>/dev/null | wc -l) open files"; done | sort -n -k5,5