Navigation

    Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. Categories
    3. System & Network Configurations
    4. Linux
    • Simple linux commands for beginners

      binurayeshan

      මේ commands linux environment එකේ ඔයාලට භාවිතා කරන්න පුලුවන්

      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
      Linux
    • Lets talk about bash script

      binurayeshan

      bash script කියන්නෙ linux environment එකේ වැඩ කරන්කොට අපිට හම්බුවෙන script language එකක්. ගොඩක්ම මේ bash scripting අවශ්‍ය වෙන්නෙ linux administrator ඒ වගේම ethical hacking ගැන උනන්දු වන අයට. ඇත්තටම bash script එකක් ගත්තම ඒක linux command වල එකතුවක් විදියට දකින්නත් පුලුවන්.

      Linux
    • Logical Operators in bash script(And, OR, NOT)

      binurayeshan

      හරි මම ඔයාලට කියල දෙන්නම් අද කොහොමද BASH Script වලදි Logical expression use කරන්නෙ කියලා..

      #!/bin/bash echo "Enter marks :"#user ගෙන් input එක ඉල්ලන්න read mark #input එක ගන්න if [ $mark -ge 80 -a $mark -le 100 ] #enter කරපු mark එක 80ට වඩා වැඩිද(-ge 80) ඒ වගේම (-a) 100ට වඩා අඩුද(-la 100) then #එහෙමනම් echo "A" #A කියල print කරන්න elif [ $mark -ge 60 -a $mark -le 79 ] then echo "B" elif [ $mark -ge 40 -a $mark -le 59 ] then echo "C" elif [ $mark -ge 20 -a $mark -le 39 ] then echo "D" elif [ $mark -ge 10 -a $mark -le 19 ] then echo "E" else echo "Invalid mark" fi

      👻

      0_1570683194188_Screenshot 2019-10-10 at 10.23.09.png

      Linux
    • DECISION MAKING IN SHELL SCRIPTS Part 2(කොහොමද Arguments දෙකක් එක්ක වැඩ කරන්නෙ)

      binurayeshan

      හරි මම ඔයාලට කියල දෙන්නම් කොහොමද conditions දෙකක් check කරන්නෙ කියල.
      මෙන්න මේකයි Programm එක. userගෙන් input දෙකක් ගන්නව අරගෙන එයා ඒ දෙකටම inputs දුන්නද නැද්ද කියල check කරනව.

      #!/bin/bash echo "Enter argument 1 :" #argument 1 එක එන්ටර් කරන්න කියනවා read arg1 #User ගෙන් input එක ගන්නවා echo "Enter argument 2 :" read arg2 if [ -n "$arg1" ] #මේ කියන්නෙ arg1 එක මෙකේ value එක Zero නෙමේනම් කියන එක then #එහෙමන්ම් echo "Argument 1 has value"#Argument 1 has value කියල print කරන්න elif [ -z "$arg1" ]#මේ කියන්නෙ arg1 එක මෙකේ value එක Zero නම් කියන එක then #එහෙමන්ම් echo "Argument 1 has no value"#Argument 1 has no value කියල print කරන්න fi#මේ කියන්නෙ මෙන්න මේ පටන් ගත්ත පලවෙනි dicision එක close කරන්න කියල if [ -n "$arg2" ] then echo "Argument 2 has value" elif [ -z "$arg2" ] then echo "Argument 2 has no value" fi

      👨‍💻 🤙 😎

      0_1570345984519_Screen Shot 2019-10-06 at 12.42.59 PM.png

      මේ link වලින් ගිහින් ඔයාලට bash script ගැන කලින් කරපු post බලාගන්න පුලුවන්..

      Lets talk about bash script - https://lankadevelopers.com/topic/371/lets-talk-about-bash-script

      First bash script - https://lankadevelopers.com/topic/372/first-bash-script

      Sum of two numbers in bash script - https://lankadevelopers.com/topic/377/sum-of-two-numbers-in-bash-script

      Bash script Array introduction - https://lankadevelopers.com/topic/386/bash-script-array-introduction

      Linux
    • Arithmetic operators in BASH scripting

      binurayeshan

      අද කතා කරන්නේ Basic Arithmetic operators ටික ගැන. ඒ කියන්නෙ එකතු කිරීම, අඩු කිරීම , බෙදීම , ගුන කිරීම.

      ඔයාල දැන් දන්නවනේ කොහොමද bash script file එකක් හදාගන්නෙ කියල.. දන්නෙ නැති අය මෙ Link එක Use කරල ඔක්කොම ටික බලන්න - https://binurayeshan.blogspot.com

      හරි දැන් ඔයාලා හදා ගත්ත script file එකේ මෙන්න මේ code line ටික type කරන්න.

      #!/bin/bash a=2 b=5 c=9 echo "$a,$b,$c" echo "Sum of variable are = $[a+b+c]" #එකතු කිරිම් echo "Value of c MOD b = $[c%b] " #mod එක ඒ කියන්නෙ බෙදුවම එන ඉතිරිය echo "Value of c MOD b = $[c-b] " #අඩු කිරීම echo "Value of a * c = $[a*c]" #ගුණ කිරීම echo "Value of c / b = $[c/b]" #බෙදීම

      👨‍💻 😎
      0_1570406256663_Screen Shot 2019-10-07 at 5.27.33 AM.png

      Linux
    • File Test Operators(bash script use කරල file එකක් හදල permission දීල run කරමු)

      binurayeshan

      හරි මම ඔයාලට කියල දෙන්නෙ මේ වෙනකන් කියල දීපු හැම පොස්ට් එකකින්ම ගත්ත දේවල් එකතු කරල කොහොමද linux වලදි එක ස්ක්‍රිප්ට් එකකින් ෆයිල් එකක් හදල ඒක ඇතුලෙ දෙයක් type කරල ඒකට execute permission දීලා ඒක run කරන්නෙ කියලා.

      හරි දැන් ඔයාල මෙන්න මේ වගේ sh file එකක් හදාගෙන script එක ලියන්න.

      #!/bin/bash cd ~ #මේ කියන්නෙ ඔයා ඉන්න directory එකෙන් ඊට කලින් තිබ්බ directory එකට යන්න කියල මම මේ ඉන්නෙ Documents Directory එකේ තියෙන folder එකක ඒ නිසා මම මගේ User Directory එකට යන්න දෙපාරක් back වෙන්න ඕන cd ~ # මේ දෙවනි එක cd Desktop# හරි මම දැන් ඔන්න Script එකේ ලියනවා Desktop Directory එකට එන්න කියල if [ -d new ] #මේ කියන්නේ new කියල Directory එකක් තියෙනවද කියල බලන්න කියන එක then echo "Directory available" #එහෙම තියෙනවනම් Directory available කියල display කරන්න cd new #තියෙනවනම් ඒක ඇතුලට යන්න else echo "Directory not available so i am creating file.."#එහෙම නැත්නම්not Directory available කියල display කරන්න mkdir new#Directory එක හදන්න cd new#දැන් ඒක ඇතුලට යන්න fi #එක decision making command set එකක් ඉවරයි if [ -f foo.sh ] #හරි දැන් බලන්න foo.sh කියල file එකක් තියෙනවාද කියල then echo "File available"#එහෙම තියෙනවානම් File available කියල print කරන්න else echo "File not available so i am creating file..." #එහෙම නැත්නම් File not available so i am creating file..." කියල print කරලා touch "foo.sh"; echo "#!/bin/bash" >> foo.sh #File එක හදන්න හදලා ඒකෙ #!/bin/bash කියල type කරන්න කියන්න fi if [ -e foo.sh ] #හරි මේ බලන්නෙ ඒ හදපු ෆයිල් එක ඇතුලෙ text මොනවා හරි තියෙනවාද කියල then echo "available"# එහෙම තියෙනවානම් available කියල print කරන්න else echo "Not available so i am writing.." #එහෙම නැත්නම් echo "#!/bin/bash" >> foo.sh##!/bin/bash කියල ෆයිල් එක ඇතුලෙ ටයිප් කරන්න fi if [ -x foo.sh ]#මේ කියන්නෙ ඒ හදපු ෆයිල් එකට execution permission දීලද බල්න්න කියල then echo "Yes executable file so i am opening file"#එහෙම දීලනම් open foo.sh#open කරන්න ./foo.sh#Execute කරන්න else echo "Not a executable file i give permission and opening file"#file එකට permission දීල නැත්නම් chmod +x foo.sh #permission දෙන්න open foo.sh ./foo.sh fi echo "enter yes if you want edit file otherwise enter no" # හරි මම දැන් කියනවා ඔයාට ඒ file එක ආයිත් edit කරන්න ඕනනම් yes කියල type කරන්න එපානම් No කියල ටයිප් කරන්න read input #user ගේ input එක ගන්න if [ "$input" = "yes" ] # input එක yes නම් then open foo.sh # ෆයිල් එක open කරන්න else echo "Work done bye!!!!" fi

      👽

      0_1570411209941_Screen Shot 2019-10-07 at 6.50.04 AM.png

      Linux
    • DECISION MAKING IN SHELL SCRIPTS(Write a shell script to determine whether a given number is either positive or negative)

      binurayeshan

      මම අද ඔයාලට කියල දෙන්නෙ කොහොමද shell scripting පාවිච්චි කරල DECISION MAKING simple programme එකක් ලියන්නෙ කියල.👨‍💻

      මේ link වලින් ගිහින් ඔයාලට bash script ගැන කලින් කරපු post බලාගන්න පුලුවන්..

      Lets talk about bash script - https://lankadevelopers.com/topic/371/lets-talk-about-bash-script

      First bash script - https://lankadevelopers.com/topic/372/first-bash-script

      Sum of two numbers in bash script - https://lankadevelopers.com/topic/377/sum-of-two-numbers-in-bash-script

      Bash script Array introduction - https://lankadevelopers.com/topic/386/bash-script-array-introduction

      ඔයාලට කියල දුන්න විදියට .sh File එකක් හදාගන්න. දැන් ඔයාලා මෙන්න මේ code එක ඔයාලගෙ script එකේ ලියන්න.

      #!/bin/bash echo "Enter mark :" read number #ඔයාගේ mark එක read කරනව if [ $number -lt 0 ]# මේ කියන්නෙ enter කරපු mark එක less than(අඩුයිනම්) 0 ට වඩා then #එහෙනම් echo "Negetive" #negative කියල print කරන්න elif [ $number -gt 0 ] # මේ කියන්නෙ enter කරපු mark එක greater than(වැඩියිනම්) 0 ට වඩා then #එහෙනම් echo "Positive" #Positive කියල print කරන්න else #ඒ දෙකම නෙමෙයිනම් echo "Neither Positive nor negative" fi

      ☺
      0_1570151873514_Screen Shot 2019-10-04 at 6.47.49 AM.png

      Linux
    • Read only variables in Bash Scripting

      binurayeshan

      මේ link වලින් ගිහින් ඔයාලට bash script ගැන කලින් කරපු post බලාගන්න පුලුවන්..

      Lets talk about bash script - https://lankadevelopers.com/topic/371/lets-talk-about-bash-script

      First bash script - https://lankadevelopers.com/topic/372/first-bash-script

      Sum of two numbers in bash script - https://lankadevelopers.com/topic/377/sum-of-two-numbers-in-bash-script

      Bash script Array introduction - https://lankadevelopers.com/topic/386/bash-script-array-introduction

      මොකක්ද මේ කතාව හරි මෙන්න මෙහෙමයි.
      අපි Bash Script එකක් ලියනකොට අපිට ඕනි වෙනව වෙනස් කරන්න බැරි විදියට variables හදන්න ඒ කිවුවේ මෙන්න මෙහෙම.
      හිතන්නකො මම මුලින්ම x = 5 කියල value එකක් දෙනව කියල මම ඊලග code line එකේ x=8 කියල දුන්නම x ගේ value එක 8 ක් වෙනවා

      x=5 echo "$x" x=8 echo "$x"

      මෙන්න මේ වැඩේ අපිට නතර කරගන්න පුලුවන් readonly variable use කලාම. ඔන්න බලන්න ඒක කරන විදිය

      #!/bin/bash readonly x=5 #අපි x ව readonly variable එකක් කලා echo "$x"#එයාව print කරනවා x=9 #ඔන්න දැන් එයාව වෙනස් කරන්න හදනව ඒ නිසා අපිට පෙන්නනව එයාව වෙනස් කරන්න බෑ කියල echo "$x"

      0_1569543892668_Screen Shot 2019-09-27 at 5.53.00 AM.png

      Linux
    • unsert variables in Bash Scripting

      binurayeshan

      මේ link වලින් ගිහින් ඔයාලට bash script ගැන කලින් කරපු post බලාගන්න පුලුවන්..

      Lets talk about bash script - https://lankadevelopers.com/topic/371/lets-talk-about-bash-script

      First bash script - https://lankadevelopers.com/topic/372/first-bash-script

      Sum of two numbers in bash script - https://lankadevelopers.com/topic/377/sum-of-two-numbers-in-bash-script

      Bash script Array introduction - https://lankadevelopers.com/topic/386/bash-script-array-introduction

      Read only variables in Bash Scripting - https://lankadevelopers.com/topic/387/read-only-variables-in-bash-scripting

      අපි දැන් බලමු මොකක්ද මේ unset variables කියල කියන්නෙ කියල.
      මෙන්න මෙහෙමයි
      හිතන්න අපි මුලින්ම assign කරපු variable එකක value එක පස්සෙ අයින් කරන්න ඕනි කියල අපි මේකට use කරන්නෙ unset variables

      #!/bin/bash y=7 #y ගේ value එක 7 යි කියල දෙනව echo "$y" #ඒක ප්‍රින්ට් කරනවා unset y #ඔන්න දැන් value එක අයින් කරන​වා echo "$y" #දැන් ප්‍රින්ට් කරල බල්න්න...

      0_1569544638776_Screen Shot 2019-09-27 at 6.07.08 AM.png

      Linux
    • How to copy and move files on linux

      binurayeshan

      හරි මම අද ඔයලට කියල දෙන්නෙ කොහොම්ද Linux වලදි File එක​ක් copy කරගන්නෙ Move කරගන්නෙ කියල 0_1569455450299_Screen Shot 2019-09-26 at 5.20.41 AM.png

      හරි ඔයාලට පේනව මගෙ මේ ෆොල්ඩර් එක ඇතුලෙ sample.txt කියල file ekak තියෙනව මම දැන් කියල දෙන්නම් කොහොමද එකේ copy ගන්නෙ කියල වෙනත් නමකින්

      cp sample.txt new.txt #මේ කියන්නේ sample.txt කියන file එකේ copy එකක් new.txt කියල ගන්න කියලා.

      0_1569455747004_Screen Shot 2019-09-26 at 5.25.39 AM.png

      හරි දැන් බලමු කොහොමද හදපු file එක කොහොමද වෙන තැනකට move කාරග්න්නෙ කිය​ලා

      mv new.txt /Users/yeshan/Desktop/new.txt # මුලින්ම මම file එකේ නම දෙනවා ඊට පස්සෙ move කරන්න ඕන directory එකේ නම දෙනවා ඊට පස්සෙ ඔයාට කැමති නමක් දෙන්න පුලුවන් එත්කොට ඒ නමින් තමයි file එක move වෙන්නෙ..

      0_1569457230372_Screen Shot 2019-09-26 at 5.36.18 AM.png

      Linux
    • change read write execute permission of a file linux

      binurayeshan

      linux file permission ගැන දැන ගන්න - https://lankadevelopers.com/topic/382/understand-permission-of-a-file-in-linux
      හරි මම කියල දෙන්නම් දැන් කොහොමද linux file එකක permission වෙනස් කරන්නෙ කියල.

      0_1569376605126_Screen Shot 2019-09-25 at 6.46.17 AM.png

      මේ තියෙන්නෙ අපි හදා ගත්ත ෆයිල් එක 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!

      0_1569376655050_Screen Shot 2019-09-25 at 7.24.19 AM.png

      දැන් ඔයා ඒ file එකේ permission බැලුවම ඔයාට පේනව් x කියල permission එක එයා​ලට හම්බුවෙලා තියෙනවා. ‍‍

      හරි දැන් අපි group membersලට permission දෙමු

      chmod g+w sample.txt # මේ කියන්නෙ group membersලට write permission දෙන්න කියල

      0_1569376982177_Screen Shot 2019-09-25 at 7.31.30 AM.png

      ඔයාලට බලාගන්න පුලුවන්න් group membersලගෙ permission වෙනස් වෙලා තියෙන විදි​ය

      other usersලට permission දෙමු

      chmod o+w sample.txt

      0_1569377612870_Screen Shot 2019-09-25 at 7.43.20 AM.png

      ownerට විතරක් permission දෙමු

      chmod u+x sample.txt

      මේ විදියට ඔයාලට කැමති විදියට ෆයිල් වල permission දෙන්න පුලුවන්

      u — the user who owns the file (that is, the owner)
      g — the group to which the user belongs
      o — others (not the owner or the owner's group)
      a — everyone or all (u, g, and o)

      r — read access
      w — write access
      x — execute access

      Linux
    • Understand permission of a file in Linux

      binurayeshan

      මම දැන් ඔයාලට කියල දෙන්න යන්නෙ කොහොමද අපි linux වලදි file එකකට read, write, execute කියන permission දෙන්නෙ කියල මේ post එකේදි මන් කියල දෙන්නම් කොහොමද permission check කරන්නෙ කියලා

      හරි මම මුලින්ම file එකක් හදනව
      0_1569374198712_Screen Shot 2019-09-25 at 6.46.17 AM.png

      ඔයාලට දැන් පේනව මේ file එකේ -rw-r--r-- කියල අකුරු වගයක් තියෙනව මේ තියෙන්නෙ users ලට permission බෙදිල යන විදිය.

      මේ තියෙන්නේ ප්‍රධාන permission 3
      r - read
      w - write
      x - execute

      0_1569374595380_Screen Shot 2019-09-25 at 6.52.59 AM.png

      rwx තුනම file එකේ පෙන්නනවා කියන්නේ එ file එකට read write execute කියන permission තුනම දීල තියෙනව් කියන එක.

      මේ වගේ set 3ක් එක ෆයිල් එකක තියෙනව එ මොනාද ඒ
      පලව්වෙනි සෙට් එක - ෆයිල් එක හදපු එක්කෙනාට තියෙන permisson (owner of the file )
      දෙවනි සෙට් එක - file එකට access තියෙන membersලට දෙන permission
      තුන්වෙනි සෙට් එක - අනිත් usersලට තියෙන permission

      Linux
    • Bash script Array introduction

      binurayeshan

      හරි මම ඔයාලට දැන් කියලා දෙනනෙ Bash script වල Array use කරන විදිය
      මේ link වලින් ගිහින් ඔයාලට bash script ගැන කලින් කරපු post බලාගන්න පුලුවන්..
      Lets talk about bash script - https://lankadevelopers.com/topic/371/lets-talk-about-bash-script

      First bash script - https://lankadevelopers.com/topic/372/first-bash-script

      Sum of two numbers in bash script - https://lankadevelopers.com/topic/377/sum-of-two-numbers-in-bash-script

      #!/bin/bash fruits=(apple orange graphes banana) echo "${fruits[2]}" #print element 2 echo "${fruits[@]}" #print all array elements echo "${!fruits[@]}" #print array position echo "${#fruits[@]}" #calculate array size fruits[1]=lemon #overwrite 1st element echo "${fruits[@]}" fruits+=(orange) #add more value (අපිට පුලුවන් මේකෙන් array එකේ element වැඩි කරන්න) echo "${fruits[@]}" #print all array elements echo "${!fruits[@]}" #print array position

      0_1569460696930_Screenshot from 2019-09-26 06-47-45.png

      Linux
    • Simple linux commands for beginners part 2

      binurayeshan

      ලින්කුව for part 1 - https://lankadevelopers.com/topic/380/simple-linux-commands-for-beginners

      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 (ෆයිල් එකේ නමට ඉස්සරහින් . එකක් තියන්න ) ``
      Linux
    • First bash script

      binurayeshan

      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 karaganna.

      #!/bin/bash echo "Hellp bash"

      දැන් ඔයාගෙ terminal එකට ආයිත් ගිහින් මෙන්න මේ command ටික දෙන්න

      chmod +x ex1.sh #මේ කියන්නෙ මේ file එකට executable permission දෙන්න කියල ./ex1.sh #දැන් ඔයාට මේ file එක run කරන්න පුලුවන්
      Linux
    • Sum of two numbers in bash script

      binurayeshan

      හරි අපි පලෙවෙනි script එකෙන් කතා කලා කොහමද bash script එකක් use karala දෙයක් print කරන්නෙ කියල අද අපි බලමු කොහොමද arithmatic operatorse use කරන්නෙ කියල.

      මම ඔයාලට කලින් post එකෙ කියල දුන්න විදියට bash script file එක හදාගන්න - https://lankadevelopers.com/topic/372/first-bash-script

      #!/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 කරන්න

      Linux
    • Linux Commands For Developers

      root

      1. HARDWARE INFORMATION

      #Display messages in kernel ring buffer dmesg #Display CPU information. cat /proc/cpuinfo #Display memory information. cat /proc/meminfo #Display free and used memory ( -h for human readable, -m for MB, -g for GB.). free -h #Display PCI devices. lspci -tv #Display USB devices. lsusb -tv #Display DMI/SMBIOS (hardware info) from the BIOS. dmidecode #Show info about disk sda. hdparm -i /dev/sda #Perform a read speed test on disk sda. hdparm -tT /dev/sda #Test for unreadable blocks on disk sda. badblocks -s /dev/sda

      2. SYSTEM INFORMATION

      #Display Linux system information. uname -a #Display kernel release information. uname -r #Show which version of redhat installed. cat /etc/redhat-release #Show how long the system has been running + load. uptime #Show system host name. hostname #Display the IP addresses of the host. hostname -I #Show system reboot history. last reboot #Show the current date and time. date #Show this month's calendar. cal #Display who is online. w #Who you are logged in as whoami

      3. USER INFORMATION AND MANAGEMENT

      #Display the user and group ids of your current user. id #Display the last users who have logged onto the system. last #Show who is logged into the system. who #how who is logged in and what they are doing. w #Create a group named "test". groupadd test #Create an account named john, with a comment of "John Smith" and create the user's home directory. useradd -c "John Smith" -m john #Delete the john account. userdel john #Add the john account to the sales group. usermod -aG sales john

      4. FILE AND DIRECTORY COMMANDS

      #List all files in a long listing (detailed) format. ls -al #Display the present working directory. pwd #Create a directory. mkdir directory #Remove (delete) file. rm file #Remove the directory and its contents recursively. rm -r directory #Force removal of file without prompting for confirmation. rm -f file #Forcefully remove directory recursively. rm -rf directory #Copy file1 to file2. cp file1 file2 #Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with the contents of source_directory. cp -r source_directory destination #Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2. mv file1 file2 #Create symbolic link to linkname. ln -s /path/to/file linkname #Create an empty file or update the access and modification times of file. touch file #View the contents of file. cat file #Browse through a text file. less file #Display the first 10 lines of file. head file #Display the last 10 lines of file. tail file #Display the last 10 lines of file and "follow" the file as it grows. tail -f file

      5. FILE PERMISSIONS
      0_1543122821558_linux-permissions-chart.png

      PERMISSION EXAMPLE

      U G W rwx rwx rwx chmod 777 filename rwx rwx r-x chmod 775 filename rwx r-x r-x chmod 755 filename rw- rw- r-- chmod 664 filename rw- r-- r-- chmod 644 filename

      6. PROCESS MANAGEMENT

      #Display your currently running processes. ps #Display all the currently running processes on the system. ps -ef #Display process information for processname. ps -ef | grep processname #Display and manage the top processes. top #Interactive process viewer (top alternative). htop #Kill process with process ID of pid. kill pid #Kill all processes named processname. killall processname #Start program in the background. program & #Display stopped or background jobs. bg #Brings the most recent background job to foreground. fg #Brings job n to the foreground. fg n

      7. PERFORMANCE MONITORING AND STATISTICS

      #Display and manage the top processes. top #Interactive process viewer (top alternative). htop #Display processor related statistics. mpstat 1 #Display virtual memory statistics. vmstat 1 #Display I/O statistics. iostat 1 #Display the last 100 syslog messages (Use /var/log/syslog for Debian based systems.). tail 100 /var/log/messages #Capture and display all packets on interface eth0. tcpdump -i eth0 #Monitor all traffic on port 80 ( HTTP ). tcpdump -i eth0 'port 80' #List all open files on the system. lsof #List files opened by user. lsof -u user #Display free and used memory ( -h for human readable, -m for MB, -g for GB.). free -h #Execute "df -h", showing periodic updates. watch df -h

      8. NETWORKING

      #Display all network interfaces and ip address. ifconfig -a #Display eth0 address and details. ifconfig eth0 #Query or control network driver and hardware settings. ethtool eth0 #Send ICMP echo request to host. ping host #Display whois information for domain. whois domain #Display DNS information for domain. dig domain #Reverse lookup of IP_ADDRESS. dig -x IP_ADDRESS #Display DNS ip address for domain. host domain #Display the network address of the host name. hostname -i #Display all local ip addresses. hostname -I #Download http://domain.com/file. wget http://domain.com/file #Display listening tcp and udp ports and corresponding programs. netstat -nutlp

      9. ARCHIVES (TAR FILES)

      #Create tar named archive.tar containing directory. tar cf archive.tar directory #Extract the contents from archive.tar. tar xf archive.tar #Create a gzip compressed tar file name archive.tar.gz. tar czf archive.tar.gz directory #Extract a gzip compressed tar file. tar xzf archive.tar.gz #Create a tar file with bzip2 compression. tar cjf archive.tar.bz2 directory #Extract a bzip2 compressed tar file. tar xjf archive.tar.bz2

      10. SEARCH

      #Search for pattern in file. grep pattern file #Search recursively for pattern in directory. grep -r pattern directory #Find files and directories by name. locate name #Find files in /home/john that start with "prefix". find /home/john -name 'prefix*' #Find files larger than 100MB in /home. find /home -size +100M

      11. SSH LOGINS

      #Connect to host as your local username. ssh host #Connect to host as user. ssh [email protected] #Connect to host using port. ssh -p port [email protected]

      12. FILE TRANSFERS

      #Secure copy file.txt to the /tmp folder on server. scp file.txt server:/tmp #Copy *.html files from server to the local /tmp folder. scp server:/var/www/*.html /tmp #Copy all files and directories recursively from server to the current system's /tmp folder. scp -r server:/var/www /tmp #Synchronize /home to /backups/home. rsync -a /home /backups/ #Synchronize files/directories between the local and remote system with compression enabled. rsync -avz /home server:/backups/

      13. DISK USAGE

      #Show free and used space on mounted filesystems. df -h #Show free and used inodes on mounted filesystems. df -i #Display disks partitions sizes and types. fdisk -l #Display disk usage for all files and directories in human readable format. du -ah #Display total disk usage off the current directory. du -sh

      14. DIRECTORY NAVIGATION

      #To go up one level of the directory tree. (Change into the parent directory.). cd .. #Go to the $HOME directory. cd #Change to the /etc directory. cd /etc

      @Linux-Help

      Linux
    • Arch Linux Touchpad Drivers

      Rusiru Athukorala

      Antergos Distro එක ඉන්ස්ටෝල් කරා නමුත් ටච් පෑඩ් ඩ්‍රයිවර් දාගන්නෙ කොහොමද?Synaptic ඩ්‍ර්‍යිවර්ස් ඩිවලොප් වෙන්නෙ නැද්ද මේවට? @sudo මේ ගැන විස්තරයක් දෙන්න පුලුවන්ද?Acer Aspire E 15 E5-575G @root

      Linux
    • Linux

      Rusiru Athukorala

      ලිනක්ස් ගැන පාඩම් ටිකක් යනව නම් හොදයි දන්න කෙනෙක්ගෙන්

      Linux
    Log in to post
    • Newest to Oldest
    • Oldest to Newest
    • Most Posts
    • Most Votes
    • root

      The best Linux distro in 2018 (#1 in distrowatch.com)
      arch desktop os linux • • root

      20
      3
      Votes
      20
      Posts
      2465
      Views

      crxssrazr93

      @sudo said in The best Linux distro in 2018 (#1 in distrowatch.com):

      @crxssrazr93 i don't know man. I know few people who switched directly from windows to manjaro. But i agree a normie might not be able to do that.

      Exactly. I switched from Windows to Arch Linux back in the day too but the linux community kept pushing me back because I didn't know how to troubleshoot and fix or approach most problems that may arise if you use Arch. I use Manjaro extensively. Everyone was like "Arch is not for you, get a more user friendly os instead blah blah." Thank god I didn't give up but I did learn alot though it was a real sh*tstorm at the beginning. 10/10 would do it again.

    • lkdev

      Nginx: connect() failed (111: Connection refused) while connecting to upstream
      nginx php server ubuntu • • lkdev

      7
      0
      Votes
      7
      Posts
      5024
      Views

      crxssrazr93

      @lkdev said in Nginx: connect() failed (111: Connection refused) while connecting to upstream:

      @crxssrazr93 said in Nginx: connect() failed (111: Connection refused) while connecting to upstream:

      @lkdev

      Make sure php-fpm is already running on the background...

      Then, change your listen 80; to listen 127.0.0.1; .

      @ciaompe said in Nginx: connect() failed (111: Connection refused) while connecting to upstream:

      Simply, open the following path to your php5-fpm (if you php 7 then open php 7 fpm)

      Php 5

      sudo nano /etc/php5/fpm/pool.d/www.conf

      Php 7

      sudo nano /etc/php/7.2/fpm/pool.d/www.conf

      Then find this line and uncomment it:

      listen.allowed_clients = 127.0.0.1

      Also comment below line

      Php 5

      ;listen = /var/run/php5-fpm.sock

      Php 7

      ;listen = /run/php/php7.2-fpm.sock

      and add

      listen = 9000 after you make the modifications, all you need to restart or reload both Nginx and Php fpm

      Php 5

      sudo service php5-fpm restart

      Php 7

      sudo service php7.2-fpm restart

      Nginx

      sudo service nginx restart

      Guys this works. thanks aganin and lankadevelopers thank you very much

      Anytime mate xD

    • root

      What are the best cpanel alternatives (free)?
      cpanel hosting linux • • root

      5
      0
      Votes
      5
      Posts
      546
      Views

      root

      @b6 ok bro i'll see that

    • Rusiru Athukorala

      Linux
      learn linux programming • • Rusiru Athukorala

      8
      1
      Votes
      8
      Posts
      852
      Views

      dev_lak

      @Rusiru-Athukorala welcome machn

    • Rusiru Athukorala

      Arch Linux Touchpad Drivers
      archlinux drivers laptop linux root • • Rusiru Athukorala

      3
      0
      Votes
      3
      Posts
      540
      Views

      S

      @Rusiru-Athukorala said in Arch Linux Touchpad Drivers:

      ?Acer Aspire E 15 E5-575G

      Acer 575G wla awl tyena bro linux support wala. mama hoyala balala kiyannm.

    • Danuva

      This topic is deleted!
      • Danuva

      1
      0
      Votes
      1
      Posts
      1
      Views

      No one has replied

    • root

      Linux Commands For Developers
      centos commands linux redhat ubunu • • root

      8
      8
      Votes
      8
      Posts
      1150
      Views

      waex97

      thanx ❤

    • binurayeshan

      Sum of two numbers in bash script
      bash linux linuxfoundation • • binurayeshan

      3
      4
      Votes
      3
      Posts
      216
      Views

      root

      Superb bro

    • binurayeshan

      First bash script
      bash linux scripting • • binurayeshan

      8
      4
      Votes
      8
      Posts
      343
      Views

      root

      @Binura-Yeshan-Samarawickrama

      widnows wala ta danna. godak aya dan use karanne windows 10

    • binurayeshan

      Simple linux commands for beginners part 2
      linux linuxfoundation • • binurayeshan

      1
      2
      Votes
      1
      Posts
      129
      Views

      No one has replied

    • binurayeshan

      Bash script Array introduction
      bash linux scripting • • binurayeshan

      5
      3
      Votes
      5
      Posts
      932
      Views

      binurayeshan

      @dev_lak Thank you...

    • binurayeshan

      Understand permission of a file in Linux
      linux linuxfoundation • • binurayeshan

      5
      4
      Votes
      5
      Posts
      227
      Views

      binurayeshan

      @root said in Understand permission of a file in Linux:

      very easy to understand , thanks bro

      Thank you very much brother

    • binurayeshan

      change read write execute permission of a file linux
      linux linuxfoundation • • binurayeshan

      7
      3
      Votes
      7
      Posts
      291
      Views

      binurayeshan

      @root said in change read write execute permission of a file linux:

      Superb bro

      Thank you very much bro

    • binurayeshan

      How to copy and move files on linux
      linux linuxfoundation • • binurayeshan

      5
      3
      Votes
      5
      Posts
      215
      Views

      cg-xx

      supiri wadak.

    • binurayeshan

      unsert variables in Bash Scripting
      bash linux linuxfoundation scripting • • binurayeshan

      3
      2
      Votes
      3
      Posts
      173
      Views

      dev_lak

      great bro

    • binurayeshan

      Read only variables in Bash Scripting
      bash linux linuxfoundation scripting • • binurayeshan

      3
      2
      Votes
      3
      Posts
      190
      Views

      root

      good work bro

    • binurayeshan

      DECISION MAKING IN SHELL SCRIPTS(Write a shell script to determine whether a given number is either positive or negative)
      bash linux linuxfoundation • • binurayeshan

      4
      4
      Votes
      4
      Posts
      206
      Views

      dev_lak

      thanks bro

    • binurayeshan

      File Test Operators(bash script use කරල file එකක් හදල permission දීල run කරමු)
      bash linuxfoundation scripting • • binurayeshan

      2
      3
      Votes
      2
      Posts
      287
      Views

      Nubelle

      eka patta mchan

    • binurayeshan

      Arithmetic operators in BASH scripting
      bash linux scripting • • binurayeshan

      2
      2
      Votes
      2
      Posts
      147
      Views

      Nubelle

      patta pata machn

    • binurayeshan

      DECISION MAKING IN SHELL SCRIPTS Part 2(කොහොමද Arguments දෙකක් එක්ක වැඩ කරන්නෙ)
      bash linux scripting • • binurayeshan

      3
      1
      Votes
      3
      Posts
      308
      Views

      Nubelle

      fatta mchan

    • 1
    • 2
    • 1 / 2
    • Privacy
    • Terms & Conditions
    • Donate
    • Contact Us

    © Copyrights and All right reserved Lanka Developers Community

    Made with in Sri Lanka

    | |