{
  "id": 11343691,
  "title": "Linux mkdir: Create Directories, Build Paths, and Fix Common Errors",
  "url": "https://urgent.news/2026/10/02/linux-mkdir-create-directories-build-paths-and-fix-common-errors",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-02T03:11:16.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/__3381495fd2b/linux-mkdir-create-directories-build-paths-and-fix-common-errors-4kb0"
  },
  "original_language": "en",
  "account": "Creating directories on the Linux command line is straightforward, but it can be frustrating when things go wrong. To create a single directory named \"project\" in the current working directory, simply use the command \"mkdir project\". To verify your current location, run \"pwd\" before executing the mkdir command.\n\nYou can specify either a relative or absolute path when using mkdir. A relative path is based on your current directory, while an absolute path begins with a forward slash and remains consistent regardless of your current directory. For example, \"mkdir projects/demo\" will create a directory named \"demo\" inside a folder called \"projects\", but only if \"projects\" already exists.\n\nAn absolute path, like \"mkdir /home/alex/projects/demo\", offers more predictability in scripts, as the current working directory may be unknown. If you need to create multiple directories simultaneously, separate their names with spaces, like \"mkdir logs backups temp\". These directories become siblings rather than nested within each other.\n\nTo create a directory tree that includes missing parent directories, use the \"-p\" option. For instance, \"mkdir -p projects/app/logs\" will generate \"projects\", \"app\", and \"logs\" if they don't exist already. It also works if the target directory is already there, which can be useful in scripts that might run multiple times.\n\nWhen dealing with spaces in directory names, quote them with quotation marks to ensure they're treated as a single argument. For a hidden directory, such as \".local-data\", run \"ls -a\" to reveal it with \"ls\", but note that the leading dot signifies a naming convention, not a special permission.\n\nPermissions on new directories are typically determined by your shell's umask. A standard umask of 022 will yield permissions of 755, granting read, write, and execute access to the owner while providing read and execute access to group and other users. To create a directory with specific permissions, like 700 (owner-only access), use the \"-m\" option: \"mkdir -m 700 private-data\". The specified mode applies to the final directory in both -m and -p combinations.\n\nIf you encounter an error stating \"file exists\", check whether it's a directory or a file using \"ls -ld path/to/name\". If it's a file, you can't use mkdir again, but if it's a directory, you might reuse it. Permission denied errors arise when the shell lacks write or execute permission on the parent directory. Check the parent directory with \"ls -ld path/to/parent\" before attempting creation. Using \"sudo mkdir\" might create the directory under root ownership, limiting your ability to write within it.\n\nRunning \"mkdir -p\" on a missing parent directory will attempt to create it alongside the target directory. If you hit a \"Read-only file system\" error, the issue lies in the filesystem's write permissions, not a missing directory. Lastly, to verify that you've successfully created a directory, use \"ls -ld project\" to display its details, including permissions and owner. To automatically enter the newly created directory, chain the commands with \"&&\", like \"mkdir project && cd project\".",
  "summary": "Creating a directory from the Linux command line is simple; choosing the right path and understanding why a command fails are the parts that tend to trip people up. The basic command is: mkdir project That creates project inside your current working directory. To check where you are first, run pwd . Choose a path that matches the task You can pass mkdir a relative or absolute path. A relative…",
  "key_points": [
    "Use mkdir command to create directories on Linux.",
    "Specify relative or absolute paths with mkdir.",
    "Use -p option to create directory tree with missing parents."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}