Looking for files NOT owned by a specific user
The find(1) utility has primaries that can be negated ("reversed") using the "!" operator. On the prompt one must however escape the negation with a backslash as it is a shell metacharacter. Result:
find . \! -user foo -print
Using find to locate files not owned by USER or GROUP
not (X or Y) and (not X or not Y) are different things, negation is not a distributive operation. You indeed need parentheses there—as -o has a lower precedence than -a implied by the conjunction of primaries—, but also both predicates inside should be negated.
find . \( ! -user user -o ! -group group \) -exec chown user:group {} +
Find files which have (or have not) a specific owner
You can use the find command.
find (directory) -user (user)
find (directory) -not -user (user)
https://www.cyberciti.biz/faq/how-do-i-find-all-the-files-owned-by-a-particular-user-or-group/
How can I find files that only have certain permission for owner?
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
how to find files not owned by me in Google apps script
I think the updated answer as of now is to use DriveApp.searchFiles(params) (https://developers.google.com/apps-script/reference/drive/drive-app#searchFiles(String) ).
Code is something like:
// Log the name of every file in the user's Drive that shared with me
var files = DriveApp.searchFiles('sharedWithMe');
while (files.hasNext()) {
var file = files.next();
Logger.log(file.getName());
}
How to Use Powershell to find files that do not include a specific user in the ACL
Update your commands to the following:
Get-ChildItem 'Z:\Inbox' -Recurse |
Where {(Get-Acl $_.fullname).Access.IdentityReference.Value -notcontains 'domain\user'}
In your attempt, the problem is the chaining of where
commands. The Get-ChildItem
command returns objects when the Access
contains an entry that does not include domain\user
as a .IdentityReference.Value
. It will almost always have an Access
entry that doesn't contain that value since almost every folder contains multiple Access
objects.
What you should be after is only returning objects where the Access.IdentityReference.Value
collection never contains domain\user
.
listing files in UNIX owned by a particular user
It should be possible to use awk togheter with ls -l
ls -l | awk '$3=="user_2" { print $0 }'
this will print all lines where third field (user) matches "user_2"
find command: search for files owned by many users in one command
Try using the -o
syntax like this:
find ./ -user john -o -user akido
For further references, check Linux / Unix: Find All The Files Owned By a Particular User / Group
If you want to check the files belonging to users of a specific group:
find ./ -group name_of_group
Related Topics
Learning Kernel Hacking and Embedded Development at Home
How to Have Tcpdump Write to File and Standard Output the Appropriate Data
How to Set the Grep After Context to Be "Until the Next Blank Line"
How to Check the Bios Version or Name in Linux Through a Command Prompt
Error When Trying to Run .Asm File on Nasm on Ubuntu
How to Decrease the Size of Generated Binaries
What Context Does the Scheduler Code Run In
Bash with Aws Cli - Unable to Locate Credentials
How to Remove Jenkins Completely from Linux
In Unix, How to Run 'Make' in a Directory Without Cd'Ing to That Directory First
Find Files in Created Between a Date Range
How to Print Only the Hex Values from Hexdump Without the Line Numbers or the Ascii Table
How to Execute a Series of Commands in a Bash Subshell as Another User Using Sudo
Convert Multipage PDF to a Single Image
Why Does Perf Stat Show "Stalled-Cycles-Backend" as <Not Supported>
How to Know the Interrupt/Gpio Number for a Specific Pin in Linux