In ubuntu we can see a list of files with permissions, simply using the commandls -l. But can I add the filter in this case? For example, a list of all files that are permission set to read only?



ls doesn't provide this – it's typically used for just tweaking display options. What you can do instead involves using find. For example:

find . -perm -g+s

To mimic ls's behavior of only listing files in the current directors, use the -maxdepth 1 option.

The possible combinations are endless. Refer to the find help linked above for more examples and the syntax differences in using - or / before the mode, also with respect to / being a GNU-only extension and + being used in BSD-style find.


ls does not directly support sorting by permissions, but you can combine it with the sort command:

ls -l | sort

You can use the -k option to sort to start matching from a specific character, the format is -k FIELD.CHAR, the permissions are the first field in the ls output. So e.g. -k 1.2 will start from the second character of the permission string, which will ignore any directory / device / link etc. flag, or -k 1.5 for sorting by group permissions.

If you don't want the additional output of ls -l, you can remove it with awk:

 ls -l | sort | awk '{ print $1, $NF}'

This will print only the first field (the permissions) and the last one (the filename).

| improve this answer | |

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