How to list files recursively in Linux


Recursive means that Linux command works with the contains of directories, and if a directory has files, the command works on those files too (recursively).

if you want to receive the list, all directories and files recursively try the following commands, you should read this article.

List files recursively

I have a directory like this, it’s called unixcop, it contains sub directories and they contain a files.

I can display them with tree command, so just install it on your system:

sudo dnf install -y tree   #CentOS
sudo apt install -y tree   #ubuntu

Then display the directory with

tree + [directory _name]

For my example:

tree unixcop

Some examples to get a recursive directory listing in Linux system:

  • Linux recursive directory listing using ls -R command in the current working directory.
ls -R
  • the same command but with a specific directory
ls -R unixcop
  • Recursive directory listing using find command with print option instead of -R .
find unixcop/ -print
find unixcop/ -print -ls
  • Also you can use namei command with -l (list option) to recursive a directory listing its contents but with displaying the ownership and their permissions as shown in the above command output but with another command.
namei -l [full path]
namei-l unixcop/mahmoud/qadry/
  • You can use du command recursively to calculate the directories and files usage as shown below.
du -ah unixcop/

-h for human readable.

  • To run command recursively on files. use the syntax below:
[command] $(find /dir/ -name 'pattern' -print)
rm -i $(find unixcop/ -name '*.sh' -print)


That’s it

We illustrated how to list file recursively in Linux.

Thank you

unixcop Admin


Please enter your comment!
Please enter your name here

Latest articles

You might also likeRELATED

How to set PassivePortRange and PassiveIP in pure-ftpd on Ubuntu to secure the app!

Introduction Hi guys, We will talk about setting PassivePortRange and PassiveIP in pure-ftpd. If you run a firewall on your Linux server and want to...

Install Java 8 on CentOS 8

Hi Guys, In this guide, we’ll show you how to install Oracle’s Java 8 programming language on CentOS 8 . It's an object-oriented language...

How to install flameshot on RHEL/CentOS using Snapcraft

In this post, you will learn how to install Flameshot on RHEL / CentOS Flameshot is a powerful open source screenshot and annotation tool for...