---
title: "pols files"
description: "List directories, watch files and track changes in a sandbox"
---

<!-- Generated by scripts/reference.mjs from the pols CLI's --help. Do not edit; run `npm run reference:sync`. -->

List a directory, watch the files under a path as they change, or track what
changed under a directory since a point in time. They act with root's rights,
or as a sandbox user with `--user` (only what it may read). Copy files with
`pols cp`.

## Usage

```text
pols files [flags]
pols files [command]
```

## Subcommands

| Command | Description |
| --- | --- |
| [`pols files changes`](#pols-files-changes) | List what changed under a tracked directory |
| [`pols files ls`](#pols-files-ls) | List a directory |
| [`pols files track`](#pols-files-track) | Start tracking the changes under a directory |
| [`pols files untrack`](#pols-files-untrack) | Stop tracking the changes under a directory |
| [`pols files watch`](#pols-files-watch) | Print the changes to files under a path as they happen |

## Flags

```text
-h, --help              help for files
-u, --user pols users   act as this sandbox user (see pols users; default: root)
```

## pols files changes

List the files and directories under DIR created, modified or deleted since
`pols files track` (at most 10,000).

### Usage

```text
pols files changes SANDBOX DIR [flags]
```

### Flags

```text
-h, --help   help for changes
```

## pols files ls

List a directory's entries (at most 10,000), without following symbolic links.

### Usage

```text
pols files ls SANDBOX PATH [flags]
```

### Examples

```sh
pols files ls web /home/user
```

### Flags

```text
-h, --help   help for ls
```

## pols files track

Remember what is under DIR now, so that `pols files changes` lists what was
created, modified or deleted since. Tracking again starts over. Tracking is
per user and stays across stop, resume and standby. At most 100,000 files.

### Usage

```text
pols files track SANDBOX DIR [flags]
```

### Examples

```sh
pols files track web /home/user/app
pols exec web -- bash -lc 'cd app && npm run codegen'
pols files changes web /home/user/app
```

### Flags

```text
-h, --help   help for track
```

## pols files untrack

Stop tracking the changes under a directory

### Usage

```text
pols files untrack SANDBOX DIR [flags]
```

### Flags

```text
-h, --help   help for untrack
```

## pols files watch

Watch a directory (and the directories below it, unless `--no-recursive`) or a
file, and print each file created, modified or deleted, until interrupted.
With `--json`, print the API's events, one JSON object per line. Changes the
watch cannot keep up with are reported as an overflow, not dropped silently.

### Usage

```text
pols files watch SANDBOX PATH [flags]
```

### Examples

```sh
pols files watch web /home/user/app
pols files watch web /home/user/app --json | jq -r .path
```

### Flags

```text
-h, --help           help for watch
    --no-recursive   watch only PATH itself, not the directories below it
```

The [global flags](/docs/reference/cli/#global-flags) work with this command too.
