linux blog

Linux Blog Writing 
Name :- Tanuja Tidake 
PRN :- 202501040063
Div :- CS1 
Batch :- C13

Advantages of Linux

Linux is Free and open-source means operating system allowed user to view, modify, distributed it source code no cost, fully customizable.

Linux is highly secure means fewer viruses and strong permission.

Linux is faster performance like works even on old or low spec systems.

Linux is good for servers, stable and reliable.

Linux is great for programming for supports all major languages and tools.

It is use everywhere like servers, Android, cloud and supercomputer.

All Commands with Syntax, Use and Scennio

1) ls

Syntax :-  ls -l

Scenario 1 :- show the all files in your directory 
 Scenario 2 :-  Show only directories

2) echo

Syntax :- echo

Scenario 1 :- I want to display my name
Scenario 2 :- Print your marks

3) read 

Syntax :- read 

Scenario 1 :- To read the variable name 
Scenario 2 :- To read the user name

4) cd

Syntax :- cd directory name

Scenario 1 :- Mam said that move to the linux  2025 directery 
Scenario 2 :- Go directory to the home directory

5) mkdir

Syntax :- mkdir directory name

Scenario 1 :- You want to create folders for assignments and notes.
Scenario 2 :- Neha want to create subfolders

6) chmod

Syntax :- chmod +x filename.sh

Scenario 1 :- You want to be creat a file like notes.txt and display the given file
Scenario 2:- I want to create file for mall management and I gives a permission for execution 

7) touch

Syntax :-  touch filename

Scenario 1 :- Priya make a file for his daily routine by using touch command 
Scenario 2 :- The CEO is starting a new project inside his project folder,he needs to create several empty files 

8) cat

Syntax :-  cat filename.sh

Scenario 1 :-  Mihir  creat file like Song.txt and he display the all songs inside the file. 
Scenario 2 :- Most of the time user use a cat command to display the conent of file

9) sed

Syntax :- sed [option] 'script' [file]

Scenario 1 :- delete line numbes 5 from a file
Scenario 2:- I want to remove all entries of employes who have left the company & marked as "Resigned"

10) head

Syntax:- head -n filenam

Scenario 1 :- The group are writing a program that generate output in output.txt and want to check only the top few lines to confirm a format
Scenario 2 :- I want to read 10 lines inside the data.txt

11) tail

Syntax :- tail -n filename 

Scenario 1:- Mam want to be check last 10  entries from student record file.
Scenario 2 :- I want to check last 3 lines to confirm the end statement 

12) grep

Syntax:- grep -i "___" filename | wc -l 

Scenario 1:-  I want to know the exact line numbers where "Linux" appears in pt.txt
Scenario 2 :- Manager want to find all employes who work in the sales department

13) cp

Syntax :-  cp filename

Scenario 1 :- Mahima want to copy program into the given directory.
Scenario 2 :- In Hospital nurse create a new directory called backup and she want to copy the file there

14) clear

Syntax :- clear 

Scenario 1 :- Students enter in lab then they removes all previous text and gives a fresh terminal
Scenario 2 :- There are most of the error on the terminal I want to clear terminal

15) date

Syntax :- date

Scenario 1 :- display a day, month and time in the pattern like hour : minute : second.
Scenario 2 :- If your system clock is wrong. you can check it using date command 

16)  cal

Syntax :- cal [ month ] [ year]

Scenario 1  :-  The small child was interested to see new calendar 
Scenario 2 :- Amit want to see a june month 

17)  file *

Syntax :- file *

Scenario 1 :-  I received a file name report.txt,but it is not open 


18) If Else

Syntax :- if [ condition ] 
                then
                         logic
                else
                         logic
                fi

Use :-  It is decision making statement

Scenario :- Mam gives a program for student take positive integer and tell if it is divisible by 5 or not

echo "Enter a number:  "
read n
if [ $((n%5)) == 0 ]
then
        echo " divisible by 5 "
else
       echo " not divisible by 5 "
fi

19) While loop

Syntax:- while [ contion ] 
               do
                     logic
              done

Use  :- While loop is used to iteration like repeat a block of commands multiple times.

Scenario :-  I want to display multiples of 3 up to 30.

i = 3
while [ $i -le  30 ] 
do 
        echo "$1"
         i = $(( i+3))
done

20)  for  loop

Syntax  :-  for variable in { start .. end } 
                  do
                           logic
                 done

Use :- repeat a set of commands.

Scenario :-  I want to print even numbers.

for i in { 2.. 20..2 }
do
       echo" $i"
done

21 ) Continue

Syntax :-  Continue 

Use  :-  Inside loops to skip the remaining commands in the current iteration and jump to the next iteration of the loop.

Scenario :- Print numbers from 1 to 20, but skip the number 10
 for num in { 1..20 }
do
      if [ $num -eq 10 ] 
then
     continue
fi
     echo "$num"
done

22) Break

Syntax :- break 

Use :- to stop the execution of a loop

Scenario :- Sir want to search for a file named entry.txt in a directory .It is found, stop checking other files.

for file in *
do
      if [ "$file" = "enty.txt"]
then
      echo " File found : $file"
      break
fi
done

23) String Concatenation

Syntax :- str3 = "$ str1 $ str 2"

Use :-  Combine two or more strings.

Scenario :- In hospital stores patient name by joining first name and last name. Combine the two names and display the full name.

Str1 = "Mansi"

str2 = " Nikam"

fullname  = "$str1 $str2"

echo "Full Name: $fullname"

24) String Comparison 

Syntax :- variable  =~ variable 

Use :- decision making inside scripts and checking empty or non-empty strings

Scenario :- The manager wants to check if the name of two staff is same 
s1 = " seema"
s2 = " reema "
if [ $s1 =~ $s2 ]
then
echo " same "
else 
echo " not same"
fi


Conclusion 
Use of command 
  
1) ls :-  lists the contents of a directory 
2) echo :- display on terminal
3) cd :- change the current directory 
4) mkdir :- make a directory 
5) chmod :- permission for execution 
6) touch :- creating a new file 
7) cat :- display the content of file 
8) sed :-  perform various transformation on text
9) head :-  display the beginning lines of a file
10) tail :-  display the ending lines of a file 
11) grep :-  searching for patterns in files 
12) cp :- for copy 
13) clear :- clear a teminal screen 
14) date :- display or set system date and time 
15) read :- to read or show the input 
16) cal :- to show the regular calendar month 
17) file * :-  list the all files in current directory 
18) mv :- to move the files and directories from one to another 
19 ) rm :-  remove the files and directories 
20) pwd :- print the full path of the current working directory 
21) whoami :-  to check the current user login 
22) if else :- it is decision making statement 
23) while loop :- while loop is used to iteration like repeat a block of commands multiple times 
24) for loop :- repeat a set of commands
25) continue :- inside loops to skip the remaining commands in the current iteration and jump to the next iteration of the loop
26) break :- to stop the execution of a loop
27) string concatenation :- combined two or more strings 
28) string Comparison :- decision making inside scripts and checking empty or non- empty string 

Comments