Creating and Managing Directories
Creating Directories
In Linux, you can create directories using the mkdir
(make directory) command. The basic syntax is:
mkdir [options] directory_name
For example, to create a new directory named "documents" in the current working directory, you can run:
mkdir documents
You can also create multiple directories at once:
mkdir documents downloads
Navigating Directories
To change the current working directory, you can use the cd
(change directory) command. The basic syntax is:
cd [directory_path]
For example, to change to the "documents" directory:
cd documents
You can use the ..
(two dots) to refer to the parent directory, and the .
(single dot) to refer to the current directory.
Managing Directories
In addition to creating directories, you can also perform other operations:
rmdir
: Remove an empty directory
rm -r
: Remove a directory and its contents recursively
mv
: Move or rename a directory
cp -r
: Copy a directory and its contents
For example, to remove the "documents" directory and its contents:
rm -r documents
Understanding these basic directory management commands is crucial for organizing and maintaining your Linux file system.