Tuesday, January 30, 2018

11 Useful Linux Commands (My Choice)

              ဒီ article မှာ အသုံးများတဲ့ commands တွေ အကြောင်း အဓိက ကျွန်တော် အမြဲ သုံးဖြစ်နေတဲ့ commands ကို ပြောပြထားပါတꩻယ်။ Linux ကို familiar. ဖြစ်ချင်ဆိုရင် ကျွန်တော့်တို့ Windows Shortcut command တွေကို အမှတ်ရနေသလိုမျှိုး Linux မှာရှိတဲ့ commands တွေကိုလဲ အမြဲအမှတ်ရနေဖို့လိုအပ်ပါတယ်။



#uname -r (Check Kernel Version)

          Linux OS တစ်ခုရဲ့ kernel version ကိုသိချင်ရင် #uname -r ဆိုတဲ့ command ကို အသုံးပြုပါတယ်။
အခု အောက်ကပုံမှာဆိုရင် Kernel Version "3" , Major Version "10", Minor "0", "693" ဆိုတာက bug fix   Detail ကိုပြောပြီး el7 ကိုတော့ လက်ရှိ OS platform RHEL/CENTOS 7 ကိုပြောထားတာဖြစ်ပါတယ်။




# cat /etc/redhat-release (OS Version)

          ဒီ command ကိုလဲ ကျွန်တော် ခနခနအသုံးများပါတယ်။ သူကတော့ OS release version ကို ကြည့်တာပါ။


#df -hT (Check File System and Disk Usage)

        #df -hT command ကျတော့ လက်ရှိ mounting လုပ်ထားတဲ့ disk space usage တွေရယ် နောက် သူတို့ အသုံးပြုထားတဲ့ Filesystem တွေကို ပြပါတယ်။



#lsblk ( Check all available block device)

        #lsblk command ကျတော့ system မှာ ရှိတဲ့ block devices အားလုံးကိုပြပေးပါတယ်။ Block Device တွေကိုမှ hierarchical ပုံစံမျိုးပြပေးပါတယ်။



#du -hs ( Check File/Directory Usage)

          #du -hs ကျတော့ Windows မှာလို File/Folder disk usage ကိုကြည့်ချင်ရင်  Right Click -> Properties နဲ့ အသုံးပြုသလိုပဲ Linux မှာကျ အခု command ကိုအသုံးပြုပြီး ကြည့်ပါတယ်။



#pvs, vgs, lvs ( Check LVM disk information)

           ဒီ command ၃ခုကိုတော့ အဓိကအားဖြင့် system changes မလုပ်ခင် လက်ရှိ system မှာ LVM run ထားလား run ထားရင် information တွေက ဘာတွေလဲ မှတ်ထားဖို့ လိုအပ်လာရင် အသုံးပြုပါတယ်။ 



#uptime

        ဒီ command လဲ အရေးကြီးတဲ့အထဲမှာ ပါပါတယ်။ System Uptime, how long has the system been running ကြည့်ချင်တဲ့အခါ သုံးပါတယ်။ ဥပမာ ကျွန်တော်တို့ မသိလိုက်တဲ့အချိန်မှာ system reboot ဖြစ်သွားလား confirm လုပ်ချင်ရင် သိချင်ရင် အသုံးပြလို့ရတယ်ပေါ့။ "07:32:53" က current time , "up" system up ဖြစ်နေတယ် "1:26" နာရီ running ဖြစ်နေတယ်။ နောက် Current users ရယ် system load average ပါကြည့်နိုင်ပါတယ်။ 



#getenforce

         ဒီ command ကျ SELINUX လို့ ခေါ်တဲ့ Security feature system မှာ currently activeဖြစ်နေလား မဖြစ်နေဘူးလား သိချင်ရင်အသုံးပြုပါတယ်။ "Enforcing" ဆိုရင် active ဖြစ်နေတယ်ပေါ့။ Use case ကိုပြောပါဆိုရင်တော့ security နဲ့ပတ်သတ်ပြီး troubleshooting လုပ်နေတဲ့အချိန် အသုံးပြုတယ်ပေါ့။ Application မှာ error ပြနေတယ် Selinux run ထားလား သိချင်တယ် အဲ့လိုမျိုး အခြေနေတွေများသုံးတက်ပါတယ်။



