0

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?

  • Does ls -al $HOME reveal these directories? – fd0 Feb 20 at 12:54
  • 3
    Which directory were you in when you ran the command. – Mark Feb 20 at 12:54
  • @Mark I was in the home directory, the one dedicated to current user – Arman Feb 20 at 17:34
  • @fd0 I tried different options like u what u say, but I did not found the folder I had made. Actually I do not know where those folders are made, otherwise I would use 'ls -a'. – Arman Feb 20 at 17:36
3

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.

  • Thanks a lot. Is it possible that a command fails without any message in terminal? I searched for the folders in the directory I was was working, but I did not find them. I guess that commands simply did not run. – Arman Feb 20 at 17:41
  • There is still sth I do not get. I have added 'sudo' at the beginning of the code. Does that mean folders are created in the main root directory? – Arman Feb 20 at 17:44
  • 1
    @Arman, If you preface the mkdir command with sudo it doesn't change where the directory is created, only its ownership. In other words, using e.g. sudo mkdir directory_name causes directory_name to be owned by root, but is still created in the present working directory (pwd) assuming an explicit pathname what not a part of directory_name. – user3439894 Feb 20 at 18:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .