> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to List Files Recursively in Linux command line
- URL: https://linuxhandbook.com/list-files-recursively/
- Published: 2022-10-06T12:54:00.000Z
- Updated: 2023-10-01T06:47:09.000Z
- Description: Want to list files recursively and see the contents of all the subdirectories in Linux? Here's how you can do that.
- Author: Sagar Sharma
- Tags: Quick Tip

The ls command is the default for viewing the contents of a directory. This is despite the existence of the [dedicated dir command](https://linuxhandbook.com/dir-command/).

The [ls command](https://linuxhandbook.com/ls-command/) list the contents of the present directory, but it doesn't show the contents of the subdirectories by default. You can make it though.

## Use ls command to list files recursively

You can change the default behavior of the [ls command to list files recursively](https://linuxhandbook.com/ls-recursive/) by using the `-R` option. 

```
ls -R Directory_name
```

![list files in linux recursively ](https://linuxhandbook.com/content/images/2022/11/ls--R.png)

As you can see, it shows the contents of every subdirectory one by one. 

That's uppercase `R`. the lowercase `r` is used for the reverse display of ls output.

But wait, you can't expect Linux to have just one solution. Here are some other ways of listing files recursively.

## Use the tree command to list files recursively

By far, this is my favorite utility when it comes to listing files recursively as it gets the output in the easiest way possible. 

But it does not come pre-installed in most distributions. If you're on a Debian-based distro, you can use this command for installation:

```
sudo apt install tree
```

Once you are done with the installation, you just have to append the filename with the [tree command](https://linuxhandbook.com/tree-command/):

```
tree Directory_name
```

![use the tree command to list files recursively in linux](https://linuxhandbook.com/content/images/2022/11/use-the-tree-command-to-list-files-recursively-in-linux.png)

## Use the find command to list files recursively 

You'll find me often praising the [find command being so extensive](https://linuxhandbook.com/find-command-examples/) with more than 50 options and can also be used for listing files recursively.

You can recursively search sub-directories with the `-ls` option of the find command. It will list all the files but not the hidden files. It will show additional information such as [read-write permissions](https://learnubuntu.com/check-file-permissions/?ref=linuxhandbook.com):

```
find Directory_name -ls
```

![how to use find command to print files recursively in linux](https://linuxhandbook.com/content/images/2022/11/find-command-with--ls-option.png)

Similarly, you can also use the `-print` option with the find command if you just want to list files recursively:

```
find Directory_name -print
```

![use the find command to list files recursively ](https://linuxhandbook.com/content/images/2022/11/use--print-option-with-the-find-command.png)

## Use the du command to list files recursively

The [du command is used to show the storage size of files](https://linuxhandbook.com/find-directory-size-du-command/) and when used with the `-a` option, it will count and print the files recursively. 

But I'm also going to use the `-c` option that will sum the total number of files available in the specified directory:

![use the du command to list files recursively in linux](https://linuxhandbook.com/content/images/2022/11/use-the-du-command-to-list-files-recursively.png)

## Wrapping Up

This was my take on how you can print files recursively in Linux. But you can do more with those utilities with enough knowledge. 

And we have a detailed guide on how you can [make the most out of man pages in Linux](https://linuxhandbook.com/man-pages/) so you can be creative whenever you want!