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 on Linux where only root has read permission
find /home/mike/www/test -user root -perm +400 ! -perm +044 -print
-perm +400
matches files that have at least the owner-read mode set. -perm +044
matches files that have either group-read or other-read modes set, but !
inverts the test so these files are excluded from the result.
UPDATE:
The man page for find(GNU findutils) says:
-perm +mode This is no longer supported (and has been deprecated since 2005). Use -perm /mode instead."
The updated command should be:
find /home/mike/www/test -user root -perm /400 ! -perm /044 -print
Using `find -perm` to find when a permission is not set
Try:
find . ! -perm -g+r
How to add file execute permission for owner only in Git on Windows?
The only permissions that Git tracks (regardless of operating system) is the executable bit. This is by design:
Actually in a very early days, git used to record the full (mode & 0777)
for blobs.Once people started using git, everybody realized that it had a very
unpleasant side effect that the resulting tree depended on user's umasks,
because one person records a blob with mode 664 and the next person who
modifies the file would record with mode 644, and it made it very hard to
keep track of meaningful changes to the source code. This issue was fixed
long time ago with commit e447947 (Be much more liberal about the file
mode bits., 2005-04-16).
Note that Junio Hamano, the author of the quoted post, has been the main Git maintainer since 2005, shortly after it was created.
Granular execute permissions are best applied on deployment.
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
Related Topics
How to Pass Command Line Parameters from a File
Variables Set in a Bash 'While Read' Loop Are Unset After It
Comparing Two Files in Linux Terminal
Shell Script to Kill the Process Listening on Port 3000
How to Track Child Process Using Strace
Is There Any Modern Review of Solutions to the 10000 Client/Sec Problem
Maximum Number of Files/Directories on Linux
Why Disabling Interrupts Disables Kernel Preemption and How Spin Lock Disables Preemption
What Is the "Current" in Linux Kernel Source
How to Test If Your Linux Support Sse2
Multiple Ble Connections Using Linux and Bluez 5.0
All Newlines Are Removed When Saving Cat Output into a Variable
When "Vagrant Up" It Says "It Appears Your Machine Doesn't Support Nfs" (Debian Jessie)
How to Gently Kill Firefox Process on Linux/Os X