Folders created by “sudo mkdir” stored

sudoterminal

I am new to mac terminal and I have made some folder using command "sudo mkdir". Some of this folders are hidden :/, in other words I have put a period before their names when using command mkdir. Now, I want to delete those folders. How can I find those folders?

Best Answer

mkdir, in the form of mkdir directory_name without a pathname, creates a directory in the current working directory, which is by default your home directory (often represented as ~). You can check you current working directory by running pwd.

If you were not in your home directory (either by having cd-ed to a different directory or having used the New Terminal at Folder Service) you will have to navigate to the directory you were in first.

You can show all files (including hidden ones) in a directory by running ls -a in it. Once you have found the directories you want to delete, you can permanently (!) remove them using rm -R directoryNameHere (including the . in the name) from their parent directory.

If you don't feel confident deleting files in the Terminal, you can simply show hidden file in Finder, in macOS Sierra and later, by using Shift++. and then deleting them like you would any other directory.