How can I find files that only have certain permission for owner?

后端 未结 2 1671
别跟我提以往
别跟我提以往 2020-12-14 00:19

I would like to find files only by a certain user\'s permission. For example, if I want to find a file that I have full permission.

I may do something like:

相关标签:
2条回答
  • 2020-12-14 00:38

    -perm -mode

    All of the permission bits mode are set for the file. Symbolic modes are accepted in this form, and this is usually the way in which would want to use them. You must specify 'u', 'g' or 'o' if you use a symbolic mode.

    find . -user $(whoami) -perm -007
    

    for the specified user, it returns files with the following privileges: rwx,

    find . -user $(whoami) -perm -006
    

    for the specified user, it returns files with the following privileges: rwx, rw,

    find . -user $(whoami) -perm -005
    

    for the specified user, it returns files with the following privileges: rwx, rx,

    find . -user $(whoami) -perm -004
    

    for the specified user, it returns files with the following privileges: rwx, rw, rx, r,

    find . -user $(whoami) -perm -003
    

    for the specified user, it returns files with the following privileges: rwx, wx,

    find . -user $(whoami) -perm -002
    

    for the specified user, it returns files with the following privileges: rwx, rw, wx, w,

    find . -user $(whoami) -perm -001
    

    for the specified user, it returns files with the following privileges: rwx, rx, wx, x,

    find . -user $(whoami) -perm -000
    

    for the specified user, it returns files with the following privileges: rwx, rw, rx, wx, r, w, x, 0,

    -perm /mode

    Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify 'u', 'g' or 'o' if you use a symbolic mode. See the EXAMPLES section for some illustrative examples. If no permission bits in mode are set, this test matches any file (the idea here is to be consistent with the behaviour of -perm -000).

    find . -user $(whoami) -perm /007
    

    for the specified user, it returns files with the following privileges: rwx, rw, rx, wx, r, w, x,

    find . -user $(whoami) -perm /006
    

    for the specified user, it returns files with the following privileges: rwx, rw, rx, wx, r, w,

    find . -user $(whoami) -perm /005
    

    for the specified user, it returns files with the following privileges: rwx, rw, rx, wx, r, x,

    find . -user $(whoami) -perm /004
    

    for the specified user, it returns files with the following privileges: rwx, rw, rx, r,

    find . -user $(whoami) -perm /003
    

    for the specified user, it returns files with the following privileges: rwx, rw, rx, wx, w, x,

    find . -user $(whoami) -perm /002
    

    for the specified user, it returns files with the following privileges: rwx, rw, wx, w,

    find . -user $(whoami) -perm /001
    

    for the specified user, it returns files with the following privileges: rwx, rx, wx, x,

    find . -user $(whoami) -perm /000
    

    for the specified user, it returns files with the following privileges: rwx, rx, rw, wx, r, w, x, 0.

    Examples have been tested.

    Source of citations.

    0 讨论(0)
  • 2020-12-14 00:43

    Start with:

    find /path/to/file -user user1 -perm -u+rwx
    

    This means: look for files starting in /path/to/files, owned by user1, where the permissions for group and other can be anything (- in front of the permission string) and the users permissions are only: rwx

    To search for files only (no directories) then add -type f.

    Also, try some reading. This has great examples: Find tutorial

    0 讨论(0)
提交回复
热议问题