We can use -user option to filter files or directories belonging to a specific user.
1) list all files, from description, all files belong to user "aubinxia"(first one), and belong to group "aubinxia" (second one)
2) We use find command to list files belonging to user "aubinxia"
3) "!" means not. We use find command to list all files not belonging to user "aubinxia"
4) We use find command to list files belonging to group "aubinxia"
5) We use find command to list all files not belonging to group "aubinxia"
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ ls -lrt
total 4
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oc
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
drwxrwxr-x 2 aubinxia aubinxia 4096 Jul 4 11:58 dir
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -user aubinxia
dir
dir/d2
dir/d1
oa
ob
oc
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * ! -user aubinxia
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -group aubinxia
dir
dir/d2
dir/d1
oa
ob
oc
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * ! -group aubinxia
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$
2. Find command: -perm
-perm option allows find command to find files whose permission are satisfied.
1) List all files in local directory
2) find all files in local directory whose permission is exactly "664"(rw-rw-r--)
3) find all files in local directory whose permission is exactly "662"(rw-rw--w-)
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ ls -lrt
total 4
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oc
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
drwxrwxr-x 2 aubinxia aubinxia 4096 Jul 4 11:58 dir
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -perm 664 -ls
920603 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d2
920593 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d1
131137 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
131266 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
134220 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oc
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -perm 662 -ls
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$
=========================================1) List all files in local directory
2) Find all files in local directory whose permission satisfies: +444(r--r--r--), there are 3 read bits turned up, as long as the file's permission has one of these 3 bits on, then it will be selected
3) Find all files in local directory whose permission satisfies: +777(rwxrwxrwx), as long as file's permission has one of these 9 bits on, then it will be selected.
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ ls -l
total 4
drwxrwxr-x 2 aubinxia aubinxia 4096 Jul 4 11:58 dir
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
-r--r--r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oc
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -perm +444 -ls
920592 4 drwxrwxr-x 2 aubinxia aubinxia 4096 Jul 4 11:58 dir
920603 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d2
920593 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d1
131137 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
131266 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
134220 0 -r--r--r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oc
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -perm +777 -ls
920592 4 drwxrwxr-x 2 aubinxia aubinxia 4096 Jul 4 11:58 dir
920603 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d2
920593 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d1
131137 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
131266 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
134220 0 -r--r--r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oc
=============================================1) List all files in local directory
2) Find all files in local directory whose permission satisfies: -664(rw-rw-r--), there are 5 bits on. As long as file's permission has all these 5 bits on, it will be selected, even if other bits are also on. So in this case, all files are selected unless oc.
3) Find all files in local directory whose permission satisfies: -444(r--r--r--), there are 3 bits on. As long as file's permission has all these 3 bits on, it will be selected. So in this case, all files are selected.
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ ls -l
total 4
drwxrwxr-x 2 aubinxia aubinxia 4096 Jul 4 11:58 dir
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
-rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
-r--r--r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oc
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -perm -664 -ls
920592 4 drwxrwxr-x 2 aubinxia aubinxia 4096 Jul 4 11:58 dir
920603 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d2
920593 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d1
131137 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
131266 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -perm -444 -ls
920592 4 drwxrwxr-x 2 aubinxia aubinxia 4096 Jul 4 11:58 dir
920603 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d2
920593 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 dir/d1
131137 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oa
131266 0 -rw-rw-r-- 1 aubinxia aubinxia 0 Jul 4 11:58 ob
134220 0 -r--r--r-- 1 aubinxia aubinxia 0 Jul 4 11:58 oc
3. Find command: -size
size option helps find command to filter files by file size
1) List all files in local directory with size information
2) "-size 7c" means find command will list all files with 7 bytes. c means byte here.
3) "-size 13c" means find command will list all files with 13 bytes, c means byte here.
4) "-size -16c" means find command will list all files less than 16 bytes. "-" means less than.
5) "-size +16c" means find command will list all files greater than 16 bytes. "+" means greater than.
6) "-size +11k" means find command will list all files greater than 11kb."k" means kb.
7) "-size +11M" means find command will list all files greater than 11Mb. "M" means Mb.
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ ls -lrt
total 13340
-rw-rw-r-- 1 aubinxia aubinxia 7 Jul 4 15:14 o1
-rw-rw-r-- 1 aubinxia aubinxia 13 Jul 4 15:14 o2
-rw-rw-r-- 1 aubinxia aubinxia 16 Jul 4 15:14 o3
-rw-rw-r-- 1 aubinxia aubinxia 13312 Jul 4 15:18 o4
-rw-rw-r-- 1 aubinxia aubinxia 13631488 Jul 4 15:19 o5
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -size 7c
o1
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -size 13c
o2
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -size -16c
o1
o2
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -size +16c
o4
o5
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -size +11k
o4
o5
aubinxia@aubinxia-fastdev:~/Desktop/xxdev$ find * -size +11M
o5
No comments:
Post a Comment