# find and locate

## Syntax:

```
find <location> -user <username> -exec <komanda> <tapilan_fayllar> \;
```

## Task 1:

Find the files owned by harry, and ccopy it to cataog: `/opt/dir`

Solution:

```
mkdir -p /opt/dir
find / -user harry -exec cp -rfp {} /opt/dir/ \;
```

## Task 2:

Find all files owned by user 'alex' and redirect the output to `/home/alex/files`

Solution:

```
find / -user alex -type f > /home/alex/files
```

## Task 3:

Find all sizes of 10K file or directory under the `/etc`directory, and copy to `/tmp/findfiles`directory. Then, find all files or directories with Lucy as the owner, and copy them to `/tmp/findfiles`

Solution:

```
find /etc -size 10k -exec cp -r --parents {} /tmp/findfiles \;
find / -user Lucy -exec cp -r {} /tmp/findfiles \;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://alicenab.gitbook.io/linux/redhat/tasks/find-and-locate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
