Labels

Learn Linux

 Linux

Essential Ubuntu Basic Commands

Linux basic command များ အကြောင်းကို Ubuntu အသုံးပြုပြီး လေ့လာသွားမှာ ဖြစ်ပါတယ်။ ကျတော်ကိုယ်တိုင် Ubuntu 22.0.04 ကို စမ်းသုံးကြည့်ရင်းလေ့လာထားတာများကို noted down ချရေးထားသည်များကို မျှဝေထားတာဖြစ်ပါတယ်။

1. Open the Terminal (Shortcut Ctrl+Alt+T)

Linux  command များ ရိုက်ရန် terminal/prompt ဖွင့်ရန် application icon မှ တဆင့် search box မှ terminal လို့ ရိုက်ရှာ၍သြော် လည်းကောင်း သို့မဟုတ် shortcut အနေဖြင့် Ctrl+Alt+T နှိပ်၍ ဖွင့်နိုင်သည်။

Click the Terminal prompt to make sure the cursor starts to type some command.

အခြေခံ command များစတင်ရိုက်နိုင်ရန် cursor အား prompt ပေါ်တွင် ရောက်ရှိနေကြောင်းသေချာပါစေ။    သေချာစေရန် Terminal/prompt window အား click ၍ cursor အား focus လုပ်ပါ၊ cursor လေး blink ဖြစ်နေပါက commands များရိုက်ရန် အဆင့်သင့် ဖြစ်နေပါပြီ။

2. Very basic and first command

  • whoami     - check user name 
  • pwd           print working directory 
  • ls                -  lis
  • cd               - change directory 
  • cd ..            change directory to backward (upper level of current directory) 
  • cd home     change directory to home (your home directory in Linux system)
  • cd ~            - change directory to home (your home directory in Linux system)
  • cd /             - root (very root level of your drive on Linus)
whoami        - လက်ရှိ အသုံးပြုနေသော user အားစစ်ဆေးရန်
pwd              ယခုရောက်ရှိနေသော folder path အား စစ်ဆေးရန်
ls                  folder ထဲရှိ file list ကို ပြသရန် output ထုတ်ရန်
cd                 - folder လမ်းကြောင်းပြောင်းရန်
cd ..              - လက်ရှိနေရာမှ အပြင်ပြန်ထွက်ရန်
cd home       - home directory သို့ ပြန်သွားရန်
cd ~              - home directory သို့ ပြန်သွားရန်
cd /               - Linux file system ရဲ့ root directory သို့သွားရန်

3. Creating folder and file

3.1. Creating folder 

  • mkdir         - makdirectory (eg. mkdir folder_name, mkdir dir1 dir2 dir3)
    • mkdir dir1 dir2 dir3 (create multiple folder by one command)
    • mkdir -p dir4/dir5 (create parent and sub folder by one command) note: -p mean parent
    • -p character means operation or switch (-p is shortcut for parent short word)
    • --parent --verbose ( can be type command like --(double hyphen) for long word)
    • mkdir "another folder" - use " character to create folder name with space.

3.2. Creating files using redirection

  • ls > output.txt
  • cat output.txt
  • echo
    • echo "This is a test"
    • echo "This is a test 1" > text1.txt
    • echo "This is a test 2" > text2.txt
    • echo "This is a test 3" > text3.txt
  • cat
    • cat text1.txt text2.txt text3.txt
    • cat text?.txt
    • cat text*.txt
    • cat t* > combined.txt
    • cat combined.txt
    • cat t* >> combined.txt
    • echo "I've appended a line" >> combined.txt
    • cat combined.txt
    • less combined.txt
  • echo "Lower Case" > a.txt
  • echo "Upper Case" > A.TXT
  • echo "Mixed Case" > A.txt

4. Moving and Manipulating files

  • mv combined.txt dir1
  • ls dir1
  • mv dir1/* 
  • mv combined.txt test_* dir3 dir2
  • ls
  • ls dir2
  • mv dir2/combined.txt dir4/dir5/dir6
  • ls dir2
  • ls dir4/dir5/dir6

  • cp dir4/dir5/dir6/combined.txt .
  • ls dir4/dir5/dir6
  • ls

  • cp combined.txt backup_combined.txt
  • ls

  • mv backup_combined.txt combined_backup.txt
  • ls

  • mv "folder 1" folder_1
  • mv "folder 2" folder_2
  • mv "folder 3" folder_3
  • mv "folder 4" folder_4
  • mv "folder 5" folder_5
  • mv "folder 6" folder_6
  • ls

  • rm dir4/dir5/dir6/combined.txt combined_backup.txt
  • rm folder_*
  • rmdir folder_*
  • rm -r folder_6
  • ls
Important Warning
Unlike graphical interfaces, rm doesn’t move files to a folder called “trash” or similar. Instead it deletes them totally, utterly and irrevocably. You need to be ultra careful with the parameters you use with rm to make sure you’re only deleting the file(s) you intend to. You should take particular care when using wildcards, as it’s easy to accidentally delete more files than you intended. An errant space character in your command can change it completely: rm t* means “delete all the files starting with t”, whereas rm t * means “delete the file t as well as any file whose name consists of zero or more characters, which would be everything in the directory! If you’re at all uncertain use the -i (interactive) option to rm, which will prompt you to confirm the deletion of each file; enter Y to delete it, N to keep it, and press Ctrl-C to stop the operation entirely.

5. A bit of plumbing

  • wc -l combined.txt

  • ls ~ > file_list.txt
  • wc -l file_list.txt
  • rm file_list.txt

  • ls ~ | wc -l

  • ls /etc|wc -l

  • ls /etc|wc -l

  • cat combined.txt | uniq | wc -l

  • cat combined.txt | uniq | less

  • man uniq

  • sort combined.txt | less

  • sort combined.txt | uniq | wc -l

Many manuals
    Most Linux command line tools include a man page. Try taking a brief look at the pages for some of the commands you’ve already encountered: man ls, man cp, man rmdir and so on. There’s even a man page for the man program itself, which is accessed using man, of course.

    6. The command lines and the superuser

    7. Hidden files

    8. Conclusion


    No comments:

    Post a Comment

    FinTech

     "FinTech" is a term that combines "financial" and "technology" and refers to the use of technology to provide...