Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Viewing Files and Directories on a Device Running Junos OS

Junos OS stores information in files on the device, including configuration files, log files, and router software files. This topic shows some examples of operational commands that you can use to view files and directories on a device running Junos OS.

Sections include:

Directories on the Router or Switch

Table 1 lists some standard directories on a device running Junos OS.

Table 1: Directories on the Router

DIrectory

Description

/config

This directory is located on the device’s router’s internal flash drive. It contains the active configuration (juniper.conf) and rollback files 1, 2, and 3.

/var/db/config

This directory is located on the router’sdevice’s hard drive and contains rollback files 4 through 49.

/var/tmp

This directory is located on thedevice’s hard drive. It holds core files from the various processes on the Routing Engines. Core files are generated when a particular process crashes and are used by Juniper Networks engineers to diagnose the reason for failure.

/var/log

This directory is located on the device’s hard drive. It contains files generated by both the device’s logging function as well as the traceoptions command.

/var/home

This directory is located on the device’s hard drive. It contains a subdirectory for each configured user on the device. These individual user directories are the default file location for many Junos OS commands.

/altroot

This directory is located on the device’s hard drive and contains a copy of the root file structure from the internal flash drive. This directory is used in certain disaster recovery modes where the internal flash drive is not operational.

/altconfig

This directory is located on the device’s hard drive and contains a copy of the /config file structure from the internal flash drive. This directory is also used in certain disaster recovery modes when the internal flash drive is not operational.

Listing Files and Directories

You can view the device’s directory structure as well as individual files by issuing the file command in operational mode.

  1. To get help about the file command, type the following:
    user@host> file ?
    Possible completions:
      <[Enter]>            Execute this command
      archive              Archives files from the system
      checksum             Calculate file checksum
      compare              Compare files
      copy                 Copy files (local or remote)
      delete               Delete files from the system
      list                 List file information
      rename               Rename files
      show                 Show file contents
      source-address       Local address to use in originating the connection
      |                    Pipe through a command
    user@host> file    

    Help shows that the file command includes several options for manipulating files.

  2. Use the list option to see the directory structure of the device. For example, to show the files located in your home directory on the device:
    user@host> file list.ssh/common

    The default directory for the file list command is the home directory of the user logged in to the device. In fact, the user’s home directory is the default directory for most of Junos OS commands requiring a filename.

  3. To view the contents of other file directories, specify the directory location. For example:
    user@host> file list /configjuniper.confjuniper.conf.1.gzjuniper.conf.2.gzjuniper.conf.3.gz
  4. You can also use the device’s context-sensitive help system to locate a directory. For example:
    user@host> file list /?
    Possible completions:
      <[Enter]>            Execute this command
      <path>               Path to list
      /COPYRIGHT           Size: 6355, Last changed: Feb 13 2005
      /altconfig/          Last changed: Aug 07 2007
      /altroot/            Last changed: Aug 07 2007
      /bin/                Last changed: Apr 09 22:31:35
      /boot/               Last changed: Apr 09 23:28:39
      /config/             Last changed: Apr 16 22:35:35
      /data/               Last changed: Aug 07 2007
      /dev/                Last changed: Apr 09 22:36:21
      /etc/                Last changed: Apr 11 03:14:22
      /kernel              Size: 27823246, Last changed: Aug 07 2007
      /mfs/                Last changed: Apr 09 22:36:49
      /mnt/                Last changed: Jan 11 2007
      /modules/            Last changed: Apr 09 22:33:54
      /opt/                Last changed: Apr 09 22:31:00
      /packages/           Last changed: Apr 09 22:34:38
      /proc/               Last changed: May 07 20:25:46
      /rdm.taf             Size: 498, Last changed: Apr 09 22:37:31
      /root/               Last changed: Apr 10 02:19:45
      /sbin/               Last changed: Apr 09 22:33:55
      /staging/            Last changed: Apr 09 23:28:41
      /tmp/                Last changed: Apr 11 03:14:49
      /usr/                Last changed: Apr 09 22:31:34
      /var/                Last changed: Apr 09 22:37:30
    user@host> file list /var/?
    <[Enter]> Execute this command <path> Path to list /var/account/ Last changed: Jul 09 2007 /var/at/ Last changed: Jul 09 2007 /var/backups/ Last changed: Jul 09 2007 /var/bin/ Last changed: Jul 09 2007 /var/crash/ Last changed: Apr 09 22:31:08 /var/cron/ Last changed: Jul 09 2007 /var/db/ Last changed: May 07 20:28:40 /var/empty/ Last changed: Jul 09 2007 /var/etc/ Last changed: Apr 16 22:35:36 /var/heimdal/ Last changed: Jul 10 2007 /var/home/ Last changed: Apr 09 22:59:18 /var/jail/ Last changed: Oct 31 2007 /var/log/ Last changed: Apr 17 02:00:10 /var/mail/ Last changed: Jul 09 2007 /var/msgs/ Last changed: Jul 09 2007 /var/named/ Last changed: Jul 10 2007 /var/packages/ Last changed: Jan 18 02:38:59 /var/pdb/ Last changed: Oct 31 2007 /var/preserve/ Last changed: Jul 09 2007 /var/run/ Last changed: Apr 17 02:00:01 /var/rundb/ Last changed: Apr 17 00:46:00 /var/rwho/ Last changed: Jul 09 2007 /var/sdb/ Last changed: Apr 09 22:37:31 /var/spool/ Last changed: Jul 09 2007 /var/sw/ Last changed: Jul 09 2007 /var/tmp/ Last changed: Apr 09 23:28:41 /var/transfer/ Last changed: Jul 09 2007 /var/yp/ Last changed: Jul 09 2007 user@host> file list /var/
  5. You can also display the contents of a file. For example:
    user@host>file show /var/log/inventory
    Jul 9 23:17:46 CHASSISD release 8.4I0 built by builder on 2007-06-12 07:58:27 UTC Jul 9 23:18:05 CHASSISD release 8.4I0 built by builder on 2007-06-12 07:58:27 UTC Jul 9 23:18:06 Routing Engine 0 - part number 740-003239, serial number 9000016755 Jul 9 23:18:15 Routing Engine 1 - part number 740-003239, serial number 9001018324 Jul 9 23:19:03 SSB 0 - part number 710-001951, serial number AZ8025 Jul 9 23:19:03 SSRAM bank 0 - part number 710-001385, serial number 243071 Jul 9 23:19:03 SSRAM bank 1 - part number 710-001385, serial number 410608 ...

