토. 7월 26th, 2025

Navigating Linux relies heavily on command-line operations. Mastering directory and file commands is crucial for efficient system management. Here are 20 fundamental commands with practical examples:

### 🗂️ Directory Navigation
1. **pwd** (Print Working Directory)  
   Shows current directory path  
   `$ pwd` → `/home/user/documents`

2. **cd** (Change Directory)  
   Moves between directories  
   `$ cd /var/log`  
   `$ cd ..` (go back one level)

3. **ls** (List)  
   Displays directory contents  
   `$ ls -l` (detailed list)  
   `$ ls -a` (show hidden files)

4. **tree**  
   Shows directory structure visually  
   `$ tree -L 2` (display 2 levels deep)

### 📁 Directory Management
5. **mkdir** (Make Directory)  
   Creates new directories  
   `$ mkdir new_project`  
   `$ mkdir -p dir1/dir2/dir3` (create nested directories)

6. **rmdir** (Remove Directory)  
   Deletes EMPTY directories  
   `$ rmdir old_folder`

### 📄 File Operations
7. **touch**  
   Creates empty files or updates timestamps  
   `$ touch file.txt`

8. **cp** (Copy)  
   Copies files/directories  
   `$ cp file.txt backup/`  
   `$ cp -r dir1 dir2` (recursive copy)

9. **mv** (Move)  
   Moves/renames files  
   `$ mv old.txt new.txt`  
   `$ mv file.txt ~/Documents/`

10. **rm** (Remove)  
    Deletes files/directories  
    `$ rm temporary.log`  
    `$ rm -r old_project` (delete recursively)

### 🔍 File Inspection
11. **cat** (Concatenate)  
    Shows file content  
    `$ cat config.conf`

12. **less**  
    Views files page-by-page  
    `$ less long_file.log` (press `q` to exit)

13. **head**  
    Displays first 10 lines  
    `$ head -n 5 file.log` (show first 5 lines)

14. **tail**  
    Shows last 10 lines  
    `$ tail -f access.log` (live updates)

### 🔎 Search Operations
15. **find**  
    Searches for files/directories  
    `$ find /home -name "*.jpg"`  
    `$ find . -size +10M`

16. **grep** (Global Regular Expression Print)  
    Searches text patterns  
    `$ grep "error" system.log`  
    `$ grep -r "TODO" ./src/` (recursive search)

### 🛡️ Permissions & Ownership
17. **chmod** (Change Mode)  
    Modifies file permissions  
    `$ chmod 755 script.sh`  
    `$ chmod u+x executable` (add user execute)

18. **chown** (Change Owner)  
    Changes file ownership  
    `$ chown user:group file.txt`

### 🔗 File Links
19. **ln** (Link)  
    Creates file links  
    `$ ln -s target.txt symlink.txt` (symbolic link)

### ℹ️ File Information
20. **file**  
    Identifies file type  
    `$ file unknown.dat` → `unknown.dat: ASCII text`

21. **stat**  
    Shows detailed file info  
    `$ stat document.pdf`

22. **du** (Disk Usage)  
    Checks file/directory size  
    `$ du -sh *` (human-readable sizes)

### 💡 Pro Tips
- Use `man [command]` for official documentation (e.g., `man ls`)
- Combine commands with pipes: `grep "404" access.log | less`
- Tab completion saves typing: type `cd Dow⇥` to autocomplete `Downloads`

Practice these commands in a safe environment to build confidence. Remember: Linux is case-sensitive and paths matter! Start with basic operations before attempting system-critical tasks. 🐧

답글 남기기

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