Cannot create directory: File exists error

I’ve started on the Terminal Basics series. In #1, Changing Directories, I made many mistakes, but finally completed it successfully. Before completing it, I did something that didn’t allow me to return to my home directory. Deciding to start over in a new terminal, typing “exit” didn’t close it. I clicked it closed and opened a new one to complete the exercise. Now beginning #2, Making Directories, when instructed to “mkdir dir1 dir2 dir3”, I see “mkdir: cannot create ‘dir1’: File exists
mkdir: cannot create ‘dir2’: File exists”
I don’t know what I’ve done, but until I fix it I won’t be able to make any progress in these lessons. Any help will be very much appreciated.


First, I am glad that you have started the Terminal Basics series and doing the exercises along with it.

It’s okay to make mistakes because you’ll learn new things. And it is even better to use the forum to clear your doubts. It will also give me ideas to improve the series and make it even more beginner friendly.

Now if you see dir1’: File exists kind of errors, it simply means that those directories have already been created.

You can use this command to see the contents of the directory (covered in detail in chapter 3):


This is why I recommend starting each chapter in the series in a new directory (create a new one and switch to it).

Let me know if it helps :slight_smile:


Hi @frankp and Welcome to “It’s Foss”.

Glad to see you learning about the basic terminal commands. Like @abhishek said, feel free to ask questions.

So maybe you might want to make a make a new directory for each series or chapter.
Example: “mkdir chapter2” then “cd chapter2” without the quotes.

Now since this chapter2 directory is a new directory and you just changed to it using the cd command, it will be empty. Your mkdir command will now work.

Hopefully, in chapter 2 or 3 in the Terminal Basic, it will show you how to delete the new directories you make for the class. Just be extra careful when deleting directories.


13 posts were split to a new topic: Upgrading EOL Ubuntu 18.04 with backup