Table of contents
1.
Introduction
2.
Arguments
2.1.
bulk delete
2.2.
delete
2.3.
download
2.4.
list
2.5.
metadata
2.6.
metadata from file
2.7.
show
2.8.
test
2.9.
upload
3.
Frequently Asked Questions
3.1.
What is a cookbook in software?
3.2.
What is a cookbook in DevOps?
3.3.
What is Knife?
3.4.
Why is a cookbook important?
3.5.
Why is Chef used in DevOps?
4.
Conclusion
Last Updated: Aug 13, 2025

Overview of Knife Cookbook

Author yuvatimankar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

A cookbook is a basic unit of configuration and policy distribution in Chef Infra. It defines a scenario and keeps everything needed to support it. The cookbook organizes material into recipes. The cookbook can do multiple tasks—cookbooks store values about the needed state of the node. And Knife is a tool that interfaces between the Chef Infra Server and local Chef-repo. The knife cookbook subcommand interacts with cookbooks in the local chef-repo or the Chef Infra server.

overview of knife cookbook

In this blog, we will discuss the various functions of knife cookbooks in detail. So, Stay till the end, and Let’s get started!

Arguments

bulk delete

bulk delete argument is used to delete files of cookbooks that match a pattern specified by a regular expression.  

Syntax knife cookbook bulk delete REGEX (options)
Options -p,  --purge
Example knife cookbook bulk delete “^[0-9] {3} $” -p

delete

delete argument is used to delete a particular cookbook version on the Chef Infra Server or cookbook.

Syntax knife cookbook delete NAME_OF_COOKBOOK [VERSION_OF_COOKBOOK] (options)
Options -a, --all
Example knife cookbook delete smartmon 0.8

download

download argument is used for downloading a cookbook from the Chef Infra Server to the present directory.

Syntax knife cookbook download NAME_OF_COOKBOOK [VERSION_OF_COOKBOOK] (options)
Options

-d DOWNLOAD_DIRECTORY, --dir DOWNLOAD_DIRECTORY, 

-N, --latest, -f, --force

Example knife cookbook download thiscookbook

list

List argument is used to see a list of cookbooks that are available at the moment on the Chef Infra Server. The list will only store the latest version for each cookbook by default.

Syntax knife cookbook list (options)
Options -a, -w, --all, --with-uri
Example knife cookbook list

metadata

metadata argument is used to create the metadata for one or more than one cookbook.

Syntax knife cookbook metadata (options)
Options -a, -o PATH: PATH, --all, --cookbook-path PATH: PATH 
Example knife cookbook metadata -a

metadata from file

metadata from file argument is used to load the metadata for the cookbook from a file.

Syntax knife cookbook metadata from file FILE
Options This argument does not contain any options.
example knife cookbook metadata from file /the/filepath

show

show argument is used to view information about a cookbook, files, parts of a cookbook(recipes, libraries, providers, attributes, resources, and templates), or a file connected with a cookbook.

Syntax knife cookbook show NAME_OF_COOKBOOK [VERSION_OF_COOKBOOK] [PART...] [FILE_NAME] (options)
Options
  • -f FQDN,
  • FILE_NAME,
  • --fqdn FQDN,
  • --platform PLATFORM, 
  • -p PLATFORM, 
  • -V PLATFORM_VERSION, 
  • PART,
  • --platform-version PLATFORM_VERSION,
  • -w,
  • --with-uri

Examples

To get the list of present versions of a cookbook named getting-started, use the following command:

Knife cookbook show getting-started


To display the list of data about a cookbook using the version and the name of the cookbook, use the following command:

knife cookbook show getting-started 0.3.0


To only see the data about the templates, you can use the following command:

knife cookbook show getting-started 0.3.0 templates


To see the information in JSON format, you can use the -F common option; you can use the following command:

knife cookbook show devops -F json

test

test argument is used to test a cookbook for syntax errors. This test argument uses RUBY syntax checking to verify each file in a cookbook that ends in Embedded Ruby and .rb.

Syntax knife cookbook test NAME_OF_COOKBOOK (options)
Options -a, -o PATH:PATH, --all, --cookbook-path PATH:PATH
Example knife cookbook test cookbook_name

upload

upload argument is used to upload one or more than one cookbooks from the local repository into the Chef Infra Server. Files already uploaded on the Chef Infra server will not be uploaded.

Syntax knife cookbook upload [NAME_OF_COOKBOOK...] (options)
Options
  • -a,--all
  • --concurrency
  • -d, --include-dependencies
  • -E ENVIRONMENT, -- environment ENVIRONMENT
  • --force
  • --freeze
  • -o PATH: PATH, --cookbook-path PATH: PATH

Examples

To upload a cookbook, use the following command:

knife cookbook upload name_of_cookbook


To upload a cookbook and then freeze, you can use the following command:

knife cookbook upload redis --freeze

Frequently Asked Questions

What is a cookbook in software?

A cookbook in the context of programming means a collection of small programs depicting a particular programming concept.

What is a cookbook in DevOps?

In terms of DevOps, Cookbooks are the fundamental unit of Chef, which has all the details related to working units and can change the configuration.

What is Knife?

A knife is a command-line tool that interfaces between a chef Infra Server and local chef-repo.

Why is a cookbook important?

A cookbook is important because it allows us to dive into that culture and traditions while educating its readers about the importance and joy of cooking.

Why is Chef used in DevOps?

In DevOps, Chef manages and deploys servers and applications in-house and on the cloud.

Conclusion

In this article, we discussed the overview of the Knife Cookbook. We started by introducing the cookbook, then we saw some arguments about the knife cookbook.

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive ProgrammingJavaScriptSystem Design, etc. Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Happy learning, Ninja

Live masterclass