Is there anyway I can list files by typing a command in the shell which lists all the file names, folder names and their permissions in CentOS?

  • Hi, thanks for the reply. Yes for example, if I have the following structure: Folder A > File 1, File 2, Folder AA [File AA1, File AA2] etc, so I wish to list all folders and all files inside these folders along with their permissions in a text file. I hope that makes sense? May 30, 2012 at 21:38

5 Answers 5


Have a look at tree, you may have to install it first. Per default tree does not show permissions, to show permissions next to the filename run

tree -p

which will recursively list all folders and directories within the current directory including permissions.


ls -lR lists the contents of directories recursively. The output is hard to process automatically, but for manual browsing it may be good because it's what you're familiar with.

The find command lists files recursively. You can customize its output, for example the following command prints permissions like ls -l does before each file name:

find -printf '%M %p\n'

This output can be processed mechanically if there are no newlines in your file names. If you replace \n (newline) by \000 (null byte), you can process the output with tools that support null-separated records.

Both ls and find only print traditional unix permissions, not access control lists. For a recursive listing of all file permissions including ACL information, run

getfacl -R .

The output can be processed mechanically (special characters are sorted); in particular, it can be fed to setfacl --restore to replicate the permissions to another tree with the same file names.


You want find for this.

find some/dir -ls > output.txt

From the find man page:


    True; list current file in ls -dils format on standard output.

From the ls man page:


    use a long listing format


The stat command executed by the find command will give you permissions and a whole lot more:

$ find . -exec stat {} +

  File: '.'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 10306h/66310d   Inode: 1326677     Links: 3
Access: (0775/drwxrwxr-x)  Uid: ( 1000/    rick)   Gid: ( 1000/    rick)
Access: 2020-06-24 17:00:52.131209006 -0600
Modify: 2020-06-13 09:21:40.489850096 -0600
Change: 2020-06-13 09:21:40.489850096 -0600
 Birth: -

  File: './.eyesome-sunset'
  Size: 8           Blocks: 8          IO Block: 4096   regular file
Device: 10306h/66310d   Inode: 1323438     Links: 1
Access: (0666/-rw-rw-rw-)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-06-23 04:32:44.808321580 -0600
Modify: 2020-06-02 16:37:33.282346160 -0600
Change: 2020-06-02 16:37:33.282346160 -0600
 Birth: -

ls is a command to list computer files in Unix

ls -l list items in directory
ls -R recursively list file

ls -lR
  • This was in Gilles answer. Also your explanation of ls -l doesn't explain what the -l is at all.
    – jesse_b
    Nov 14, 2019 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .