Copy, Move & Rename

Copying, Moving, and Deleting Files

Three essential commands for file management: cp (copy), mv (move/rename), and rm (remove/delete).

cp — Copy Files

bash
# Copy a file
cp original.txt backup.txt

# Copy a file to a directory
cp myfile.txt Documents/

# Copy a directory (use -r for recursive)
cp -r projects/ projects-backup/

mv — Move and Rename

bash
# Rename a file
mv oldname.txt newname.txt

# Move a file to a directory
mv myfile.txt Documents/

# Move and rename at the same time
mv draft.txt Documents/final.txt

rm — Remove Files

bash
# Delete a file
rm unwanted.txt

# Delete a directory and its contents
rm -r old-project/

# Force delete (no confirmation)
rm -rf temp/  # Be VERY careful with this!

Tip:rm -rf is one of the most dangerous commands in Linux. There's no trash can — deleted files are gone forever. Always double-check before using it!

Terminalbash
Welcome to the Linux Terminal Simulator!
Type commands below. Use 'help' to see available commands.
user@codewithmuh:~$
Try:

💬 Got questions? Ask me anything!