Lecture # 10 - Working with Directories in Linux
Creating, Removing, Copying, Moving Directories.
Commands for Manipulating Directories:
Creating a Directory:
mkdir
is used to create directory/directories in linux. This command is written asmkdir [directory-name] [directory-name] [directory-name]
.-
Deleting a Directory:
rmdir
is used to delete directory/directories in Linux. This command is written asrmdir [directory-name] [directory-name] [directory-name]
. -
Delete a Directory Recursively:
rm
is used to delete a directory recursively in Linux. This command is written asrm -r [directory-name]
.I made a directory 'DevOps' and inside this directory I made another directory 'Linux'. The 'DevOps' directory cannot be deleted by
rmdir
command because the directory is not empty. It will be deleted byrm -r
command to delete the directory recursively. Copy Files and Directories:
cp
is used to copy files or directories from one location to the other. This command copies the file or directory from the source and paste it to the destination. This command is written ascp [options] [source] [destination]
.-> To copy a directory recursively use
cp -r [directory-name] [destination]
.-> To copy from a path to a path use
cp [source] [destination]
.-
Move Files and Directories:
mv
command is used to move files and directories from one location to another or to rename them. This command cuts the file or directory from the source and paste it to the destination path. This command is written asmv [source] [destination]
.-> To rename a file
mv [new-name] [old-name]
is used.