Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 19

--> 3rd CA 7.

--> use any open source software to generate a detailed report of your system to
investigate what
happened on a computer in last 3 months.

--> revision control system

-->

-->

<----------------------------Theory of Open Source ----------------------------->

--> It was developed by ESR - Eric Steven Raymon - 1998

1. Open Source Software- Open Source Software is a computer software whose source
code is available to general
public for use as it is or with modifications. This software usually doesn't
require a license.

--> OSS is always released under a license or copyright which must meet the
criteria of Open Src definition

--> The major difference between proprietary software and open source software
is that open source software
doesn't require license.

---> Advantage of OS

1. Free of Cost
2. Flexibility
3. Relability and Quality

2. Difference between Open source?, Freeware, Free software , shareware?

1. Freeware - Freeware software is a Computer software which is freely available &


doesn't cost any money.
Source code of Freeware softwares are not available. For
example 1.Skype 2.Team Viewer

2. shareware software - Shareware software is a computer software which is used for


marketing purpose. Computer users
can download and use limited version or full version of software for limited
period of time. Shareware software are also
known as "Try before you buy". Example

1. WinZip
2. Adobe Acrobat 8 Professional

3. Free software - It is a computer software which can be used, modified and


studied without any restriction. It can be
copied and distributed with or without modifications. For example, Linux OS,
Linux kernel, Relational Database Mysql
---> These citeria include right to

1. redistribute the software without any restriction


2. acess the source code
3. modify the source code
4. distribute the modified software

<---------------------Propriteary Software ---------------------->

** software - It is the set of instructions which tells the computer hardware to


perform a specific task.
** source code - It is the set of instruction which is the basis of any software

1. Proprietary Software - It is a computer software in which users need to buy the


license before using it. The source
code of Proprietary software is not available to general public. The user is
not allowed to view, copy, modifiy or
distribute the source code. The owner is only allowed to distribute the
software to any number of users.

--> Advantage of Proprietary Software

1. Stability
2. Relability
3. User-friendly

1. Pragmatism - It is a philosophical approach that evaluates therories and beleifs


in terms of success of their pratical application

2. Ideallism - It refers to any philosophy that states reality is mentally


constructed

--> Pragmatism vs Idealism - The key difference between pragmatism and idealism is
that prgamatism considers the practical consequences
of an action as its main componenet where as idealism considers mental
enitites or thoughts and idea as its main component.

1. Intellectual Property Rights - IPR is the right to specific type of intangible


assets which have been created. The ownership
IPR provides rights for the protection and commercialization of assets.

-> Types of IPR

1. Copy right act 1957


2. Trademark
3. patents
4. design
5. plant varieties
6. geographical indications
7. semiconductor integrated layout circuits.
1. Copyright Act 1957 -> The copyright act 1957 under section 17 clearly states
that the author of the original work shall be the first
owner of the work. The validity of copyright is for 70 years.

-> The owner has the right to licenese the copyright of thier work to third parties
through a written agreement.

2. TradeMark Act 1999 - The Trademark Act 1999 states that trademark is a graphical
mark that is capable of distinguishing the
goods or services of one person from other. A trademark provides protection for
symbols, colors, shapes, words, etc.
representing goods or services. The validity for trademark is 10 years which
can be renewd succesively.

3. The Patent Act 1970 - The Patent Act 1970 is an IPR that protects any new
invention. It protects the right of the inventor and
prevent unauthorized use and missappropriation of registered patent. The patent
is only registered if invention is novel and
original and is not introduced in any public domain. The validity of patent is
20 years.

4. Design Act 2000- The Design Act 2000 is an IPR that protects shape,
configuration, pattern, applied to any article either in 2d
or 3d or in both forms. A design is only registered if it is novel and original
and is not introduced to any public domain.

---> Licenese - It is a permit from an authority to use something or do a paticular


thing

---> Software license - It is an agreement that gives a user the right to use a
paticular software

---> OS License - It is a license which gives user the right to distibute,


access ,modify, and redistribute
the modified version of the software.

----------> Licensing agreements

1. Limited License - It is a license where there is limited copies of software is


avalilabe for insallation.

2. Unlimited - It is a license where there is unlimited copies of software


available for installation

3. Volume Purchase Agreement - It is an agreement where an organization buys large


number of copies
in reduced price. This is mostly used for propreitary software.

4. End User license agreement - It is an agreement between author and the end user
of the application.

--> General Public License - To make a software freely available we need to release
it under a free software license for that
purpose we use General Public License.

----------> Licensisng Types

1.

<------------ Types of software licensing ----------->

1. Adware
2. Demoware - It is CS that allows user to see what full version of the software
looks like
3. free software - same as previous
4. shareware software - same as previous
5. liteware software - It is CS that which is of limited verison or lite version of
particular software.
The user has to pay to use this liteware software.
6. spyware software - It is CS that is used by the organization to track their
user's activity.

<------------ Difference between Copyright and Copyleft --------------->

Copyright - It is an act which states that the original author of the work shall be
the first owner of the work.
This act further states that the owner has right to license the
copyright of their work to the third
parties through a written agreement.

The exclusive legal right to use, copy, and distribute a creative


work.

Copyleft - It is an act where a software owner has granted its users a license to
modify and alter thier work such
permission and license are known as Copyleft.

For instance, software having a copylefted license can be modified,


used, distributed, or reproduced
and source code of such software should be kept open and available
to the public.

--> It is also known as the right to use, modify and distribute the software on
condition anything derived from it
is bound by the same condition.
<--------------Open and Closed Source Technologies -------------->

1. Open Source Technology - refers to Open source software all the definition of
OSS

2. Closed Source Technology - refers to Propreitary software in which user has to


buy the license before using it .
Definiton in more details

----> Difference between Open source and Closed source in terms of

1. Cost - OSS is free to use


CS we have to buy a license to use it

2. Service - OSS service is not so good compared to propreitary software


CS - has the best service

3. Innovation - OSS provides flexibility in modifiying the code and distribute it


CS - User has not those rights they have to wait for
owner/organization for the update

4. Usability - Low usability compared to CS


CS high usability

5. Security - OS - doesn't provide good security becuase it is not developed in


controlled environment

CS - provide good security because it is developed in


controlled environment

<----------------------Linux Theroy------------------------------->

1. shell - It is a program that takes the command typed by the user and calls OS to
run those commands

2. shell script - It is a plain text file which stores one command per line

3. System defined variables - These variables are defined and maintained by the
system itself. They are defined
using Capital letters

4. User defined variables - These variables are defined and maintained by the user
itself. Lower letters

5. Variables - It is nothing more than a pointer to an actual data. It must be


accessed using $ but can defined
normally. i.e; var1="lpu".

6. readonly variables - They are the variables which can't be modified i.e;
readonly variable_name

7. unsetting variable - Once you unset a variable you can't access the value of
that variable
<----------------------------Theory of Open Source ----------------------------->

-- CA-1, CA-2, CA-3

1. CA-1 - Next week, Unit-1, before control structure.


2. CA-2 - Get the dairy number.

- # - It is used for commenting

Int 301 -

-> How to work with shell?

--> Note - Shell scripts store plain text file, generally one command per line.
--> shell - It is the collection of commands group of commands that we can create
to run multiple things

1. vi script.sh - vi is the editor, script is the name and sh is the extension

-> we can either use .bash .sh for file extension for script for identification

-> Commands - read the data from system defined variables

1. mkdir
2. cd
3. pwd - present working directory
4. nano script.sh -- GNU nano is the editor
5. who -
6. tty - terminal type
7. whoami - name of the user
8. touch - to create a empty file
9. cat - display the data content on the terminal
10. ls -l ---> to see the properties associated with that file
11. chmod- change mode - giving permission , r-4, w-2, x-1 - 7

--> change file ./script.sh

--> maximum allwoed permission for a file - 6


--> maximum allwoed permission for a directory - 7

Note - > shell based system - everything is considered is the file

----------> 23 january

#!/bin/bash - inital statement so that your system execute the script bash --->
bash is the shell

-> bash - It is the by default shell

--> chmod 777 variable.sh ( changing the permission)


--> ./varibales.h - to run it
--> ls -l variable.sh ( name of the file is also necessary)

----> copy and paste from source to destination within the same directory

1. first you need to create a new file - using --> touch new.sh
2. copy from source to destination -> cp variable.sh new.sh

----> difference between echo and printf --> echo- gives the new line each time ,
printf- doesn't gives the new line

--> why do we need prermission?


Ans -rw-rw-r-- --> owner or user, group, others

--> our main concern is owner it already has read and write permission but it
doesn't have execute right

--> r-4, w-2, x-1 ---> 1. chmod 777 - This is octal method

1. chmod u+x ---> This is symbol method

Note - We are only concerned about the user/owner that's why he need to assign
EXECUTE command to it
that's why we are giving it 7, r-4 w-2 x-1, by default the permission
given to file is 6 we are giving it
one more right i.e; execute command.

---> In conclusion we can say that we need to chmod because it only has read write
permission without execute
permission it won't run that's why we are giving execute also, x -1

--> env --> gives all the system defined variables also known as environment
variables

--> echo $SHELL , --> it gives the current shell -> /bin/bash

--> echo $LOGNAME, --> it gives the current user

------> how to take Input from the user ?

-> There are two ways to take


input from the user

--> 1st way - using read


--> 2nd way - using positional parameter or CLA - Command Line Arguments

---> Use Command Line Arguments in a Bash Script

1. $0 - name of the program --> ./new.shh


2. $* - value of all the arg. passed at Command Line
3. $@ - same as $*
4. $# - count of arg. passed at CL
5. $? - status of last executed command - 0,1 --> 0 means previous command
executed, 1- didn't executed -> It has boolean response
It has a blooean response 0 means success 1 means unsucessful

6. $$ - PID of bash - process id of bash -> bash is the shell where our entire code
is working

-------> 25th January (Revision)

--> System defined variables-> Capital letters, fetch value of EV using $, they
always have name and value associated with it.

--> User defined variables -> Small letters, we can set and unset value -> set x =
10 , unset value b="lpu" c=1, read value $x

--> When initializing the variable there should be no space b = "lpu"

-----> read only x = It doesn't allow you to change the value, x=5 and x=20, it
won't change

-----> unset x="lpu" unset x echo"$x" the value of x is empty now

-------> Display anything in the terminal echo vs printf

1. echo - It gives me new line every time


2. printf - It prints out every thing on the same line

-----> Taking input from the user ---> two ways

1. read - from the user --> command --> read name

2. command line arguments -> $1 - $9 after 10 ${10}

----> Generally new file is started with #!/bin/bash -- by default our shell is
bash

---> Note: From where we start the positional paramters from there input will be
start taking
---> If I start $1 at second line now from there input will start taking

----> (STDIN - It is an initial buffer -> reading is done by the keyword --> always
consider your self as an Operating system )

----> $? - It is not concerned wether the line before it was executed or not. It is
concerned with the command that executed
before it. It takes the previous command

--> Ways of writing the expression

1. In expression we need double brackets and there is no space anywhere c=$(($a+


$b))
2. c=`expr $a + $b ` --> space within the backtick but while asssigning no space
--> expr - expression

--------------------------> 30th January

scale - It is a command which tells us how much decimal line we need ---> bc - It
is the basic calculator

echo "scale=2; $a / $b " | bc

Question- Write shell script to create a file inside a directory. The file name
should be passed as first argument and the
directory name/path should be passed as second argument

----> Take input from the user means use read

-----> Command Line Arguments = This means take input during run time

----> How to run the file if you want to enter the things in run time

<---------Very Important --------->

./nano.sh _$1_ _$2_ ---> You have to give input at run time beside the file name

------> Write CLA to make a directory and take them as 3rd and 4th arguments and
create 2 files as
1st and 2nd arguments

---> Finals - Expect questions from Loops

----> We can also make two files at one touch $1 $2 - It is during run time only

====> ( ..) - It means go to parent directory

