Syntax vs. Semantics in Linux Commands
---
* **Syntax** = The *form* of a command (how you type it).
* **Semantics** = The *meaning* or *effect* of the command (what it actually does).
Example:
```
ls -l /home
```
* âś… Correct **syntax**: `ls` followed by an option `-l` and a directory path `/home`.
* **Semantics**: "List the contents of `/home` in long format."
But if you typed:
```
ls /home -l
```
* This is still **syntactically valid** (the shell won’t complain).
* But the **semantics** are different: `ls` interprets `-l` as a *filename* inside `/home`, not as an option! You’ll likely get an error:
```
ls: cannot access '/home/-l': No such file or directory
```
👉 Moral: In Linux, getting the **syntax** right avoids errors, but understanding the **semantics** ensures the command does what you *intend*.