In most cases, vmkfstools and other commands are used to manipulate virtual machine files. In some cases, you might have to view and manipulate files on remote ESXi hosts directly.
Caution If you manipulate files directly, your vSphere setup might end up in an inconsistent state. Use the vSphere Web Client or one of the other vCLI commands to manipulate virtual machine configuration files and virtual disks.The vifs command performs common operations such as copy, remove, get, and put on ESXi files and directories. The command is supported against ESXi hosts but not against vCenter Server systems.Some similarities between vifs and DOS or UNIX/Linux file system management utilities exist, but there are many differences. For example, vifs does not support wildcard characters or current directories and, as a result, relative pathnames. Use vifs only as documented.Instead of using the vifs command, you can browse datastore contents and host files by using a Web browser. Connect to the following location:The vifs command supports different operations for the following groups of files and directories. Different operations are available for each group, and you specify locations with a different syntax. The behavior differs for vSphere 4.x and vSphere 5.0.
Host configuration files. You must specify the file’s unique name identifier.Specify host locations by using the /host/<path> syntax. Host configuration files. You must specify the file’s unique name identifier.Specify host locations by using the /host/<path> syntax. The /tmp directory and files in that directory.Specify temp locations by using the /tmp/dir/subdir syntax.
■ Datastore prefix style: '[ds_name] relative_path'. For example:'[myStorage1] testvms/VM1/VM1.vmx'(Linux) or "[myStorage1] testvms/VM1/VM1.vmx" (Windows)
■ URL style: /folder/dir/subdir/file?dsName=<name>. For example:The two example paths refer to a virtual machine configuration file for the virtual machine VM1 in the testvms/VM1 directory of the myStorage1 datastore.To avoid problems with directory names that use special characters or spaces, enclose the path in quotes for both operating systems.When you run vifs, you can specify the operation name and argument and one of the standard connection options. Use aliases, symbolic links, or wrapper scripts to simplify the invocation syntax.
vifs command-specific options allow you to retrieve and upload files from the remote host and perform a number of other operations. All vifs options work on datastore files or directories. Some options also work on host files and files in the temp directory. You must also specify connection options.
- -copy-c <source> <target> Copies a file in a datastore to another location in a datastore. The <source> must be a remote source path, the <target> a remote target path or directory.The - -force option replaces existing destination files. Datastore Temp - -dir Datastore Temp dir datastore_directory_path - -force Datastore Temp - -get-g <remote_path> <local_path> Downloads a file from the ESXi host to the machine on which you run vCLI. This operation uses HTTP GET. Datastore Host get src_dstore_file_path dst_local_file_pathget src_d store_dir_path dst_local_file_path - -listdc Datastore Host - -listds Lists the datastore names on the ESXi system. When multiple data centers are available, use the - -dc (-Z) argument to specify the name of the datacenter from which you want to list the datastore. Datastore Host vifs - -listds - -mkdir Creates a directory in a datastore. This operation fails if the parent directory of dst_datastore_file_path does not exist. Datastore Temp - -move-m <source> <target> Moves a file in a datastore to another location in a datastore. The <source> must be a remote source path, the <target> a remote target path or directory.The - -force option replaces existing destination files. Datastore Temp - -put Uploads a file from the machine on which you run vCLI to the ESXi host. This operation uses HTTP PUT.This command can replace existing host files but cannot create new files. Datastore Host Temp put src_local_file_path dst_file_pathput src_local_file_path dst_directory_path - -rm Datastore Temp - -rmdir Deletes a datastore directory. This operation fails if the directory is not empty. Datastore Temp You can use vifs to interact with the remote ESXi or vCenter Server system in a variety of ways. Specify one of the connection options listed in Connection Options in place of <conn_options>. The examples illustrate use on a Linux system, use double quotes instead of single quotes when on a Windows system.
■ List all data centers on a vCenter Server system with --listdc, using --server to point to the vCenter Server system.
■ List all datastores on an ESXi host with --listds.You can use each name that has been returned to refer to datastore paths by using square bracket notation, as follows:The command lists the directory content. In this example, the command lists the contents of a virtual machine directory.
■ Create a new directory in a datastore with --mkdir <remote_dir>.
■ Remove a directory with --rmdir <remote_dir>.
■ Forcibly remove a directory with --rmdir --force <remote_dir>.
■ Update a file on the remote server with --put <local_path> <remote_path>.
■ Retrieve a file from the remote server with --get <remote_path> <local_path>|<local_dir>. The command overwrites the local file if it exists. If you do not specify a file name, the filename of the remote file is used.vifs --server <my_ESXi> --username root --password <pswd> --get '[Storage1] test/testfile' /tmp/tfile
■ Delete a file on the remote server with -rm <remote_path>.
■ Forcibly remove a file on the remote server with --rm <remote_path> --force.
■ Move a file from one location on the remote server to another location with --move <remote_source_path> <remote_target_path>. If you specify a file name, the file is moved and renamed at the same time.vifs --server <my_ESXi> --username root --password <pswd> --move '[Storage1] test/tfile' '[Storage1] newfile'vifs --server <my_ESXi> --username root --password <pswd> --move '[Storage1] test/tfile2' '[Storage1] test2/tfile' --forcevifs --server <my_ESXi> --username root --password <pswd> --copy '[Storage1] test/tfile' '[Storage1] test/tfile2'vifs --server <my_ESXi> --username root --password <pswd> --copy '[Storage1] test/tfile' '[Storage1] test/tfile2' --forceThe following example scenario illustrates other uses of vifs. Specify one of the connection options listed in Connection Options in place of <conn_options>.
2 vifs <conn_options> - -put /tmp/test_doc '[osdc-cx700-03] vcli_test/test_doc'vifs <conn_options> - -move '[osdc-cx700-03] vcli_test/test_doc'