Manipulating Directories

The most common ways of manipulating a directory are

  • Creating a directory

  • Copying a directory

  • Moving a directory

  • Removing a directory

Creating Directories

You can create directories with the mkdir command (short for make directory). Its syntax is

mkdir dir

Here, dir is the absolute or relative pathname of the directory you want to create. For example, the command

$ mkdir hw1

creates the directory hw1 in the current directory. Here is another example:

$ mkdir /tmp/test-dir

This command creates the directory test-dir in the /tmp directory. The mkdir command produces no output if it successfully creates the requested directory.

If more than one directory is specified, mkdir will try to create each of the directories. ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.