WeOS
5.29.0

# Filesystem

## Overview

Warning

This context is used for direct file-access and should therefore be used with caution. For example, erase will not keep track if the file is used by any other device subsystem. Therefore, performing this action on used files may cause unforeseen behaviour.

The file context provides a number of commands to handle files in certain predefined directories located on internal and external media.

The commands are:

- diff - Compare two files
- dir - List files
- copy - Copy file from/to internal or external media
- show - Show file
- erase - Erase configuration
- import - Import file from remote source onto filesystem
- export - Export file to remote destination

The following subcontexts can be selected in the file context. Each subcontext has its own set of implicit directories and set of suitable commands for the applicable type of file.

- cfg Configuration file
- log Log files

File system commands are accessed from the admin execution context in the following manner:

    example:/#> file
    example:/file/#>

Then selecting subcontext:

    example:/file#> log
    example:/file/log#>

Or one can move to the subcontext directly:

    example:/#> file log
    example:/file/log#>

## Media selector

Throughout this series of commands the keyword media can be used to select between internal media and available external media. External media is a connected USB-stick or SD-card, internal media is the builtin storage.

For additional information on the Media tools and commands, refer to this page.

For additional information on how to access external media, refer to this page

## Cfg

Handling of configuration files.

`diff [media <label>] <FILE1> [media <label>] <FILE2>`

  Compare two configuration files. Shows the differences between two files

  Example:

      example:/file/#> cfg
      example:/file/cfg/#> diff config0.cfg media internal config1.cfg
      — config0.cfg
      +++ config1.cfg
      @@ -1,6 +1,6 @@
      {
          “meta”: {
      -   “id”: “factory-config.cfg”,
      +   “id”: “Example”,
          “vendor”: “Westermo”,
          “os”: “WeOS”,
          “release”: “5.3”

  `media`
    Media selector. Select any available media. If media keyword is omitted configured boot media is used.
`dir [media <label>] [subdir]`

  List files on internal or external media.

  Example:

      example:/file/#> cfg
      example:/file/cfg/#> dir
      /cfg/                 MOD. DATE/LINK    SIZE  MD5
      config0.cfg           2025-01-14 13:44  2724
      config99.cfg          2025-02-04 14:16  9739  a38550e2507d12fc61bf119df2c9481c
      startup-config.cfg -> config0.cfg
      startup-config.lnk    2024-12-04 11:28    12
      Free: 45.0 MiB | Total: 45.3 MiB

  `media`
    Media selector. Select any available media. If media keyword is omitted configured boot media is used.
  `subdir`
    Optional sub directory to list contents of.
`copy [media <label>] <src> [media <label>] <dst>`

  Copy file from from/to internal or external media. If media keyword is omitted configured boot media is used.

  Example:

      example:/file/#> cfg
      example:/file/cfg/#> copy config0.cfg media external config_ex.cfg

  `media`
    Media selector. Select any available media. If media keyword is omitted configured boot media is used.
  `src`
    Source filename
  `dst`
    Destination filename
`erase [media <label>] <file>`

  Erase file

  Example:

      example:/file/#> cfg
      example:/file/cfg/#> erase example.cfg

  `media`
    Media selector. Select any available media. If media keyword is omitted configured boot media is used.
  `file`
    File to erase.
`show [media <label>] <file> [KEYWORD[ KEYWORD ...]`

  Show configuration

  If no keyword is given, the command shows the entire configuration file.

  If keywords are given that matches keys within the JSON file, only those sections are shown. The keywords can be nested, for example: show config0.cfg bridge 0 vlan

  Example:

      example:/file/#> cfg
      example:/file/cfg/#> show config0.cfg bridge 0 vlan
      [
      {
          “vid”: 1,
          “id”: “vlan1”,
          “enable”: true,
          “untagged”: [
          “all”
          ],
          “multicast-snooping”: true,
          “priority”: 0
      }
      ]

  `media`
    Media selector. Select any available media. If media keyword is omitted configured boot media is used.
  `file`
    File to show.
`import [SOURCE] [DESTINATION]`

  Import configuration from remote source onto filesystem.

  Example:

      import proto ftp user user1 password pw1 192.0.2.1 remote_path local_file

  `SOURCE`

    `[proto <ftp|tftp|scp|sftp|http|https>] [user <username>] [password <password>] <address[:port]> <remote_path>`

    `proto`
      Protocol to use. ftp, tftp, scp, sftp, http or https.
    `username`
      Username if used by protocol.
    `password`
      Password if used by protocol.
    `remote_path`
      Path on the remote side.
  `DESTINATION`

    `[media <label>] <local_file>`

    `media`
      Media selector. Select any available media.
    `local_file`
      File to use as destination
`export [SOURCE] [DESTINATION]`

  Export configuration file to remote destination.

  If the remote filename is omitted the local filename is used as the destination filename.

  Example:

      example:/file/#> cfg
      example:/file/cfg/#> export local_file proto ftp user user1 password pw1 192.168.0.2.1 remote_path

  `SOURCE`

    `[media <label>] <local_file>`

    `media`
      Media selector. Select any available media.
    `local_file`
      File to use as source
  `DESTINATION`

    `[proto <ftp|tftp|scp|sftp|http|https>] [user <username>] [password <password>] <address[:port]> <remote_path>`

    `proto`
      Protocol to use. ftp, tftp, scp, sftp, http or https.
    `username`
      Username if used by protocol.
    `password`
      Password if used by protocol.
    `remote_path`
      Path to be used on the remote side.

## Log

Handling of log files.

`dir [media <label>] [subdir]`

  List files on internal or external media

  Example:

      example:/file/#> log
      example:/file/log/#> dir
      /log/                 MOD. DATE/LINK    SIZE  MD5
      bootsettings.log      2025-02-24 12:20    20
      btmp                  2025-02-24 12:20     0
      kern.log              2025-02-24 12:24 51539
      lastlog               2025-02-24 12:20     0
      messages              2025-02-24 12:20  7533
      mount.log             2025-02-24 12:20  1908
      ntp.log               2025-02-24 12:20   240
      syslog                2025-02-24 12:20 59072
      wtmp                  2025-02-24 12:20  2304
      Free: 45.0 MiB | Total: 45.3 MiB

  `media`
    Optional selector for external or internal media. If media keyword is omitted internal media is used.
  `subdir`
    Optional sub directory to list contents of.
`follow [media <label>] <file>`

  Continuously monitor a (log) file, like UNIX ‘tail -F’.

  Example:

      example:/file/#> log
      example:/file/log/#> follow messages

  `media`
    Media selector. Select any available media. If media keyword is omitted internal media is used.
  `file`
    File to follow.
`copy [media <label>] <src> [media <label>] <dst>`

  Copy file from/to internal or external media.

  Example:

      example:/file/#> log
      example:/file/log/#> copy messages media external messages

  `media`
    Media selector. Select any available media. If media keyword is omitted internal media is used.
  `src`
    Source filename
  `dst`
    Destination filename
`erase [media <label>] <file>`

  Erase file

  Example:

      example:/file/#> log
      example:/file/log/#> erase example.log

  `media`
    Media selector. Select any available media. If media keyword is omitted internal media is used.
  `file`
    File to erase.
`show [media <label>] <file>`

  Show content of file on internal or external media.

  Example:

      example:/file/#> log
      example:/file/log/#> show example.log
      Test content

  `media`
    Media selector. Select any available media. If media keyword is omitted internal media is used.
  `file`
    File to show.
`export [SOURCE] [DESTINATION]`

  Export log to remote destination

  If the remote filename is omitted the local filename is used as the destination filename.

  Example:

      example:/file/#> log
      example:/file/log/#> export local_file proto ftp user user1 password pw1 192.168.0.2.1 remote_path

  `SOURCE`

    `[media <label>] <local_file>`

    `media`
      Media selector. Select any available media.
    `local_file`
      File to use as source
  `DESTINATION`

    `[proto <ftp|tftp|scp|sftp|http|https>] [user <username>] [password <password>] <address[:port]> <remote_path>`

    `proto`
      Protocol to use. ftp, tftp, scp, sftp, http or https.
    `username`
      Username if used by protocol.
    `password`
      Password if used by protocol.
    `remote_path`
      Path to be used on the remote side.

« Previous Next »