Chapter 3: Copying, Moving, Removing

Make empty directories and files

face Robert Craven

At the end of Exercise 5, we saw mkdir. This makes a new, empty directory.

Now, ensure you’re in your home directory, and then use mkdir to make a new directory, modules, in your ~.

username@MACHINE:~$ mkdir modules

Now check that this has had the desired effect using:

username@MACHINE:~$ ls -l

Let’s make a sub-directory of modules, shell, and then move into it.

username@MACHINE:~$ mkdir modules/shell
username@MACHINE:~$ cd modules/shell

(Notice how we made a nested subdirectory by using the relative pathname.)

To make a new, empty file, use touch.

username@MACHINE:shell$ touch empty_file.txt
username@MACHINE:shell$ ls -l
total 0
-rw-r--r-- 1 username mai 0 Aug 18 13:12 empty_file.txt

Exercise 6

  1. Change to the parent of /homes/username/modules/shell using ..
  2. Make a subdirectory of the shell directory called notes, from where you are now.
  3. Put an empty file in shell/notes, called commands.txt