A Quick Introduction to Unix/Creating Directories
< A Quick Introduction to UnixCreating Directories
mkdir (make directory)
You can make a subdirectory of your home directory for your own data files. To make a subdirectory called mytraining in your current working directory type
% mkdir mytraining
To see the directory you have just created, type
% ls
You can also make a hidden directory if you want to. Use a dot as the first character of the directory name for it to be hidden.
Creating down a path
Surprisingly often you want to create a directory but not directly at your current position in the directory tree. Suppose I am in my home directory and I want to create directories to hold some files for two courses but in
~/documents/2010/IT/training/Unix/
The first course is an introduction to Linux, second an introduction to Solaris. I can create these directories like this:
% mkdir ~/documents/2010/IT/training/Unix/Linux
and
% mkdir ~/documents/2010/IT/training/Unix/Solaris
Naturally, you don't have to specify the complete path from ~, but I have done so here for clarity.
Creating a whole path
mkdir -p
Perhaps less often you want to create not a single directory but rather a directory subtree - that is a directory and directories beneath it. Suppose I am in my home directory and I want to create directories to hold some files for two courses: Redhat for Beginners and Advanced Redhat. We can do this with the -p option on the mkdir command.
Here is the command to create the first directory:
% mkdir -p ~/documents/2010/IT/training/Unix/Linux/Redhat/beginners
This creates the two directories we require in one go. We can then issue the command
% mkdir ~/documents/2010/IT/training/Unix/Linux/Redhat/advanced
Notice the difference between these two.
Contents
- Components
- Shells and subshells
- Directory Structure
- Changing Directories
- Listing Files and Directories
- Pathnames
- Files and Processes
- Wildcards
- Exercises 1
- Creating Directories
- Creating Files
- Special Directories
- Exercises 2
- Copying Files
- Moving Files
- Deleting Files
- Exercises 3
- Redirection
- Searching Text Files
- More grep examples
- Permissions on Files and Directories
- Editing Text
- Exercises 4
- My First Shell Script
- Job Control
- Links
- Environment Variables