mkdir

mkdir is used to create directories. The name mkdir is short for “make directory”.

Basic Syntax

mkdir [options] target

Here, target specifies the name of the directory you want to create. If no directory name is specified, mkdir displays an error message.

Commonly Used Options

  • -p: This creates parent directories if they don’t exist.
  • -m: This sets the permissions of the new directory.
  • -v: This displays a message for each directory that is created.

Useful Examples

  • mkdir mydir: This creates a new directory named mydir in the current working directory.
  • mkdir /home/user/mydir: This creates a new directory named mydir in the /home/user directory.
  • mkdir -p mydir/newdir: This creates a new directory named newdir inside the mydir directory. If the mydir directory does not exist, it will be created.
  • mkdir -m 755 mydir: This creates a new directory named mydir with the permissions set to rwxr-xr-x.
  • mkdir -v mydir: This creates a new directory named mydir and displays a message confirming that the directory was created.

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments

  1. […] Once installed, let’s first allow TCP traffic over your SSH port so that you don’t get locked out of…

  2. […] have the option to choose between Password and SSH key selection. Learn more about SSH keys here. It’s recommended…