9

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? – user1038814 May 30 '12 at 21:38
11

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.

9

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.

5

You want find for this.

find some/dir -ls > output.txt
-1

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 '19 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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