#scp (Secure Copy Transfer)

         တစ်ချို့လဲ rsync သုံးပါတယ် #scp command ကလဲ ထိုနည်း၄င်းပဲ files tranfer လုပ်တဲ့အခါ အသုံးပြုပါတယ်။ Windows to Linux trasnfer ဆိုရင် WinSCP software ကိုအသုံးပြုကြပါတယ်။


#dd if=/dev/sdx of=/dev/null (Find out Physical HDD drive location) 

         ဒီ command ကျတော့ အမြဲ သုံးနေကျ တော့မဟုတ်ဘူး နောက်ပြီး #dd command usage က သတ်သတ်ရှိတယ်  ဒါပေမယ့် တော်တော်ကို အသုံးဝင် တဲ့ command တစ်ခု ဖြစ်ပါတယ်။ သူ့ကို ကျွန်တော် က HDD Physical Location ကိုသိချင်ရင်အသုံးပြုတယ်။  သူက တစ်ကယ် တော့ if(InputFile) /dev/sdx block device က data တွေကို of(OutputFile) /dev/null (black hole) ထဲကို copy လုပ်ခိုင်းတာပေါ့ /dev/null ထဲကို copy ကူးယူးနေတုန်းမှာ အဲ့ဒီ /dev/sda ဆိုပါတော့ အဲ့ဒီ့ block device ရဲ့ activity light က flash ကအလုပ်လုပ်နေလိမ့်မယ် သိသိသာသာ အဲ့ဒီလိုနည်းနဲ့ HDD Physical Drive တည်နေရာကို သိနိုင်ပါတယ်။ HDD replacement လုပ်တဲ့အခါ customer ကလဲ mount directory ပဲ သိတယ် တစ်ကယ့် physical drive bay ကိုမသိဘူးဆိုရင် အသုံးပြုပါတယ်။ HDD Physical location ကိုသိပြီးရင်တော့ Ctrl+C နဲ့ break လုပ်ပြီး opreation stop လုပ်ရပါမယ်။ 
PS: #dd command is like double edge sword as it could be useful and harmful at the same time. Recommend to understand #dd command usage first before use it in production.



#Export LESS="-X" (Use for Man Page Reference)

          တော်တော်ကို အသုံးတဲ့တယ့် command ဖြစ်ပါတယ်။ Linux command တွေအလွတ်ကျက်ဖို့တော့ မဖြစ်နိုင်ဘူးဆိုတော့ တစ်ခါတစ်လေ long command တွေအသုံးပြုရတဲ့အခါ ဥပမာ #nmcli command မျိုး #iscsiadm command မျိူး #pcs command မျိူးတွေ ကျ ကျွန်တော်တို့ အရင်ဆုံး command ကို man pageခေါ်ကြည့်တယ် အများစု man page ရဲ့ အောက်ဆုံးမှာ examples တွေ ရှိတက်တယ် အဲ့ဒီ examples တွေကို အသုံးပြုဖို့ Man page ကထွက်လိုက်ရင် ပုံမှန်ဆို screen မှာပျောက်သွားသောကြောင့်  screen မှာကျန်ခဲ့ဖို့ သုံးတဲ့ command ဖြစ်ပါတယ်။






           အခုဆိုရင် man page ကနေထွက်ပြီးတောင်မှ man page က screen ပေါ်မှာ  clear ဖြစ်မသွားပဲ ကျန်ခဲ့ပြီး command တွေကို အလွယ်တကူ အသုံးပြုနိုင်ပါတယ်။

Please also Like and Follow Root Of Info Page
Share:

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.