Specifying Filenames and URLs

In some CLI commands and configuration statements—including file copy, file archive, load, save, set system login user username authentication load-key-file, and request system software add—you can include a filename. On a routing matrix, you can include chassis information as part of the filename (for example, lcc0, lcc0-re0, or lcc0-re1).

You can specify a filename or URL in one of the following ways:

  • filename—File in the user’s current directory on the local flash drive. You can use wildcards to specify multiple source files or a single destination file. Wildcards are not supported in Hypertext Transfer Protocol (HTTP) or FTP.

    Note: Wildcards are supported only by the file (compare | copy | delete | list | rename | show) commands. When you issue the file show command with a wildcard, it must resolve to one filename.

  • path/filename—File on the local flash disk.
  • /var/filename or /var/path/filename—File on the local hard disk. You can also specify a file on a local Routing Engine for a specific T640 router on a routing matrix:
    user@host> file delete lcc0-re0:/var/tmp/junk
  • a:filename or a:path/filename—File on the local drive. The default path is / (the root-level directory). The removable media can be in MS-DOS or UNIX (UFS) format.
  • hostname:/path/filename, hostname:filename, hostname:path/filename, or scp://hostname/path/filename—File on an scp/ssh client. This form is not available in the worldwide version of Junos OS. The default path is the user’s home directory on the remote system. You can also specify hostname as username@hostname.
  • ftp://hostname/path/filename—File on an FTP server. You can also specify hostname as username@hostname or username:password@hostname. The default path is the user’s home directory. To specify an absolute path, the path must start with %2F; for example, ftp://hostname/%2Fpath/filename. To have the system prompt you for the password, specify prompt in place of the password. If a password is required, and you do not specify the password or prompt, an error message is displayed:
    user@host> file copy ftp://username@ftp.hostname.net//filename
    file copy ftp.hostname.net: Not logged in.
    user@host> file copy ftp://username:prompt@ftp.hostname.net//filename
    Password for username@ftp.hostname.net:
  • http://hostname/path/filename—File on an HTTP server. You can also specify hostname as username@hostname or username:password@hostname. If a password is required and you omit it, you are prompted for it.
  • re0:/path/filename or re1:/path/filename—File on a local Routing Engine. You can also specify a file on a local Routing Engine for a specific T640 router on a routing matrix:
    user@host> show log lcc0-re1:chassisd

Published: 2013-01-15