Lecture 3 - Linux Command Line Tutorial - (mkdir, rmdir, touch, rm) commands

Опубликовано: 16 Июнь 2026
на канале: TechVikings
47
0

Command: mkdir (Creating Directories)
Description:
The mkdir command creates new directories.
Syntax:
mkdir [OPTION] DIRECTORY...
Common Flags:
• -p: Create parent directories as needed.
• -v: Verbose mode; show the creation of directories.
Examples:
1. Basic Usage:
mkdir my_directory
Creates a directory named my_directory.
2. Create Parent Directories:
mkdir -p parent/child
Creates parent and child directories if they don't exist.
3. Verbose Mode:
mkdir -v example_dir
Displays a message confirming the creation of example_dir.
________________________________________
Command: rmdir (Removing Empty Directories)
Description:
The rmdir command removes empty directories.
Syntax:
rmdir [OPTION] DIRECTORY...
Common Flags:
• -p: Remove a directory and its parent directories if they are empty.
Examples:
1. Basic Usage:
rmdir my_directory
Removes my_directory if it is empty.
2. Remove Parent Directories:
rmdir -p parent/child
Removes child and then parent if both are empty.
________________________________________
Command: touch (Creating Empty Files)
Description:
The touch command creates empty files or updates timestamps.
Syntax:
touch [OPTION] FILE...
Common Flags:
• -a: Change only the access time.
• -m: Change only the modification time.
• -t: Set a specific timestamp.
Examples:
1. Basic Usage:
touch file.txt
Creates an empty file named file.txt.
2. Update Access Time:
touch -a file.txt
Updates the access time of file.txt.
3. Set Specific Timestamp:
touch -t 202401010101 file.txt
Sets the timestamp of file.txt to January 1, 2024, 01:01.
________________________________________
Command: rm (Removing Files and Directories)
Description:
The rm command removes files and directories.
Syntax:
rm [OPTION] FILE...
Common Flags:
• -r: Recursively remove directories.
• -f: Force removal without confirmation.
• -i: Interactive mode; ask before every removal.
Examples:
1. Remove a File:
rm file.txt
Removes file.txt.
2. Remove a Directory Recursively:
rm -r my_directory
Removes my_directory and its contents.
3. Force Removal:
rm -rf my_directory
Forcefully removes my_directory and its contents without prompts.