general_find
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
general_find [2020/11/17 02:36] – [Find Files by Type] gman | general_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: | ||
< | < | ||
+ | |||
+ | https:// | ||
+ | |||
+ | 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: | ||
+ | |||
+ | < | ||
+ | |||
+ | **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): | ||
+ | |||
+ | < | ||
---- | ---- | ||
Line 79: | Line 96: | ||
---- | ---- | ||
- | |||
==== Expressions ==== | ==== Expressions ==== | ||
Line 102: | Line 118: | ||
Use the '' | Use the '' | ||
- | ^ Type ^ Description | + | ^ Type ^ Description |
- | | s | block (buffered) special | + | | |
- | | c | character | + | | |
- | | d | directory | + | | l | symbolic link | |
- | | p | named pipe (FIFO) | | + | | |
- | | f | regular file | | + | | |
- | | s | socket | | + | | p | named pipe (FIFO) | |
+ | | s | socket | | ||
**Examples: ** | **Examples: ** | ||
Line 124: | Line 141: | ||
Use the '' | Use the '' | ||
* '' | * '' | ||
- | * '' | + | * '' |
- | ^ Suffix | + | ^ Suffix |
- | | b | blocks (512 bytes), default | | + | | b | blocks (512 bytes), default | |
- | | c | bytes | | + | | c | bytes | |
- | | k | kilobytes | | + | | k | kilobytes | |
- | | M | Megabytes | | + | | M | Megabytes | |
- | | G | Gigabytes | | + | | G | Gigabytes | |
- | ^ Prefix | + | ^ Prefix |
- | | + | greater than | | + | | + | greater than | |
- | | - | less than | | + | | - | less than | |
**Example: | **Example: | ||
Line 157: | Line 174: | ||
Use the '' | Use the '' | ||
- | - No prefix: find exact permissions | + | - **No prefix:** find exact permissions |
- | - Prefix of ' | + | - **Prefix of ' |
- | - Prefix of '/': | + | - **Prefix of '/': |
**Examples: | **Examples: | ||
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>/ | ||
+ | # This will find files with the SUID bit set. | ||
+ | # -l long listing format | ||
+ | # -d list directory names, not contents | ||
</ | </ | ||
Line 188: | Line 210: | ||
Three timestamps for **DAYS** (24-hour periods): | Three timestamps for **DAYS** (24-hour periods): | ||
- | ^ Type ^ Description | + | ^ Type ^ Description |
- | | atime | shows when the file was last accessed (e.g., read) | | + | | atime | shows when the file was last accessed (e.g., read) | |
- | | mtime | shows when the file contents were last modified | | + | | mtime | shows when the file contents were last modified | |
- | | ctime | shows when metadata was last changed (including content modification) | | + | | ctime | shows when metadata was last changed (including content modification) | |
Three timestamps for **MINUTES** (60-second periods) | Three timestamps for **MINUTES** (60-second periods) | ||
- | ^ Type ^ Description | + | ^ Type ^ Description |
- | | amin | file was last accessed (e.g., read) | | + | | amin | file was last accessed (e.g., read) | |
- | | mmin | file contents were last modified | | + | | mmin | file contents were last modified | |
- | | cmin | file metadata was last changed (including content modification) | | + | | cmin | file metadata was last changed (including content modification) | |
- | ^ Prefix | + | ^ Prefix |
- | | + | greater than | | + | | + | greater than | |
- | | - | less than | | + | | - | less than | |
**Note:** Any fractional part of the time period is ignored. Therefore '' | **Note:** Any fractional part of the time period is ignored. Therefore '' | ||
Line 221: | Line 243: | ||
</ | </ | ||
+ | ---- | ||
general_find.1605580566.txt.gz · Last modified: by gman