Introduction
Knife is a command-line utility that acts as an interface between a local chef-repo and the Chef Infra Server. Knife aids users in managing Nodes, Recipes, cookbooks, Environments, roles, and data bags, Various cloud environments' resources, the process of installing the Chef Infra Client on nodes, and searching through the Chef Infra Server's index of data.
This blog explains the details of Knife along with the details of Knife Subcommands, Verb Subcommands, and Knife Plug-ins.
Without further ado, let's get started.

Knife Subcommands
Cookbooks, nodes, data bags, roles, environments, and users are just a few of the objects in an organisation that may be targeted with precise actions using Knife's built-in subcommands.
Knife Command Syntax
The syntax for all knife subcommands is as follows:
Command:
knife subcommand [ARGUMENT] (options)
Each subcommand has a unique set of options and arguments.
Built-in Subcommands
The following are the Built-in Subcommands of
-
knife_bootstrap
This subcommand is used to run a bootstrap operation that installs Chef Infra Client on the target system. The IP address or FQDN of the destination system must be specified during the bootstrap operation.
-
knife_client
This subcommand is used to handle an API client list and the RSA public key pairs that go with it. Any entity that uses the Chef Infra Server API, such as the Chef Infra Client and Knife, can now send authentication requests to the Chef Infra Server.
-
knife configure
This subcommand is used to create the client.rb and credential files and then distribute them to workstations and nodes.
-
knife cookbook
To communicate with cookbooks that are kept on the local chef-repo or the Chef Infra Server, use the knife cookbook subcommand.
-
Data knife bag
This subcommand is used to utilize the knife data bag subcommand to manage arbitrary JSON data stores that are accessible worldwide.
-
knife delete
This subcommand is used for the purpose of removing an item from a Chef Infra Server. With just a single verb, this subcommand performs operations akin to those of the knife cookbook delete, knife data bag delete, knife node deletes, knife environment delete, and knife role delete commands (and a single action).
-
knife deps
This subcommand is used to determine the dependencies for a node, role, or cookbook using the knife deps subcommand.
-
knife diff
This subcommand is used to compare the differences between the files and directories on the Chef Infra Server and in the chef-repo. For instance, to check that particular files are the same across several production environments before utilising the knife download and knife upload subcommands to upload or download files from the Chef Infra Server. This subcommand can be used to compare what is in the chef-repo with what has been synced to a git repository, much like the git diff command.
-
knife download
Using the knife download subcommand, you can download roles, cookbooks, environments, nodes, and data bags to the current working directory from the Chef Infra Server. It can be used to extract out-of-process modifications users may have made to the files on the Chef Infra Server, such that if a user made a change that obviated version source control, investigate the state of one or more files, or back up data on the Chef Infra Server. Knife upload, which performs the opposite of knife download, and knife diff, which may be used to examine exactly what changes will be downloaded, are frequently used in conjunction with this subcommand.
-
knife edit
This subcommand is used to modify objects on the Chef Infra Server. Similar to the knife role edit, knife environment edit, knife node edit, knife cookbook edit, and knife data bag edit, but with just one verb (and a single action).
-
knife environment
On the Chef Infra Server, use the knife environment subcommand to manage environments for a single organisation.
-
knife exec
You can use the knife exec subcommand to run Ruby scripts inside of a Chef Infra Client that is properly set up. Use this subcommand in order to run scripts that will only seldom (or once) visit the Chef Infra Server or whenever the action does not require full use of the knife subcommand library.
-
knife list
This subcommand is used to view a list of items on the Chef Infra Server. With only one verb, this subcommand functions similarly to the knife data bag list, knife environment list, knife node list, and knife role list (and a single action).
-
knife node
This subcommand is used for control over the nodes that are present on a Chef Infra Server.
-
knife raw
This subcommand is used to send a REST call to an endpoint in the Chef Infra Server API.
-
knife recipe list
This subcommand is used to view every recipe on a Chef Infra Server. Use a regular expression to restrict the results to recipes that adhere to a given pattern. There must be quotation marks around the regular expression and no forward slashes (/).
-
knife role
This subcommand is used to handle the roles connected to one or more nodes on a Chef Infra Server.
-
knife search
Run a search query for data that is indexed on a Chef Infra Server using the knife search subcommand.
-
knife serve
This subcommand is used to perform a persistent chef-zero against the local chef-repo. This is equivalent to launching the Chef Infra Client executable in local mode. The Chef Infra Server will automatically locate the chef-repo path and bind to the first open port between 8889 and 9999. The local Chef Infra Server's URL will be printed by Knife serve so that it may be added to the config.rb file.
-
knife show
This subcommand inspects the specifics of one (or more) object on the Chef Infra Server. With just one verb, this subcommand performs operations akin to those of the knife cookbook show, knife data bag show, knife environment show, knife node show, and knife role show (and a single action).
-
knife ssh
Invoke SSH operations (in parallel) on a selection of nodes within an organisation using the knife ssh subcommand, based on the outcomes of a search query sent to the Chef Infra Server.
-
knife ssl check
This subcommand is used to check the SSL configuration for the Chef Infra Server or a destination indicated by a URL or URI. The OpenSSL protocol will not use invalid certificates.
-
knife ssl fetch
This subcommand is used to copy SSL certificates from an HTTPS server to the trusted certs dir directory, which Knife and Chef Infra Client use to hold trusted SSL certificates. Running knife ssl fetch is the sole action necessary to confirm a remote server that is reached by either knife or Chef Infra Client when these certificates match the hostname of the remote server.
-
knife status
You may get a quick rundown of the nodes on a Chef Infra Server, along with the time of the recent successful Chef Infra Client run, by using the knife status subcommand.
-
knife tag
Using the knife tag subcommand, you can tag nodes on a Chef Infra Server.
-
knife supermarket
This subcommand is used to communicate with the cookbooks that are offered in the Chef Supermarket. Any community activity that writes data to this site requires a user account. Downloading, installing, and listing arguments don't require a user account.
-
knife upload
To upload data from the chef-current repo's working directory to the Chef Infra Server, use the knife upload subcommand. With the use of this subcommand, the following data types may be uploaded:- Cookbooks
- Data bags
- Roles stored as JSON data
-
Environments stored as JSON data
Knife diff, which can be used to view exactly what changes will be posted, and knife download, which performs the opposite of knife upload, are frequently used in conjunction with this subcommand.
-
knife user
This subcommand is used to manage the list of users and the RSA public key pairs that are associated with them.
-
knife xargs
This subcommand is used to download patterns from standard input as JSON, run a program against the JSON, and then upload any modifications.
Let's look into the details of Verb Subcommands.






