Skip to main content
Version: current

Files

The File menu shows all user space files on the router. You can create a new file or directory, edit the file content, or delete a file or directory. If a RouterOS ".npk" package is uploaded, the file menu will also show package-specific information, for example, architecture, build date and time, etc.

[admin@MikroTik] > /file/print detail
0 name=wireless-7.16.1-arm.npk type=package size=1924.1KiB last-modified=2024-11-25 13:14:28 package-name="wireless" package-version="7.16.1" package-build-time=2024-10-10 14:03:32
package-architecture="arm"

1 name=routeros-7.16.1-arm.npk type=package size=11.1MiB last-modified=2024-11-25 13:14:34 package-name="system" package-version="7.16.1" package-build-time=2024-10-10 14:03:32
package-architecture="arm"

2 name=flash type=disk last-modified=2024-11-25 13:12:10

3 name=flash/skins type=directory last-modified=2024-11-25 13:10:52

4 name=flash/skins/newskin.json type=.json file size=0 last-modified=2024-11-25 13:10:52

5 name=flash/filename type=file size=0 last-modified=2024-11-25 13:11:58

6 name=flash/directory_name type=directory last-modified=2024-11-25 13:12:10

All parameters are documented in the /file CLI reference.

Storage details

If the device has a directory named "flash" in its file list, then files which you want to be kept after the system reboot/power cycle must be stored within it, as anything outside of it is kept within a RAM disk and will be lost upon reboot. This does not include .npk upgrade files as they will be applied by the upgrade process before the system discards the RAM drive content.

For multicore devices with NAND flash memory (e.g. CCR series routers, RB4011iGS), RouterOS uses a write-back cache that will buffer file changes into RAM memory instead of writing them immediately into flash media. The file changes will be stored on the flash when it is absolutely necessary. The writing can be delayed by up to 40 seconds. This helps to reduce CPU cycles, which results in better performance. However, this can cause empty or zero-length files when a device experiences a sudden power loss, because files were not fully saved on the flash.

In some cases, RouterOS may compress files to occupy less disk space. You will still see the original file size in the /file menu. However, in the /system/resource menu, you may notice that there is more free space than expected. The compressed file size is used when calculating the free-hdd-space value.

File operations

Create a new file or directory

To create a new file or directory, use the /file/add command:

[admin@MikroTik] > /file/add name=/flash/filename type=file
[admin@MikroTik] > file add name=/flash/directory_name type=directory

Get or read file contents

Using the get command, you can retrieve file contents only from files up to 60 KB in size. For accessing contents of larger files, use the /file/read command. The result is returned as an array.

For example:

[admin@MikroTik] > :put [/file/get text.txt contents]
123456

[admin@MikroTik] > /file/read file=text.txt offset=2 chunk-size=3
data: 345

Head or tail a file

Using /file/head and /file/tail commands, you can output the first or the last n lines of file contents.

For example:

/file/head test.txt n=3 numbered
1: 1
2: 2
3: 3

Copy a file or directory

Use the /file/copy command to clone a file or directory.

For example:

/file/copy test1.txt name=dir1/test1copy.txt
/file/copy dir1 name=dir2
/file/print
Columns: NAME, TYPE, SIZE, LAST-MODIFIED
# NAME TYPE SIZE LAST-MODIFIED
0 dir1 directory 2026-03-17 09:52:08
1 dir2 directory 2026-03-17 09:52:14
2 test1.txt .txt file 0 2026-03-17 09:51:43
3 dir1/test1copy.txt .txt file 0 2026-03-17 09:52:08
4 dir2/test1copy.txt .txt file 0 2026-03-17 09:52:14