Posts

unsert variables in Bash Scripting

Image
අපි දැන් බලමු මොකක්ද මේ unset variables කියල කියන්නෙ කියල. මෙන්න මෙහෙමයි හිතන්න අපි මුලින්ම assign කරපු variable එකක value එක පස්සෙ අයින් කරන්න ඕනි කියල අපි මේකට use කරන්නෙ unset variables #!/bin/bash y=7 #y ගේ value එක 7 යි කියල දෙනව echo " $y " #ඒක ප්‍රින්ට් කරනවා unset y #ඔන්න දැන් value එක අයින් කරන​වා echo " $y " #දැන් ප්‍රින්ට් කරල බල්න්න...

change read write execute permission of a file linux

Image
linux file permission ගැන දැන ගන්න -  https://binurayeshan.blogspot.com/2019/10/understand-permission-of-file-in.html හරි මම කියල දෙන්නම් දැන් කොහොමද linux file එකක permission වෙනස් කරන්නෙ කියල. මේ තියෙන්නෙ අපි හදා ගත්ත ෆයිල් එක  sample.txt එයාට default permission විදියට ඇවිල්ල තියෙන්නෙ owner - read and write permission member - read only permission user - read only permission මම දැන් owner,group,user ඔක්ටකොටම මේ file එක execute කරන්න පුලුවන් විදියට permission දෙනව chmod +x sample.txt! දැන් ඔයා ඒ file එකේ permission බැලුවම ඔයාට පේනව් x කියල permission එක එයා​ලට හම්බුවෙලා තියෙනවා. ‍‍ හරි දැන් අපි group membersලට permission දෙමු chmod g+w sample.txt # මේ කියන්නෙ group membersලට write permission දෙන්න කියල ඔයාලට බලාගන්න පුලුවන්න් group membersලගෙ permission වෙනස් වෙලා තියෙන විදි​ය other usersලට permission දෙමු chmod o+w sample.txt ownerට විතරක් permission දෙමු chmod u+x sample.txt මේ විදියට ඔයාලට කැමති විදියට ෆයිල් වල permission දෙන්න...

Understand permission of a file in Linux(File වලට permission දෙමු)

Image
මම දැන් ඔයාලට කියල දෙන්න යන්නෙ කොහොමද අපි linux වලදි file එකකට read, write, execute කියන permission දෙන්නෙ කියල මේ post එකේදි මන් කියල දෙන්නම් කොහොමද permission check කරන්නෙ කියලා හරි මම මුලින්ම file එකක් හදනව ඔයාලට දැන් පේනව මේ file එකේ -rw-r--r-- කියල අකුරු වගයක් තියෙනව මේ තියෙන්නෙ users ලට permission බෙදිල යන විදිය. මේ තියෙන්නේ ප්‍රධාන permission 3 r - read w - write x - execute rwx තුනම file එකේ පෙන්නනවා කියන්නේ එ file එකට read write execute කියන permission තුනම දීල තියෙනව් කියන එක. මේ වගේ set 3ක් එක ෆයිල් එකක තියෙනව එ මොනාද ඒ පලව්වෙනි සෙට් එක - ෆයිල් එක හදපු එක්කෙනාට තියෙන permisson (owner of the file ) දෙවනි සෙට් එක - file එකට access තියෙන membersලට දෙන permission තුන්වෙනි සෙට් එක - අනිත් usersලට තියෙන permission

Simple linux commands for beginners part 2

Image
echo ” $SHELL ” #අපි පාවිච්චි කරන ශෙල් එක බලන්න පුලුවන් echo ” $SHELL_VERSION ” #Check where the bash is located pwd #Current directory එකේ path එක බලන්න පුලුවන් echo ”Hello world” #Print Hello world cd Desktop #Change current directory d - #Moving directory up by one level cd ~ #Go to Home directory ls #List out the directory content ls -al #Get more information about file with access permission ls -a #list the all file including hidden files rm sample.txt #file එකක් delete කරන විදිය rm -d newfolder #directory එකක් delete කරන විදිය .filename.extension #Hidden the file (ෆයිල් එකේ නමට ඉස්සරහින් . එකක් තියන්න )

Simple linux commands for beginners

Image
uname -a #used to print the system information uname -r #Print the kernel release uptime #Display the time since the last boot hostname #Get host name hostname -i #Host name ip address last reboot #Last reboot time date #Date information cal #Carlander information w #provides a quick summary of every user logged into a computer, whoami #Display username of the current user who #display the users that are currently logged into your Unix computer system id #Print user id and group id information df -h #Disk space information df -t #Disk types

Sum of two numbers in bash script

Image
හරි අපි පලෙවෙනි script එකෙන් කතා කලා කොහමද bash script එකක් use karala දෙයක් print කරන්නෙ කියල අද අපි බලමු කොහොමද arithmatic operatorse use කරන්නෙ කියල. මම ඔයාලට කලින් post එකෙ කියල දුන්න විදියට bash script file එක හදාගන්න -  https://binurayeshan.blogspot.com/2019/10/2.html #!/bin/bash num1=250 #value assign කරන විදිය num2=500 #මතක තියාගන්න මෙ වගේම space තියන්නෙ නැතුව script එක ලියන්න echo "number 1 = " $num1 #number 1 එකේ value එක print කරන විදිය echo "number 2 = " $num2 echo "number 1 + number 2 =" $[num1 + num2] #value දෙකක් එකතු කරන විදිය ඊට පස්සෙ මේ Script file එකට permission දීලා Run කරන්න chmod +x ex2.sh #මේ කියන්නෙ මේ file එකට executable permission දෙන්න කියල ./ex2.sh #දැන් ඔයාට මේ file එක run කරන්න පුලුවන්

First bash script

Image
bash script file හදාගන්න විදිය.. ඔයාගේ Terminal එක open කරන්න. ඒකෙ මෙන්න මේ command ටික දෙන්න - cd Desktop #මේ කියන්නෙ ඔයාගෙ Desktop directory එකට යන්න කියල mkdir bash #මේ කියන්නෙ bash කියල folder එකක් හදන්න කියල cd bash #මේ කියන්නෙ ඔයාගෙ bash කියල හදපු folder එකට යන්න කියල touch ex1.sh #මේ කියන්නෙ ex කියන නමෙන් file එකක් හදන්න කියල ඒකෙ extension එකට මම දෙන්ව .sh කියල මොක්ද අපි හදන්නෙ bash file එකක් හින්ද දැන් ඔයාගෙ bash file එක හදල ඉවරයි. දැන් ඔයාට script එක ලියන්න පුලුවන්. දැන් ඔයා ඒ හදපු bash file එක sublime text හරි text editor එකක හරි open කරගන්න. #!/bin/bash echo "Hellp bash" #මෙන්න මේ විදියට ස්ක්‍රිප්ට් එක open කරගත්ත file එකේ ලියන්න. දැන් ඔයාගෙ terminal එකට ආයිත් ගිහින් මෙන්න මේ command ටික දෙන්න chmod +x ex1.sh #මේ කියන්නෙ මේ file එකට executable permission දෙන්න කියල ./ex1.sh #දැන් ඔයාට මේ file එක run කරන්න පුලුවන්