🌐 Linux Free Masterclass (Episode 8): Basic Commands (cp, mv, and rm)
How do you copy, move, rename, and permanently delete files and directories directly from the terminal without using a mouse? Through powerful file management commands.
Here are the key points from Episode 8:
🔹 1. The cp Command (Copying Files and Folders)
Purpose: Creates an exact duplicate of a file or directory.
Usage: Typing cp notes.txt backup.txt creates a backup copy of your file.
Recursive Copy: To copy an entire folder along with all its internal contents, use the -r flag (e.g., cp -r folder1 folder2).
🔹 2. The mv Command (Moving and Renaming)
Purpose: A dual-purpose command used for both relocation and renaming.
Moving: Shifts a file from one path to another (e.g., mv notes.txt /home/user/Documents/).
Renaming: If the destination path is the same but with a new name, mv instantly renames the file (e.g., mv oldname.txt newname.txt).
🔹 3. The rm Command & -rf Flag (Removal and Safety)
Purpose: Permanently deletes files or directories (remember, terminal deletion bypasses any recycle bin!).
Usage & Flags:
rm filename.txt deletes a specific file.
rm -rf foldername forcefully deletes a directory and all its contents recursively. Use with extreme caution!
🚀 Think of these tools like physical workspace operations: cp is like a photocopy machine, mv is either moving an item across rooms or rewriting a label on a folder, and rm is a heavy-duty paper shredder where things cannot be recovered once fed in!