--> Question#2 Write a shell script which checks the total number of command line
arguments passed. If the argument count is
greater than 5 display the message "Too many arguments"

---> Hints
---> $# - count
---> Take input during run time i.e; command line
----> To count CLA we have to use #$

Ans

if [ $# -gt 5 ]
then
echo "too many command line argumetns"
else
echo "$*"

----------------> 1st Feb

---> if [ $a -eq $b ]

-> -eq - is equal to

----> File Test Operators

1. -d check if the file exists and is a directory


2. -e check if the file exists
3. -r check if the file exists and is readable
4. -s check if the file exists and has a size greater than 0

Question - WASS to take file name as CLA and check whether its writeable or
readable?

#!/bin/bash

if [ ! -e $1 ]
then
echo "file doesn't exists"
elif [ ! -r $1 ]
then
echo "file is not readable"
elif [ ! -w $1 ]
then
echo "file is not writeable"
else
echo "file is both readable or writeable"
fi

----> Loops --> for i in $*

$* = value of all the arguments passed at run time

Question Write a shell script to enter a file/directory name at command line

# chnage its permissions to

# user - rwr
# group - rw-
# others - r--

----code--->

for i in $*
do
chmod 764 $i
done

---code--->
---> For than more time we are going to use for loop

-----> How to check the permissions of directory --> ls -ld __dirname__

Q--> Write a shell script to print the "long list" of all the file names #passed at
the command line

----code--->

---code--->

Q --> WASS to count the number of sub-directories in a directory

---code---->

* pwd - present working directory

cd $1
fc=0
for i in *
do
if [ -d $i ]
then
fc=$(($fc+1))
fi
done
echo $fc

---code---->

1. WAAS to change permission of files/directory to (read,write) for user and only


read for group
and other in your pwd except file named test.txt.
--> change everything expect test.txt

---> (*) - astreik It represents working pwd

2. WASS to display a valid message if the name entered by the user if the current
logged in user.

---> Notes

-> In environment variable we don't have to do ($LOGNAME) because it is an system


define variables
-> In command we have to do $(whoami) otherwise it won't work.

3. switch case syntax in linux


1. case "$day" in
"1") echo "monday"
; ;

4. WASS take a file/dir name from a command line. If name starts with f create file
with that name, if name starts with d
create directory for that name.

#!/bin/bash
for i in $*
do
case $i in f*)
touch $i
;;
d*)
mkdir $i
;;
*)
echo "not a valid name"
;;
esac
done

Notes - We can't use filename and dirname using while we have to use for

---> while example

Q. Write a shell script to generate a multiplication table of a number

------------------------->

---> Nested for -- only possible in terms of numeric

-----------------------> 13th Feb

--> Shell Script Functions

