So I removed hostapd with

sudo remove hostapd

but the folder


still exist but even when I use

sudo apt install hostapd 

it won’t bring back


or the other files in


And therefore I can’t edit the file or activate hostapd

Edit: Output from sudo rm /etc/hostapd:

rm: cannot remove ‘/etc/hostapd’: Is a directory

  • Unless you provide some details, we cannot help you. If it can't install, there is an error-message saying why it won't install. What is that error message? Why can't the file be removed? What error message do you get there? Jul 28, 2022 at 16:59
  • Welcome. As per the previous comment, you'll need to provide the output from sudo rm /etc/whatever-file-you-mean.
    – goldilocks
    Jul 28, 2022 at 19:05
  • please read the comment from @goldilocks again ... you did not follow the request
    – jsotola
    Jul 29, 2022 at 17:41
  • I’ve added the error output @goldilocks Jul 30, 2022 at 0:22

1 Answer 1


The original version of your post referred to "the file in /etc", which is why I said to try sudo rm /etc/whatever-file-you-mean. To remove a directory with rm, you need to use -r or -d, see man rm. You really should be at least looking at the man pages of commands that are new to you when you first use them. This could save you the time and hassle of having to ask for help with relatively simple things.

Anyway, to remove a directory you can also use rmdir -- but it only works on empty directories. To make an educated guess, probably the reason the directory was not removed was because it contains configuration files that have been changed since they were installed; the point of that is so you do not loose config files you may want to use again. Generally re-installing will respect this, I think, but perhaps not in all cases (actually it sounds like that is what happened).

So the solution here is (if hostapd is still installed, sudo apt remove hostapd first):

sudo rm -r /etc/hostapd

From man rm:

-r, -R, --recursive

         remove directories and their contents recursively

This means you could delete the entire root filesystem with rm -r /, so be careul with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.