LINUX

 Advantages of Linux 


It was the year 1991, a young lad named Linus Torvalds, a 21-year-old computer science student, was frustrated with the limitations of the current paid operating systems. The only open source at that time was UNIX, which was not well-suited for his needs. So he created a new, spiraling system called Linux, which was an open source system that was free to modify and use.


Well, if you’ve noticed, I’ve already listed advantages of Linux like open source and customizable, but there are many more to go. Like, Linux has an additional language that works only on Linux — shell scripting — which generally doesn’t require a compiler.


Besides that, Linux focuses on efficiency. When you give it a task, it will only invest its energy and resources to complete that given task. There’s nothing working in the background. Imagine if we humans had that clarity that’s the efficiency!


The biggest feature Linux has to offer is security. It is the most precious thing one could ask for, and Linux providing that for free is crazy!


Linux ticks every box of what a good operating system should.


2) Commands and Scenario:


1)echo

Concept : displays anything

Syntax : echo “Text”

Scenario : I want to display Hello World


2)date

Concept : displays current date

Syntax : date

Scenario : I want to display today's date


3)cal

Concept : Displays current calendar

Syntax : cal

Scenario : I want to know the present month and day


4)read

Concept : To save variable 

Syntax : read variable_name

Scenario : Shoeb wants to take a variable from the user and save it.


5)mkdir

Concept : to create a new directory 

Syntax : mkdir folder_name

Scenario : I want to create a new directory for my project.


6)cd

Concept : To change the directory 

Syntax : cd directory_name

Scenario : I want to work in my project directory


7)ls

Concept : List of files in the current working directory

Syntax : ls

Scenario : I got into my old directory but I don’t remember the files so I use ls


8)touch

Concept : 1)If file doesn’t exists it creates a new file

                 2)If file already exists it updates the file

Syntax : touch file_name_with_extension

Scenario : I created new file linux.txt with touch then I added a few more lines so to update I used touch again.


9)cp

Concept : Used to copy 1 file to another 

Syntax : cp Source Destination 

Scenario : I wanted to copy linux.txt to fedora.txt


10)pwd 

Concept : displays current working directory 

Syntax : pwd

Scenario : I wanted to see the directory I was working in


11)cat

Concept : it displays the file content 

Syntax : cat file_name_with_ext

Scenario : I wanted to check the file content of linux.txt


12)man

Concept : Access manual for all files 

Syntax : man command


13)grep 

Concept : search for specified in a mentioned or specified thing

Syntax : grep string_you_want_to_search file_name_ext

Scenario : I want to search mit in linux.txt


14)whoami

Concept : displays current user 

Syntax : whoami

Scenario : I want to know who accessed my pc


15)sed

Concept : used to edit or remove text 

Syntax : sed [options] script [file]

                    1) i:in place editing

                    2)n:supress automatic print

Scenario : I want to remove a particular line in linux.txt


16)head

Concept : displays contents top line in the file

Syntax : head -n no of lines file name

Scenario : I wanted to display the top 4 lines in linux.txt


17)tail

Concept : it displays the contents of bottom lines in the file

Syntax : tail -n no of lines file name

Scenario : Teacher wanted to know who were the bottom 5 in the class so she used tail in class.txt.


18)Decision making statement

Concept : Wherever there are 2 possibilities 

Syntax : If [condition]

              then

              else 

              fi


Scenario : echo “1 for yes, 2 for no”

                 read a

                 if [(($a) le 1)]

                 then 

                 echo “Yes”

                 else

                 echo “No”

                 fi

19)Loop 

Concept : Used to make iterations that are multiple back and forth trips

Syntax : while [ ]

               do

               done

Scenario : i = 10

                while [ i -ge 5 ]

                do

               echo "$i"

              i = i - 1

              done 


20) Line Concatenation 

Concept : to display a line in front of a line

Syntax S = "$( first line input ) $(second line input)

Scenario : 

echo : " Enter your college"

read n

echo : "Enter your college City"

read s

S = "$n $s"

echo "Your college is $S"


21 ) String comparison 

Concept : compares two strings with scrutinizing every letter

Syntax + Scenario : 

S1 = PASSWORD

S2 = password 

If [[ "$S1" =~ "$S2" ]]

then 

echo " access "

else

echo "access denied"

fi


22) Switch case 

Concept : Allows condition branching with the help of cases

Syntax : variable = a

Case "$a" in

("Case 1") echo " text " ;;

("Case 2") echo " text" ;;

esac

Scenario :

a=people

case "$a" in

"Xyz") echo "Enemies" ;;

"Pqr") echo "Friends" ;;

esac


23) For loop

Concept : Runs the same set of commands again and again for each value in a list or range.

Syntax :  for variable { start . . end }
                do
                done
Scenario : for i { 1 . . 5 }
                   do 
                   S = $((i*i))
                  echo "square of $i is $S"


24) function 

Concept : A function is a reusable block of code ,Write once, use many times

Syntax : function ()
               {
               code
               }
               function 
Scenario : 
    echo "Enter 1 for Yes"
    echo "Enter 2 for No"
    read c
    choice ()
    {
    if [ $c == 1 ]
    then
    echo "You chose Yes"
    elif [ $c == 2 ]
    then
    echo "You chose No"
    else
    echo "Invalid input"
    fi
     }
     choice

25)Continue 

Concept : Skips the current loop step and goes to the next one

Syntax : Loop (for/while)
                
               if [ condition]
               then
               continue 
               fi
Scenario : for i in { 1 . .5 }
do
if [ $i == 3 ]
then
continue
fi
echo $i
done


26) Break 

Concept : Breaks or discontinues loop 

Syntax: Loop (for/while)

if [ condition]

then

Break 

fi

Scenario : 
for i in { 1. . 5}
do
if [ $i  == 4 ]
then
break
fi
echo $i
done

         
               

3 Conclusion and Commands 

In a language for instance maybe English ,Hindi , Marathi etc Grammar plays an important role in molding the sentence in a way that our brain could process and understand it.Similarly these commands do the same work here so understanding them is a quint essential for one who wants to master linux , below are the commands with quick summary

1)echo : It is used to display anything on the screen


2)date : It is used to display the current date


3)cal : It is used to display the current calendar


4)read : It is used to take input from the user and save it in a variable


5)mkdir : It is used to create a new directory


6)cd : It is used to change the directory


7)ls : It shows the list of files in the current working directory


8)touch : It creates a new file or updates an existing file



9)cp : It is used to copy one file to another


10) pwd : It displays the current working directory


11) cat : It displays the content of a file


12)man : It is used to access the manual of any command


13)grep : It is used to search for a given word inside a file


14)whoami :  It displays the current user


15)sed : It is used to edit or remove text in a file


16)head  :It displays the top lines of a file


17) tail :  It displays the bottom lines of a file


18)Decision making : It is used when there are two possible outcomes


19)Loop :  It is used to perform repeated actions multiple times


20) Line concatenation : It is used to join two lines or strings together


21)String comparison : It is used to compare two strings letter by letter


22)Switch case : It allows branching based on different cases

23)continue : skips the current loop step and moves to the next.


24) break : stops the loop completely

25 ) for loop: repeats a set of commands for each value in a list


26) function: a reusable block of code you can call anytime

Comments