function_name()
{

statements...

--> WASS to create files passed at CLA using functions.

# function calling requires 2 arguments formal and actual. If you don't pass the
arguments it won't create any file

-> $* - It is used to take value of the arguments passed at the command line

-> return is a value passed by the functions to notify the execution has done
competed successfully
-> return is used to know the status of the execution --> whether it executed or
not.
-> 0 - represents successfully done, -1 - Not done

--- code --->


name()
{
echo "Hello World $1 $2 $3"
return 10
}

# function call
name You can doit

#Capture value returned by the last command

ret=$?
echo "Return value is $ret"

o/p - It will be 10 because the return is 10 now -- reutrn is only saying that the
if the functions have successfully executed.
----code---->

---> Factorial of a function using functions.

-------> Arrays - Not a part of the syllabus

---> Different ways to delclare the array

1. echo ${arr[@]}
2. echo ${arr[*]}
3. echo ${arr[@]:0}
4. echo ${arr[*]:0}

----------> 15th Feb -> Everyday it's a challenge to either be a medicore or to


achieve greatness. - Aryan Gupta

--> Handling Signals = Shell Scripting

- OS is event driven, interrupt driven?

- Nodejs - is also event driven?


-getch() - sends signal to the OS.
- Clt+C - sends signal to the OS to stop the execution.
- Can I know all the signals that are in the Computer System?
-> kill command ends all the processes.

-> signals are related to [process] = It is a program under execution

** forground processes = services - They use the terminal


** background processes = Daemons --> handles the resources ->don't use terminal
but are running inside the machines

-> When a program runs it becomes a process.

--> Command -> kill -l - gives list of commands.

--> Bus - It is a communication channel.

----> When we press - CLT+C - It send SIGINT command to the OS to stop the command.

---> parent process have to wait until child process is completed

---> sleep 10 - It is a foreground process it uses the terminal

--> sending foreground to background and bringing it back.

----> How to change foreground process into background proces


** sleep 100000 & -> [3] 5107 --> [3] is the job and 5107 is the PID

--> Command -> kill 5107, ps - process status

----> How to bring the process from background to foreground?


Ans: fg %jobno --> fg %3

--> Clt + Z - to stops the execution --> A signal is send SIGINT to tell the OS to
stop the execution

--> jobs - It only tells me the stopped processes

--> top - It gives similar all the process running to Task Manager in Windows --
How to come out of it? --> Press q

--> Propity values is decided by the - NI values. It ranges from -20 to 19

-----> Commands - Trap- It allows to me specify signals your SS -

--------------> 20th Feb

--> sudo apt-get install gcc [for installing gcc]

--> when you are not in root you have to use sudo.

--> Make file-Multiple Source Files -- This is 10 marks questions


---> Makefile and the-make command

-o -> make output file


-c -> avoid linkage

-> gcc -c add.c -> when it runs

calculator cal.o add.o sub.o -> is created

-----------------------------------------------> 22th Feb -> Creating manual

1. man mkdir
2. man 2 mkdir

--> creating a manual

Q. Let us create a man page for the following bash script I have written:

#!/bin/bash

if [ "$1" == "h" ]; then


echo "Hello"
fi
if [ "$1" = "b" ]; then
echo "Bye"
fi

--> how to run test.1 file -> man __ ./test.1

---> Steps for writing the manual

1. First create a file with the name --> test.1 -> here 1 denotes the section

Q. Now a write a manual for touch command

Input points - what our command does

<-------------------------------RCS -------------------------> Revision Control


System -> rlog Test = to check all the revision that has been done to the file

--> apt -get install rcs

--> to see the difference between two revisions associated with the file you can
use ..................................................-> resdiff .....

-> As the RCS only saves the changes between versions, it's also very space
efficient. , ci- check in , co- check out

touch Test
rcs -i Test --> i = initialization
nano Test

---> OS event driven, interrupt driven ( <-- ) symbolic links created ( actual
file is accessed)
--> Once initialization is done you have to initialize again and again -> rcs -i
Test

---> co -l test1 -> locks the revision

---> How to check the difference ? -> rcsdiff -r1.1 -r1.2 test1 , 2c2,

-------------------------------------------> 27th feb

Q. WASS to create file/directory the deault permissions as read and write at the
time of creation

umask - set whatever you don't want to assign -> umask and chmod are complement
from each other

command - umask - 0022 - first is the paratiy bit , 0 - don't assign zero to users
that means assign
--> you will set what you don't want to assign
--> first zero is the paraity bit which returns when it successfully operated
--> 0 assign everything ---> rwx
--> 2 - means don't assign write --> r
--> 2 - means don't assign write ---> r

--> file -> has rw - r -r --> user, owner , grp


--> umask 002 --> complementary of this --> 6 - 4 - 4 -> which is default
--> default of the file is -rw-r-r -> 6 - 4 - 4 [which umask of 002]

-> file - 6
-> dir = 7

----------------------------------------->

Q. WASS to create a text file and run date command in that in background.

--> append(>>) append the things one after another.

--> redirection (>) - It will create the target file even if it doesn't exist.
-> so if you do , date > file -> even if the file doesn't exist
redirection (>) will create it

--> & - It means run the things in the background

---> command -> cat - display the content of the file.


---> uname -> it is a command it gives the deatails of the system

--> command > filename^C


--> date > q_l
--> uname >> q_l - It will be appended in the file q_l file
-----> Ans - date & > q_l -- ans of the question , & is similar to sleep -> It
means things are running in the back ground.

--> If you want to append then , date & >> q_l , >> It is for appending

--------------------------------------->

Q. WASS to create a user named 'table' and set password for that user to 123.

--> It is a root task you have to switch yourself to root.

-> commands for adding the user

--> adduser table


--> passsword table

----> steps -> cd /etc , (then inside type) nano passwd


----> nano shadow
----> # - command

---> when it asks for the password --> prompt for the password

--> new version of the ans

------> one line ans --> useradd -p 123 table1

--------------------------------------------------> Git and GitHub 1st March and


6th March

--> Git is an open source

--> Git Hub - It is a proprietary software which is owned by Microsoft in 2018.

--> Adding a user inside the Git from the terminal

--> Create a folder -> inside the bash and initalize it with git init --> git add .
(to track it)
--> git status (will tell you whether there is changes to be commited) -->

--- For adding a username and email - User name and email should be same as the one
you have created
1. git config --global user.name "aryan-098max"
2. git config --global user.eamil "aryangupta4279@gmail.com"
3. git config --global --edit ( to check the usernam and emailid in the Visual
studio code)

--> -u is for tracking

---> Whole process of pushing things in git hub repo

Note - You have to use same username and email with which you have created the
file.
Note - From bash you can create notepad in particular folder -> command-> notepad
test.txt

--> adding directory as a safe directory -> command -> git config --global -add
safe.directory desktop:/Int301 ( this is the directory path)

Note- If you are already in that path you don't have to write the directory name

1. Create a folder -> create some files inside


2. Go to git bash -> type git init (intialization) - initalize particular directory
to the git
-> now create a text file or index.html anything

3. git add. (to add the files that you have created) (.) - It represents all the
files in present working directory(pwd)
-> before you do commit you have to add the files (send them to staging
process)
4. git status ( to check the staging process)
5. git commit -m 'doing the task' (commit it)
6. git log ( to check the emailId and username)
7. git remote add origin (link of the new repo from the browser)
if the file already exists ( command : git remote rm origin)

8. git push -u origin master ( master is the file that we are in) -u is for
tracking
9. git remote - tells me the origin
10. git remove -v -> gives me the origin

--> How to remove existing origin ?


-> git remote rm origin

--> After doing some changes in the file what you have to do , No need to add the
origin the second time. when you are pushing.

1. git add .
2. git commit -m 'this is the second revision'
3. git push -u origin master

--------------> Creating branches in Git, when multiple people are working in the
same project we will divide the task and create branch for each people

1. command- git branch local_branch_int301


- git branch
2. git checkout local_branch_int301 (switch to that branch)

3. git commit -m 'this is the local branch'

4. git push -u origin local_branch_INT301

5. If you want to move back to the main branch


command- git checkout master

----> The changes that have been done in the branche isn't shown in the main branch

--> Now we are going to merge the branches to reflect the changes
-> (you will merge master with local_branch) then it will show the changes
1. git merge local_branch_301 -> do this in master now master have the changes
done in branch
2. git push -u origin master ( you have to do push again then only it will show
the chnages)

3. cat test.txt - shows the content in the bash terminal itself

------------------------> 6th March

1. GDB - Dry run the code ( debugging)

-------------> 13th March

--> Git clone


1. cd D:
2. mkdir git_clone_image
3. cd git_clone_image
4. pwd
5. git status

<------------------ steps for git revert ------------------->

---> Undo changes - we will do it to the directory that has already been intialized

1. checkout -- index.html - It is not trust worthy -> It doesn't work once we do


git commit
2. git revert <paste theat git commit id here - It needs an id -> from git log you
will get the id
Note- the first id is the one with the recent changes.

--> after adding do commit -> git push -u origin master ->
--> checkout only chnages locally but if you want to revert in github
--> git log --> to get the id
--> git revert paste commit id...
--> git add .
--> git commit -m 'modified''
--> git push -u origin master

<---------------------------------------------------------->

1. What is the difference between git pull and push?

2. How do you write the rename? --> rename a git hub file

---------------------> 13th March

1. GDB

You might also like