Lesson 3 / الدرس 3

Your first commands: pwd, ls, cd / أوامرك الأولى: pwd وls وcd

Three commands answer the only questions that matter at the start: where am I, what is here, and how do I go somewhere else. Everything later assumes these are automatic.

ثلاثة أوامر تجيب الأسئلة الوحيدة المهمة في البداية: أين أنا، وما الموجود هنا، وكيف أذهب إلى مكان آخر. وكل ما بعدها يفترض أنها صارت تلقائية.

The shell is always somewhere. It has a working directory — one folder it considers the current one — and every command you run without saying otherwise applies there. Getting used to asking "where am I?" before running anything is the habit that prevents most beginner accidents.

pwd                 print working directory — where am I
ls                  list — what is here
cd projects         change directory — go into projects
cd ..               go up one level
cd                  go home, wherever you are
The three commands, and the two forms of cd you will use most. Note that cd with nothing after it takes you home — a useful way out when you are lost.

ls, and the options worth knowing

CommandShowsWhen you want it
lsNames, in columnsA quick look
ls -lOne per line: permissions, owner, size, dateAlmost always
ls -aIncluding names starting with a dotConfig files — lesson 11
ls -laBoth at onceThe one you will type by reflex
ls -lhSizes as 4.0K and 2.3M, not bytesWhen sizes matter
ls -ltNewest firstWhat changed recently

Options combine: ls -lah is all three. This is general — most commands let you run single-letter options together behind one dash.

$ ls -lh
total 24
drwxr-xr-x   5 ahmed  staff   160B  3 Aug 14:02 assets
-rw-r--r--   1 ahmed  staff   2.1K  3 Aug 14:02 index.html
-rw-r--r--   1 ahmed  staff   856B  1 Aug 09:30 style.css
Run it to read the columns without the pressure of a live terminal. Left to right: the type and permissions, a link count, the owner, the group, the size, when it changed, and the name. The leading d marks a directory; a - marks an ordinary file. Lesson 10 takes the permissions column apart.

Two keys that save you from typing

Type cd pro and press Tab: the shell completes it to projects if that is the only match, or shows you the choices if it is not. This is not only faster — it means the name is spelled the way the disk spells it, so a completed name is never a typo. Press it constantly. The up arrow walks back through commands you already ran.

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

Preview / المعاينة

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

1. You run cd projects and see no message at all. What happened?

2. What does the leading d in drwxr-xr-x mean?

3. Why is pressing Tab better than typing a name in full?

Your task / مهمتك

Open a terminal, find your way to a folder that has real files in it, and record a short session: pwd, then ls -lh, then move somewhere else and repeat. Present it as a page showing what you typed and what came back, with a note on each column of the ls -l output in your own words.

افتح طرفية، وشقّ طريقك إلى مجلد فيه ملفات حقيقية، وسجّل جلسة قصيرة: pwd، ثم ls -lh، ثم انتقل إلى مكان آخر وكرّر. واعرضها صفحةً تُظهر ما كتبته وما رجع إليك، مع ملاحظة على كل عمود من مخرَج ls -l بكلماتك.

  • A real session from your own machine, not copied from here جلسة حقيقية من جهازك، لا منسوخة من هنا
  • At least two different directories visited زيارة مجلدين مختلفين على الأقل
  • Every column of ls -l explained in your own words كل عمود من ls -l مشروح بكلماتك
How do you want to submit? / كيف تريد التسليم؟