Overview

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

It is possible to retrieve content and edit files up to 60KB in size. For accessing contents of larger files, please refer to section Get File Contents.


[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 

Create new file or directory

To create a new file or directory: 

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

Properties

PropertyDescription
contents (string; Default: )File contents that must be added. Works only for type=file
name (string; Default: )File/directory name
type (file | directory; Default: file)Specifies type 


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 a NAND flash memory (e.g. CCR series routers, RB4011iGS), RouterOS uses a write-back that will cache file changes into RAM memory instead of writing them straight away 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 a flash.

Properties

PropertyDescription
contents (string; Default: )The actual content of the file

creation-time (time)

Until RouterOS 7.16

A time when the file was created

last-modified (time

The time when the file was created or last modified. Introduced instead of creation-time in RouterOS 7.16.

name (string)Name of the file
package-architecture (string)Architecture that package is built for. Applies only to RouterOS ".npk" files
package-built-time (string)A time when the package was built. Applies only to RouterOS ".npk" files
package-name (string)Name of the installable package that. Applies only to RouterOS ".npk" files
package-version (string)A version of the installable package that. Applies only to RouterOS ".npk" files
size (integer)File size in bytes
type (string)Type of the file. For folders, the file type is the directory

Get file contents

Using the get command, it is possible to retrieve file contents only from files up to 60KB in size. For accessing contents of larger files, use command read. 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

Properties

PropertyDescription
chunk-size (integer [1..32768]; Default: )Chunk size that will be read from file
file (string; Default: )File name from which to read
offset (integer; Default:)Specifies offset where to start read file


  • No labels