Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  KNIFE (1)


knife - The man page for the knife command line tool. \$1 \n[an-margin] level \n[rst2man-indent-level] level margin: \n[rst2man-indent\n[rst2man-indent-level]] - \n[rst2man-indent0] \n[rst2man-indent1] \n[rst2man-indent2]

Knife is a command-line tool that provides an interface between a local chef-repo and the Chef server. Knife helps users to manage:
o Nodes
o Cookbooks and recipes
o Roles
o Stores of JSON data (data bags), including encrypted data
o Environments
o Cloud resources, including provisioning
o The installation of the chef-client on management workstations
o Searching of indexed data on the Chef server

Knife subcommands:
o knife bootstrap
o knife client
o knife configure
o knife cookbook
o knife cookbook site
o knife data bag
o knife delete
o knife deps
o knife diff
o knife download
o knife edit
o knife environment
o knife exec
o knife list
o knife node
o knife raw
o knife recipe list
o knife role
o knife search
o knife show
o knife ssh
o knife status
o knife tag
o knife upload
o knife user
o knife xargs


Working With Knife
     Common Options
     JSON Data Format
     Set the Text Editor
     Using Quotes


Knife runs from a management workstation and sits in-between a Chef server and an organization\(aqs infrastructure. Knife interacts with a Chef server by using the same REST API that is used by a chef-client. Role-based authentication controls (RBAC) can be used to authorize changes when Knife is run with Enterprise Chef. Knife is configured during workstation setup, but subsequent modifications can be made using the knife.rb configuration file.

    Common Options

The following options can be run with all Knife sub-commands and plug-ins:
  The configuration file to use. For example, when Knife is run from a node that is configured to be managed by the Chef server, this option is used to allow Knife to use the same credentials as the chef-client when communicating with the Chef server.
--chef-zero-port PORT
  The port on which chef-zero will listen.
-d, --disable-editing
  Use to prevent the $EDITOR from being opened and to accept data as-is.
  Use to have Knife use the default value instead of asking a user to provide one.
-e EDITOR, --editor EDITOR
  The $EDITOR that is used for all interactive commands.
  The name of the environment. When this option is added to a command, the command will run only against the named environment. This option is ignored during search queries made using the knife search subcommand.
-F FORMAT, --format FORMAT
  The output format: summary (default), text, json, yaml, and pp.
-h, --help Shows help for the command.
-k KEY, --key KEY
  The private key that Knife will use to sign requests made by the API client to the Chef server.
  Use to view colored output.
  Use to show data after a destructive operation.
-s URL, --server-url URL
  The URL for the Chef server.
-u USER, --user USER
  The user name used by Knife to sign requests made by the API client to the Chef server. Authentication will fail if the user name does not match the private key.
-v, --version
  The version of the chef-client.
-V, --verbose
  Set for more verbose outputs. Use -VV for maximum verbosity.
-y, --yes Use to respond to all confirmation prompts with "Yes". Knife will not ask for confirmation.
-z, --local-mode
  Use to run the chef-client in local mode. This allows all commands that work against the Chef server to also work against the local chef-repo.

    JSON Data Format

Most data is entered using a text editor in JSON format, unless the --disable-editing option is entered as part of a command. (Encrypted data bags use YAML, which is a superset of JSON.) JSON is a common, language-independent data format that provides a simple text representation of arbitrary data structures. For more information about JSON, see or

    Set the Text Editor

Some Knife commands, such as knife data bag edit, require that information be edited as JSON data using a text editor. For example, the following command:

$ knife data bag edit admins admin_name

will open up the text editor with data similar to:

  "id": "admin_name"

Changes to that file can then be made:

  "id": "Justin C."
  "description": "I am passing the time by letting time pass over me ..."

The type of text editor that is used by Knife can be configured by adding an entry to the knife.rb file or by setting an EDITOR environment variable. For example, to configure the text editor to always open with vim, add the following to the knife.rb file:

knife[:editor] = "/usr/bin/vim"

When a Microsoft Windows file path is enclosed in a double-quoted string (" "), the same backslash character (\) that is used to define the file path separator is also used in Ruby to define an escape character. The knife.rb file is a Ruby file; therefore, file path separators must be escaped. In addition, spaces in the file path must be replaced with ~1 so that the length of each section within the file path is not more than 8 characters. For example, if EditPad Pro is the text editor of choice and is located at the following path:

C:\\Program Files (x86)\EditPad Pro\EditPad.exe

the setting in the knife.rb file would be similar to:

knife[:editor] = "C:\\Progra~1\\EditPa~1\\EditPad.exe"

One approach to working around the double- vs. single-quote issue is to put the single-quotes outside of the double-quotes. For example, for Notepad++:

knife[:editor] = \(aq"C:\Program Files (x86)\Notepad++\notepad++.exe -nosession -multiInst"\(aq

for Sublime Text:

knife[:editor] = \(aq"C:\Program Files\Sublime Text 2\sublime_text.exe --wait"\(aq

for TextPad:

knife[:editor] = \(aq"C:\Program Files (x86)\TextPad 7\TextPad.exe"\(aq

and for vim:

knife[:editor] = \(aq"C:\Program Files (x86)\vim\vim74\gvim.exe"\(aq

    Using Quotes

Values can be entered with double quotes (" ") or single quotes (\(aq \(aq), but this should be done consistently.


Knife comes with a collection of built in subcommands that work together to provide all of the functionality required to take specific actions against any object in an organization, including cookbooks, nodes, roles, data bags, environments, and users. A Knife plugin extends the functionality beyond built-in subcommands.

Knife has the following subcommands: bootstrap, client, configure, cookbook, cookbook site, data bag, delete, deps, diff, download, edit, environment, exec, index rebuild, list, node, recipe list, role, search, show, ssh, status, tag, upload, user, and xargs.

NOTE: The following subcommands run only against the open source Chef server: index rebuild and user.


All Knife subcommands have the following syntax: knife subcommand [ARGUMENT] (options)

Each subcommand has its own set of arguments and options.

NOTE: All syntax examples in this document show variables in ALL_CAPS. For example -u PORT_LIST (where PORT_LIST is a comma-separated list of local and public UDP ports) or -F FORMAT (where FORMAT determines the output format, either summary, text, json, yaml, or pp). These variables often require specific values that are unique to each organization.


Search for    or go to Top of page |  Section 1 |  Main Index

KNIFE (1) Chef 11.14

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.