touch

Update the access and modification times of each file to the current time. By default, if the file with the name written in the command doesn't exist then the file will be created, hence this command is a simple way to create files.

Syntax: touch [option] file

Example:

  1. Using touch to create a file named file.txt

    $ touch file.txt 
    
  2. Using touch to change the file modification time to the current time.

    $ ls -l
    total 0
    -rwxrwxrwx 1 shathin shathin 0 Aug 20 07:16 file.txt
    $ touch file.txt
    total 0
    -rwxrwxrwx 1 shathin shathin 0 Aug 21 07:17 file.txt
    

    <aside> 💡 The -d option can be used to pass a date string which is to be used for the modification time instead of the current time.

    </aside>


mkdir

Create the directory(ies), if they do not already exist.

Syntax: mkdir [option] directory

Example:

  1. Creating a directory folder and creating another folder subfolder insider folder

    $ mkdir folder
    $ mkdir folder/subfolder
    
  2. The above example can be shortened using the -p or --parents option. This option will create both the parent directory and the subdirectory.

    $ mkdir -p folder/subfolder
    $ mkdir -p a/b/c/d/e
    
  3. To create multiple subdirectory inside a parent directory we mention the names inside braces {dir1,dir2,dir3}

    $ mkdir folder/{dir1,dir2,dir3}
    

    <aside> ⚠️ There must be no whitespaces between the directory names and the commas

    </aside>


rmdir

Remove the directory(ies), if they are empty.

Syntax: rmdir [option] directory

Example:

  1. Deleting a directory named folder

    $ rmdir folder