2.3 Using Directories and Listing Files: Navigating the Filesystem

Share this article to...

Getting Current Location

Bash လို Linux Shells တွေဟာ Text-based ဖြစ်တာမို့ Filesystem တွေကို အသုံးပြုရှာဖွေကြတဲ့အခါ လက်ရှိရောက်နေတဲ့နေရာကို သိရှိနေဖို့လိုပါတယ်။ Command Prompt ကိုကြည့်ပြီးလည်း သိနိုင်ပါတယ်။

            user နှင့် hostname Information တွေကို နောက်ပိုင်း Sections တွေမှာ ပြောပြပေးသွားပါမယ်။ Prompt မှ မိမိတို့ရောက်ရှိနေတဲ့ Current Location (Reports Directory) ကို သိနိုင်သလို Print Working Directory (pwd) Command ဖြင့်လည်း ခေါ်ကြည့်နိုင်ပါတယ်။

            Directory တွေရဲ့ ဆက်စပ်မှုကို Forward Slash (/) ဖြင့် ဖော်ပြတာပါ။ Reports  Directory ဟာ Documents Directory ရဲ့ အခွဲ Subdirectory တစ်ခုဖြစ်ပြီး Documents Directory ကတော့ user Directory ရဲ့  Subdirectory တစ်ခုပြန်ဖြစ်နေပြီး home Directory ထဲမှာ ရှိနေတာပါ။ home Directory မှာ Parent Directory မရှိသလိုမျိုးဖြစ်နေပေမယ့် အမှန်တကယ်မှာတော့ root လို့ခေါ်တဲ့ First Slash (/) ဖြင့် ဖော်ပြတဲ့ Directory ဟာ home Directory ရဲ့ Parent Directory ပါပဲ။ root Directory အကြောင်းကို နောက်ပိုင်းမှာ ဆက်လက်ဖော်ပြပေးပါမယ်။

            pwd Command ရဲ့ Output ဟာ Command Prompt မှာ ပေးထားတဲ့ Directory Path နှင့် အနည်းငယ်ကွာခြားနေပါတယ်။ /home/user လို့ ပြရမယ့်အစား Command Prompt မှာ Tilde (~) Symbol လေးပါဝင်နေတာပါ။ Tilde ဟာ User Home Directory ကို ကိုယ်စားပြုတဲ့ Special Character လေးတစ်ခုပါ။ နောက်သင်ခန်းစာမှာ အသေးစိတ်ဖော်ပြပေးပါ့မယ်။

Listing Directory Contents

            Current Directory ထဲမှာရှိနေမယ့် Files နှင့် Directories List ကို ls Command ဖြင့် ကြည့်နိုင်ပါတယ်။

            ls Command ဟာ Parent Directory အတွက်တော့ ဘာမှမပြပေးနိုင်ပါဘူး။ Subdirectories တွေအတွက်လည်း အလားတူပါပဲ။ Current Directory မှာ ရှိတဲ့ Information ပဲ မြင်ရမှာပါ။

Changing Current Directory

            Linux မှာ Directory Navigation အတွက် cd (Change Directory) Command ဖြင့်ပဲ အဓိကထားပြုလုပ်ပါတယ်။ pwd Command သုံးပြီး Current Directory ကို /home/user/Documents/Reports လို့ သိထားပြီး တခြား နေရာအသစ် (New Path) သို့ သွားဖို့ ရောက်ဖို့ရာ အခုလို ပြောင်းနိုင်တာပါ။

            နေရာအသစ်မှနေပြီး Mission-Statement.txt File နှင့် Subdirectory ဖြစ်တဲ့ Reports တို့ကို တွေ့နိုင်ပေမယ့် Subdirectory Contents တွေတော့ မပြပါဘူး။ Reports Directory Navigation အတွက် အခုလိုပြုလုပ်နိုင်ပါတယ်။