The gMan nixWiki

Because the mind is made of Teflon...

User Tools

Site Tools


general_find

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
general_find [2020/11/17 02:38] – [Find Files by Timestamps] gmangeneral_find [2024/01/19 00:06] (current) gman
Line 1: Line 1:
 ====== Find Stuff in Linux ====== ====== Find Stuff in Linux ======
  
-There are three basic commands to find stuff in Linux: +There are four basic commands to find stuff in Linux: 
   - whereis   - whereis
   - which   - which
Line 64: Line 64:
  
 <code>find /path/to/search/ -name searchTerm 2>/dev/null</code> <code>find /path/to/search/ -name searchTerm 2>/dev/null</code>
 +
 +https://www.cyberithub.com/find-command-in-linux/
 +
 +The -exec flag to find causes find to execute the given command once per file matched, and it will place the name of the file wherever you put the {} placeholder. The command must end with a semicolon, which has to be escaped from the shell, either as \; or as ";".
 +
 +Syntax to be used for find exec multiple commands:
 +
 +<code>find {PATH} [OPTIONS] -exec {COMMAND} {} ;</code>
 +
 +**The first argument** after the find command is the location you wish to search. Although you may specify a specific directory, you can use a metacharacter to serve as a substitute. The three metacharacters that work with this command include:
 +  * Period (.): Specifies the current and all nested folders.
 +  * Forward Slash (/): Specifies the entire filesystem.
 +  * Tilde (~): Specifies the active user's home directory.
 +
 +Find all files (not directories or links) of 1033 bytes in size that are not executable and which can be read (i.e., you can cat the file and read the contents):
 +
 +<code>find . -type f -size 1033c ! -executable -exec cat {} \;</code>
  
 ---- ----
Line 79: Line 96:
  
 ---- ----
- 
  
 ==== Expressions ==== ==== Expressions ====
Line 103: Line 119:
  
 ^  Type  ^ Description  ^ ^  Type  ^ Description  ^
-|   block (buffered) special | +|   regular file |
-|  c  | character (buffered) special |+
 |  d  | directory | |  d  | directory |
 +|  l  | symbolic link |
 +|  c  | character device |
 +|  b  | block device |
 |  p  | named pipe (FIFO) | |  p  | named pipe (FIFO) |
-|  f  | regular file | 
 |  s  | socket | |  s  | socket |
  
Line 178: Line 195:
 find . -type f -perm -220 find . -type f -perm -220
 # find files writeable by BOTH owner AND group (but no one else) # find files writeable by BOTH owner AND group (but no one else)
 +
 +find / -perm /4000 -type f -exec ls -ld {} \; 2>/dev/null
 +# This will find files with the SUID bit set.
 +# -l long listing format
 +# -d list directory names, not contents
 </code> </code>
  
Line 221: Line 243:
 </code> </code>
  
 +----
  
general_find.1605580719.txt.gz · Last modified: by gman