# 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 \;
```
