목. 7월 24th, 2025

Mastering file and folder operations is essential for Linux beginners. Here’s a practical guide to fundamental commands with examples and visuals:

📁 1. pwd (Print Working Directory)

Shows your current folder path:

$ pwd
/home/user/documents

pwd command visualization


📂 2. ls (List Contents)

Lists files/folders in your current directory:

$ ls
file1.txt  projects/  photos/

Common flags:

  • ls -l: Detailed list
  • ls -a: Show hidden files
    ls command output

🚪 3. cd (Change Directory)

Navigate between folders:

$ cd projects  # Enter 'projects' folder
$ cd ..        # Go back one level
$ cd ~         # Return to home directory

cd command diagram


4. mkdir (Make Directory)

Create new folders:

$ mkdir new_folder
$ mkdir -p projects/code/python  # Create nested directories

mkdir visualization


📄 5. touch (Create Files)

Create empty files:

$ touch notes.txt
$ touch file1.txt file2.txt  # Multiple files

touch command example


🧭 6. cp (Copy)

Copy files/folders:

$ cp file.txt backup/          # Copy to folder
$ cp -r old_dir/ new_dir/      # Copy directory recursively

cp command structure


🚚 7. mv (Move/Rename)

Move or rename items:

$ mv file.txt documents/       # Move to folder
$ mv oldname.txt newname.txt   # Rename file

mv command usage


🗑️ 8. rm (Remove)

Delete files/folders (caution!):

$ rm unwanted.txt              # Delete file
$ rm -r old_project/           # Delete folder recursively

Always double-check before running rm!
rm warning graphic


👁️ 9. Viewing Files

  • cat: Show full file content
    $ cat config.txt
  • less: Scroll through large files
  • head -n 5 file.txt: Show first 5 lines
  • tail -n 5 file.txt: Show last 5 lines
    cat command example

🔍 10. find (Locate Files)

Search for files:

$ find ~/ -name "*.jpg"       # Find JPEGs in home directory

find command visualization


⚠️ Pro Tips

  1. Use tab for auto-completion
  2. Add --help after commands for quick help (e.g., ls --help)
  3. Avoid spaces in filenames (use underscores instead)
  4. Ctrl+C stops any running command

Terminal cheat sheet

Practice safely: Create a practice/ folder to experiment without risking important files. Happy commanding! 🐧💻

답글 남기기

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