Directory trees can contain configuration files, backups, and dotfiles several levels below the path you are checking. On Linux, GNU find lists files and folders recursively so you can inspect a directory and its subdirectories in one view.

ls -R lists directory contents recursively, grouping names under each directory heading. GNU find instead prints one path per line, including hidden files and directories by default, so it suits a complete path list or a listing limited by file type or depth.

Recursive listings can become noisy on large trees or when the starting path includes protected directories, mounted volumes, or network storage. Start from the narrowest directory that contains the files of interest, add -maxdepth when only the first few levels matter, and add -xdev when a scan from a mount root such as / or /var should stay on one filesystem.

Steps to list files and folders recursively in Linux:

  1. List the starting directory and its subdirectories with ls -R.
    $ ls -R /srv/recursive-demo
    /srv/recursive-demo:
    README.md
    config
    docs
    logs
    
    /srv/recursive-demo/config:
    app.conf
    
    /srv/recursive-demo/docs:
    archive
    notes-2025.txt
    
    /srv/recursive-demo/docs/archive:
    notes-2024.txt
    
    /srv/recursive-demo/logs:
    app.log
    app.log.1

    Uppercase -R enables recursion; -l alone does not. ls -lR /srv/recursive-demo adds permissions, owners, sizes, and timestamps. ls -R omits hidden entries by default; ls -laR /srv/recursive-demo includes them. For hidden-file listing details, see How to show hidden files and folders in Linux.

  2. Print every path below the starting directory to get the full recursive view. Example output:
    $ find /srv/recursive-demo
    /srv/recursive-demo
    /srv/recursive-demo/logs
    /srv/recursive-demo/logs/app.log
    /srv/recursive-demo/logs/app.log.1
    /srv/recursive-demo/README.md
    /srv/recursive-demo/.hidden-root
    /srv/recursive-demo/docs
    /srv/recursive-demo/docs/notes-2025.txt
    /srv/recursive-demo/docs/archive
    /srv/recursive-demo/docs/archive/notes-2024.txt
    /srv/recursive-demo/config
    /srv/recursive-demo/config/app.conf
    /srv/recursive-demo/config/.env

    find walks the tree directly, so hidden entries such as .hidden-root and config/.env appear without an extra flag.

  3. Print names relative to the starting directory when the list should be easier to compare. Example output:
    $ find /srv/recursive-demo -mindepth 1 -printf '%P\n'
    logs
    logs/app.log
    logs/app.log.1
    README.md
    .hidden-root
    docs
    docs/notes-2025.txt
    docs/archive
    docs/archive/notes-2024.txt
    config
    config/app.conf
    config/.env

    -mindepth 1 omits the starting directory itself, and %P removes the starting-path prefix from each printed entry.

  4. Limit the recursive list to regular files when only file paths matter. Example output:
    $ find /srv/recursive-demo -type f -printf '%P\n'
    logs/app.log
    logs/app.log.1
    README.md
    .hidden-root
    docs/notes-2025.txt
    docs/archive/notes-2024.txt
    config/app.conf
    config/.env

    -type f excludes directories, symlinks, device nodes, and other non-regular entries.

  5. Limit the recursive list to subdirectories when the directory structure matters more than the files inside it. Example output:
    $ find /srv/recursive-demo -mindepth 1 -type d -printf '%P\n'
    logs
    docs
    docs/archive
    config

    Keeping -mindepth 1 in the directory-only view removes the starting directory from the result set.

  6. Stop descending after the required number of levels when the top of the tree is enough. Example output:
    $ find /srv/recursive-demo -maxdepth 2 -mindepth 1 -printf '%P\n'
    logs
    logs/app.log
    logs/app.log.1
    README.md
    .hidden-root
    docs
    docs/notes-2025.txt
    docs/archive
    config
    config/app.conf
    config/.env

    -maxdepth 2 includes the starting directory's children and grandchildren, but it does not descend into deeper entries such as docs/archive/notes-2024.txt.

  7. Add metadata when the recursive list also needs permissions, owners, sizes, or timestamps. Example output:
    $ find /srv/recursive-demo -ls
      3014781      4 drwxr-xr-x   5 root     root         4096 Apr 14 01:23 /srv/recursive-demo
      3014784      4 drwxr-xr-x   2 root     root         4096 Apr 14 01:23 /srv/recursive-demo/logs
      3014791      4 -rw-r--r--   1 root     root            3 Apr 14 01:23 /srv/recursive-demo/logs/app.log
      3014792      4 -rw-r--r--   1 root     root            6 Apr 14 01:23 /srv/recursive-demo/logs/app.log.1
      3014793      4 -rw-r--r--   1 root     root            6 Apr 14 01:23 /srv/recursive-demo/README.md
      3014794      4 -rw-r--r--   1 root     root            6 Apr 14 01:23 /srv/recursive-demo/.hidden-root
    ##### snipped #####

    Use -ls for a human-readable audit, and use -print0 instead of newline output when another command must receive paths that may contain spaces or newlines.

Share this guide