Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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? – user1038814 May 30 '12 at 21:38
up vote 7 down vote accepted

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.

share|improve this answer
Thanks so much! It worked just how I wanted it. – user1038814 May 30 '12 at 21:58

You want find for this.

find some/dir -ls > output.txt
share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.