{"id":32017,"date":"2026-11-30T22:07:57","date_gmt":"2026-11-30T22:07:57","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=32017"},"modified":"2026-11-30T22:07:57","modified_gmt":"2026-11-30T22:07:57","slug":"chef-tutorials-uninstalling-chef-software-chef-automate-and-chef-server","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/chef-tutorials-uninstalling-chef-software-chef-automate-and-chef-server\/","title":{"rendered":"Chef Tutorials: Uninstalling Chef Software, chef-automate and chef-server"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This guide shows how to fully remove Chef Automate, Chef Infra Server and the Chef client tools from a Linux host. It explains what each command in the example above does, gives a safer corrected order, covers backups and leftover files, and ends with checks that confirm the host is clean.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">$ systemctl stop chef-automate\r\n$ pkill chef-automate\r\n$ rm -rf \/hab\r\n$ userdel hab\r\n$ chef-server-ctl uninstall<\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">What the commands above do<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Chef Automate 2.x runs as a set of Habitat services under <code>\/hab<\/code>, managed by one systemd unit named <code>chef-automate<\/code>. A standalone Chef Infra Server is an Omnibus package installed under <code>\/opt\/opscode<\/code> and managed with <code>chef-server-ctl<\/code>. The example above mixes both products, so it helps to know what each line affects.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Command<\/th><th>Effect<\/th><th>What it leaves behind<\/th><\/tr><\/thead><tbody><tr><td><code>systemctl stop chef-automate<\/code><\/td><td>Stops the Automate systemd unit and its Habitat supervisor<\/td><td>The unit stays enabled and starts again after a reboot<\/td><\/tr><tr><td><code>pkill chef-automate<\/code><\/td><td>Kills any remaining <code>chef-automate<\/code> processes<\/td><td><code>hab-launch<\/code>, <code>hab-sup<\/code> and service processes with other names<\/td><\/tr><tr><td><code>rm -rf \/hab<\/code><\/td><td>Deletes all Habitat packages, service data and configuration<\/td><td>The systemd unit file and the <code>chef-automate<\/code> binary<\/td><\/tr><tr><td><code>userdel hab<\/code><\/td><td>Removes the <code>hab<\/code> user<\/td><td>The <code>hab<\/code> group, if other members still use it<\/td><\/tr><tr><td><code>chef-server-ctl uninstall<\/code><\/td><td>Stops Infra Server services and removes the application<\/td><td>All data in <code>\/var\/opt\/opscode<\/code>, the configuration and the <code>chef-server-core<\/code> package<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Every command here needs root. Run them as root or with <code>sudo<\/code>. The <code>$<\/code> prompt in the example above suggests a normal user, which makes most of them fail with permission errors.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Back up before you remove anything<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">All of these steps destroy data for good. If there is any chance you will need the cookbooks, node data, compliance reports or user accounts later, take a backup first and copy it off the host.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Chef Automate: creates a backup under \/var\/opt\/chef-automate\/backups by default<\/span>\nsudo chef-automate backup create\nsudo chef-automate backup <span class=\"hljs-keyword\">list<\/span>\n\n<span class=\"hljs-comment\"># Standalone Chef Infra Server: writes a tarball under \/var\/opt\/chef-backup<\/span>\nsudo chef-server-ctl backup\n\n<span class=\"hljs-comment\"># Copy the backups somewhere safe before uninstalling<\/span>\nsudo rsync -a \/<span class=\"hljs-keyword\">var<\/span>\/opt\/chef-automate\/backups\/ backup-host:\/srv\/chef-automate-backups\/\nsudo rsync -a \/<span class=\"hljs-keyword\">var<\/span>\/opt\/chef-backup\/ backup-host:\/srv\/chef-server-backups\/<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Backup locations can be changed in configuration. If the paths above are empty, check the output of the backup command for the real location.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Corrected version of the commands above<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Chef Automate has its own uninstall subcommand. It stops the services, removes the systemd unit and deletes Automate data, so you do not need to kill processes or delete <code>\/hab<\/code> by hand. If Chef Infra Server was deployed <strong>with<\/strong> Automate (<code>chef-automate deploy --product automate --product infra-server<\/code>), it runs as a Habitat package, and <code>chef-automate uninstall<\/code> removes it too. In that setup <code>chef-server-ctl<\/code> lives under <code>\/hab<\/code>, so it stops working once <code>\/hab<\/code> is deleted. That is why the last line of the original fails.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># 1. Uninstall Chef Automate (and any Infra Server deployed with it)<\/span>\nsudo chef-automate uninstall\n\n<span class=\"hljs-comment\"># 2. If the systemd unit is still present, stop, disable and remove it<\/span>\nsudo systemctl stop chef-automate <span class=\"hljs-number\">2<\/span>&gt;\/dev\/<span class=\"hljs-keyword\">null<\/span>\nsudo systemctl disable chef-automate <span class=\"hljs-number\">2<\/span>&gt;\/dev\/<span class=\"hljs-keyword\">null<\/span>\nsudo rm -f \/etc\/systemd\/system\/chef-automate.service\nsudo systemctl daemon-reload\n\n<span class=\"hljs-comment\"># 3. Kill any leftover Habitat processes<\/span>\nsudo pkill -f hab-launch\nsudo pkill -f hab-sup\n\n<span class=\"hljs-comment\"># 4. Remove Habitat data, user and group (only if nothing else on the host uses Habitat)<\/span>\nsudo rm -rf \/hab\nsudo userdel hab <span class=\"hljs-number\">2<\/span>&gt;\/dev\/<span class=\"hljs-keyword\">null<\/span>\nsudo groupdel hab <span class=\"hljs-number\">2<\/span>&gt;\/dev\/<span class=\"hljs-keyword\">null<\/span>\n\n<span class=\"hljs-comment\"># 5. Remove the chef-automate binary you downloaded<\/span>\nwhich chef-automate &amp;&amp; sudo rm -f <span class=\"hljs-string\">\"$(which chef-automate)\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\"><code>chef-automate uninstall<\/code> asks for confirmation. On a host you are about to rebuild, the manual steps 2 to 5 only act as a safety net. If the uninstall finished cleanly, most of them do nothing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> Do not delete <code>\/hab<\/code> or the <code>hab<\/code> user on a host that runs other Habitat services. They share the same supervisor and package store.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Uninstall a standalone Chef Infra Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>chef-server-ctl uninstall<\/code> removes the running application, but by design it keeps the data. To remove everything, wipe the data with <code>cleanse<\/code>, uninstall, remove the package, then delete the leftover directories.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>If Chef Manage (the web UI) is installed, remove it first: <code>sudo chef-manage-ctl cleanse<\/code>, then remove the <code>chef-manage<\/code> package.<\/li>\n\n\n<li>Run <code>sudo chef-server-ctl cleanse<\/code>. This stops services and deletes data, logs and generated configuration. It asks for confirmation before it continues.<\/li>\n\n\n<li>Run <code>sudo chef-server-ctl uninstall<\/code> to stop the runit supervisor and remove the application.<\/li>\n\n\n<li>Remove the package: <code>sudo apt-get purge -y chef-server-core<\/code> on Debian or Ubuntu, or <code>sudo dnf remove -y chef-server-core<\/code> on RHEL-family systems.<\/li>\n\n\n<li>Delete what is left: <code>sudo rm -rf \/opt\/opscode \/var\/opt\/opscode \/var\/log\/opscode \/etc\/opscode<\/code>.<\/li>\n\n\n<li>Remove the service accounts the package created, if they still exist: <code>sudo userdel opscode<\/code> and <code>sudo userdel opscode-pgsql<\/code>.<\/li>\n<\/ol>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">sudo chef-server-ctl cleanse\nsudo chef-server-ctl uninstall\nsudo apt-get purge -y chef-server-core      <span class=\"hljs-comment\"># or: sudo dnf remove -y chef-server-core<\/span>\nsudo rm -rf \/opt\/opscode \/<span class=\"hljs-keyword\">var<\/span>\/opt\/opscode \/<span class=\"hljs-keyword\">var<\/span>\/log\/opscode \/etc\/opscode\nsudo userdel opscode <span class=\"hljs-number\">2<\/span>&gt;\/dev\/<span class=\"hljs-keyword\">null<\/span>; sudo userdel opscode-pgsql <span class=\"hljs-number\">2<\/span>&gt;\/dev\/<span class=\"hljs-keyword\">null<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Remove Chef Infra Client and Chef Workstation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nodes that registered with the server still have the client installed and a node and client object on the server. Delete those objects from a workstation <strong>before<\/strong> you remove the server, then uninstall the client on each node. See the <a href=\"https:\/\/www.devopsschool.com\/blog\/chef-tutorials-knife-command-line-reference\/\">knife command line reference<\/a> for more options.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># From the workstation, while the server is still up<\/span>\nknife node delete web01 -y\nknife client delete web01 -y\n\n<span class=\"hljs-comment\"># On each node: remove Chef Infra Client<\/span>\nsudo apt-get purge -y chef        <span class=\"hljs-comment\"># Debian\/Ubuntu<\/span>\nsudo dnf remove -y chef           <span class=\"hljs-comment\"># RHEL family<\/span>\nsudo rm -rf \/opt\/chef \/etc\/chef \/<span class=\"hljs-keyword\">var<\/span>\/chef \/<span class=\"hljs-keyword\">var<\/span>\/log\/chef\n\n<span class=\"hljs-comment\"># On a Linux workstation: remove Chef Workstation<\/span>\nsudo apt-get purge -y chef-workstation   <span class=\"hljs-comment\"># or: sudo dnf remove -y chef-workstation<\/span>\nsudo rm -rf \/opt\/chef-workstation\n<span class=\"hljs-comment\"># Optional: removes your knife config and keys<\/span>\nrm -rf ~\/.chef<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">On Windows, remove Chef Infra Client or Chef Workstation from <strong>Apps and Features<\/strong>, then delete <code>C:\\chef<\/code> and <code>C:\\opscode<\/code> if they remain.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify the host is clean<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># No Chef, Habitat or Omnibus processes should be listed<\/span>\nps -ef | grep -E <span class=\"hljs-string\">'hab-|chef|opscode|runsv'<\/span> | grep -v grep\n\n<span class=\"hljs-comment\"># Ports 80 and 443 should no longer be held by nginx from Chef<\/span>\nsudo ss -tlnp | grep -E <span class=\"hljs-string\">':(80|443)\\s'<\/span>\n\n<span class=\"hljs-comment\"># No units or directories left behind<\/span>\nsystemctl <span class=\"hljs-keyword\">list<\/span>-unit-files | grep -Ei <span class=\"hljs-string\">'chef|runsvdir'<\/span>\nls -d \/hab \/opt\/opscode \/<span class=\"hljs-keyword\">var<\/span>\/opt\/opscode \/opt\/chef* <span class=\"hljs-number\">2<\/span>&gt;\/dev\/<span class=\"hljs-keyword\">null<\/span>\n\n<span class=\"hljs-comment\"># Service accounts gone<\/span>\nid hab; id opscode<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Each command should return nothing, or <code>no such user<\/code> for the <code>id<\/code> checks. If something still shows up, stop the process or unit, then remove the remaining path.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors and fixes<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symptom<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td><code>chef-server-ctl: command not found<\/code><\/td><td><code>\/hab<\/code> was deleted first, and Infra Server was deployed through Automate<\/td><td>Nothing more to uninstall with <code>chef-server-ctl<\/code>. Remove the leftover systemd unit and directories by hand<\/td><\/tr><tr><td><code>rm: cannot remove &#039;\/hab\/...&#039;: Device or resource busy<\/code><\/td><td>Habitat processes still running, or a mounted path under <code>\/hab<\/code><\/td><td>Stop the processes with <code>pkill -f hab-<\/code>, check with <code>mount | grep \/hab<\/code>, then retry<\/td><\/tr><tr><td><code>userdel: user hab is currently used by process<\/code><\/td><td>Supervisor or service processes still own files<\/td><td>Kill the processes listed, then run <code>userdel<\/code> again<\/td><\/tr><tr><td>Automate starts again after a reboot<\/td><td>The systemd unit was stopped but not disabled or removed<\/td><td>Run <code>systemctl disable chef-automate<\/code>, remove the unit file and run <code>daemon-reload<\/code><\/td><\/tr><tr><td>Reinstall fails because the port is in use or old data is present<\/td><td>Old <code>nginx<\/code> or <code>\/var\/opt\/opscode<\/code> data left behind<\/td><td>Run the verification checks and remove whatever is left<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Does chef-server-ctl uninstall delete my Chef Infra Server data?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. It stops the services and removes the application, but it leaves data and configuration in place. Use <code>chef-server-ctl cleanse<\/code> to wipe the data, then remove the <code>chef-server-core<\/code> package.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How do I uninstall Chef Automate cleanly?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run <code>sudo chef-automate uninstall<\/code>. It stops the services, removes the systemd unit and deletes Automate data. Afterwards, check that no <code>hab-sup<\/code> processes and no <code>\/hab<\/code> directory remain.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Is it safe to run rm -rf \/hab?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Only if no other Habitat-managed services run on the host. <code>\/hab<\/code> holds every Habitat package and all service data, so deleting it removes all of them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need to remove nodes from the Chef server before uninstalling it?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It is not required if the server is being destroyed. Still, deleting the node and client objects with <code>knife<\/code> first, and uninstalling the client on each node, stops nodes from failing their scheduled chef-client runs against a server that no longer exists.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I reinstall Chef Automate or Infra Server on the same host afterwards?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes, once the verification checks show no leftover processes, units, directories or users. Leftover data in <code>\/hab<\/code> or <code>\/var\/opt\/opscode<\/code> is the most common reason a reinstall fails.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related tutorials<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/chef-tutorials-knife-command-line-reference\/\">Chef Tutorials: knife command line reference<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/what-is-chef-and-use-cases-of-chef\/\">What is Chef and use cases of Chef?<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.devopsschool.com\/blog\/category\/infrastructure-as-code\/chef\/\">More Chef tutorials<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This guide shows how to fully remove Chef Automate, Chef Infra Server and the Chef client tools from a Linux host. It explains what each command in&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[88],"tags":[26234],"class_list":["post-32017","post","type-post","status-publish","format-standard","hentry","category-chef","tag-chef-infra-server"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=32017"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32017\/revisions"}],"predecessor-version":[{"id":80452,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32017\/revisions\/80452"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=32017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=32017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=32017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}