…and since there are no errors this time, we probably have just created the /tmp/try directory, as desired. Let’s rerun the mkdir command now: :~$ mkdir /tmp/try Here’s how to rename /tmp/try into /tmp/oldtry: :~$ mv /tmp/try /tmp/oldtry Use the mv command to move /tmp/try into some new location (or giving it new name). Even a directory! Possible solutions to mkdir: cannot create directory – file exists scenario Rename (move) existing directory The reason it says “File exists” is because pretty much everything in Unix is a file. Sure enough, we have a directory called /tmp/try already! You can use the wonderful ls command to check what’s going on: :~$ ls -ald /tmp/tryĭrwxr-xr-x 2 greys root 4096 Nov 5 18:55 /tmp/try Mkdir: cannot create directory – File exists This error suggests that the directory name you’re using (/tmp/try in my example shown on the screenshot) is already taken – there is a file or a directory with the same name, so another one can’t be created.Ĭonsider this scenario: :~$ mkdir /tmp/try This should be self explanatory after a few weeks of using commands like mkdir, but the first time you see this it can be confusing.įile exists? How can it be when you’re just trying to create a directory? And why does it say “File exists” when you’re trying to create a directory, not a file? mkdir: cannot create directory – File exists In this short post I’ll show the two most common types of this mkdir error and also explain how to fix things so that you no longer get these errors. New Linux users often get puzzled by the “ mkdir: cannot create directory” errors when taking first steps and trying to learn basics of working with files and directories.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |