Recursively list files with file names, folder names and permission
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