수. 7월 23rd, 2025

Linux Terminal Interface
Linux terminal – where file operations happen

Introduction to File Management

Managing files and folders is fundamental in Linux. While GUI tools exist, the terminal provides more power and flexibility. Let’s explore essential commands with practical examples.


1. Deleting Files & Folders (rm command)

Basic Syntax:
rm [options] filename

Key Options:

  • rm notes.txt → Deletes single file
  • rm -i report.docx → Prompts before deletion (safer)
  • rm *.tmp → Deletes all .tmp files in current directory

Deleting Folders:

  • rm -r Projects/ → Deletes folder recursively
  • rm -rf OldBackups/ → Force-deletes without prompts (use carefully!)

⚠️ Danger Zone:
rm -rf /NEVER RUN THIS! Destroys entire system
Always double-check paths before pressing Enter


2. Copying Files & Folders (cp command)

Basic Syntax:
cp [options] source destination

Common Use Cases:

  • cp document.txt ~/Documents/ → Copies file to Documents
  • cp -v image.jpg wallpaper.jpg → Copies with verbose output
  • cp *.png /media/usb/ → Copies all PNGs to USB drive

Copying Folders:

  • cp -R Music/ /backup/ → Recursive copy (-R flag)
  • cp -a Photos/ VacationPhotos/ → Archive mode (preserves permissions/timestamps)

3. Moving/Renaming Files & Folders (mv command)

Basic Syntax:
mv [options] source destination

Key Functions:

  • mv old_name.txt new_name.txt → Renames file
  • mv report.pdf ~/Documents/ → Moves file
  • mv * /tmp/ → Moves ALL files to /tmp directory

Moving Folders:

  • mv ProjectAlpha/ BetaProject/ → Renames folder
  • mv Downloads/movies/ /media/ → Moves folder to new location

Visual Cheat Sheet

Linux File Operations Diagram
Common command syntax reference


Pro Tips for Beginners

  1. Dry Run First:
    Use -n (no-clobber) with cp/mv to test:
    cp -n file1 backup/

  2. Undo Safety Net:
    Install trash-cli:
    trash-put file.txt → Moves to trash instead of permanent delete

  3. Tab Completion:
    Type partial name + Tab to auto-complete paths

  4. Confirm Operations:
    Always use -i when learning:
    alias cp='cp -i' (add to ~/.bashrc)


Practice Scenario

# Create practice files
touch file{1..3}.txt
mkdir Backup

# Copy with confirmation
cp -i file1.txt Backup/

# Rename file
mv file2.txt data.txt

# Delete safely
rm -i file3.txt

Conclusion

Mastering rm, cp, and mv unlocks efficient Linux file management. Remember:
✅ Always verify paths before deleting
✅ Use -i for interactive confirmation
✅ Start with non-critical files to practice

Safe File Operations Meme
When in doubt – double check!

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다