From 6dd8503d060fbe523d9e7cb898d2b47c1b52c619 Mon Sep 17 00:00:00 2001 From: trimstray Date: Tue, 25 Feb 2020 08:13:35 +0100 Subject: [PATCH] add new 'find' oneliners - signed-off-by: trimstray --- README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ace41a8..cd15156 100644 --- a/README.md +++ b/README.md @@ -1982,16 +1982,35 @@ cd /var/www/site && find . -type d -exec chmod g+x {} \; cd /var/www/site && find . -type d -exec chmod g+rwx {} + ``` -###### Find files and directories for specific user +###### Find files and directories for specific user/group ```bash +# User: find . -user -print +find /etc -type f -user -name "*.conf" + +# Group: +find /opt -group +find /etc -type f -group -iname "*.conf" ``` -###### Find files and directories for all without specific user +###### Find files and directories for all without specific user/group ```bash -find . \!-user -print +# User: +find . \! -user -print + +# Group: +find . \! -group +``` + +###### Looking for files/directories that only have certain permission + +```bash +# User: +find . -user -perm -u+rw # -rw-r--r-- +find /home -user $(whoami) -perm 777 # -rwxrwxrwx +find /home -type d -group -perm 755 # -rwxr-xr-x ``` ###### Delete older files than 60 days