Lesson 2 / الدرس 2

Why a terminal, and how to open one / لماذا الطرفية، وكيف تفتح واحدة

The window is not the point. Behind it sits a program that reads a line, runs it and waits for the next — and that arrangement can do things no amount of clicking can.

النافذة ليست المقصود. فخلفها برنامج يقرأ سطرًا وينفّذه وينتظر التالي — وهذا الترتيب يستطيع ما لا يستطيعه أي قدر من النقر.

Two words get used interchangeably and should not be. The terminal is the window — it draws text and collects your keystrokes. The shell is the program running inside it that actually reads what you typed, works out what you meant and runs it. Nearly everything in this course is about the shell.

Opening one, on each system

  • macOS — press Cmd + Space, type Terminal, press Enter. The shell you get is zsh.
  • Linux — Ctrl + Alt + T on most desktops. The shell is usually bash, sometimes zsh.
  • Windows — install WSL, which gives you a real Linux inside Windows. Open PowerShell once, run wsl --install, restart, and you have the same shell as everyone else. Do this now: the rest of the course assumes it.

That last point is the reason this course does not carry a second column of PowerShell commands. With WSL you are running the same system as the server your site is hosted on, so every command you learn is one you can use in both places — and a command you can only use on your own laptop is worth much less.

What the shell does with your line

ahmed@laptop  ~/projects  $ ls -la notes
└───┬───┘└──┬──┘ └────┬────┘ │  └┬┘ └┬┘ └──┬─┘
    │       │         │      │   │   │     └ argument
    │       │         │      │   │   └────── option
    │       │         │      │   └────────── command
    │       │         │      └────────────── the prompt ends here; you type after it
    │       │         └───────────────────── where you are
    │       └─────────────────────────────── which machine
    └─────────────────────────────────────── who you are
The prompt is everything the shell printed; you type the rest. Prompts vary — yours may be shorter — but it almost always tells you who and where you are, which becomes important the moment you are logged into a server. Run this to keep the anatomy in front of you.

The shell reads the line, splits it on spaces, treats the first word as the command and the rest as things to hand that command. Then it runs it, prints whatever came out, and prints the prompt again. That loop is the whole model, and it is why commands can be combined in ways a menu of buttons never could — lessons 13 and 14 are built on it.

Try it live / جرّب بنفسك

Preview / المعاينة

Check yourself / اختبر نفسك

1. What is the difference between the terminal and the shell?

2. In ls -la notes, what is -la?

3. A command seems to have hung and you get no prompt back. What do you press?

Your task / مهمتك

Open a terminal on your own machine and take a screenshot or copy the first line you see. Then write a page labelling your own prompt: which part is the user, which is the machine, which is the directory, and where the part you type begins. Say which shell you are running and how you found out.

افتح طرفية على جهازك وخذ لقطة شاشة أو انسخ أول سطر تراه. ثم اكتب صفحة تسمّي فيها مِحَثّك أنت: أي جزء هو المستخدم، وأيه الجهاز، وأيه المجلد، وأين يبدأ الجزء الذي تكتبه. وقل أي shell تشغّل وكيف عرفت.

  • Your own prompt, not the one in this lesson مِحَثّك أنت، لا الذي في هذا الدرس
  • Every part of it labelled كل جزء منه مسمّى
  • Which shell you are running, and how you found out أي shell تشغّل، وكيف عرفت
How do you want to submit? / كيف تريد التسليم؟