0% found this document useful (0 votes)
68 views109 pages

Linux Directory Management & Permissions

This document covers directory management and permissions in Linux, including working with hidden files, understanding permission types, and changing ownership. It explains how to view and modify permissions using both symbolic and numeric modes, as well as best practices for managing user access. Additionally, it introduces user management concepts, types of users, and process monitoring commands like ps and top.

Uploaded by

bhavyashany
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views109 pages

Linux Directory Management & Permissions

This document covers directory management and permissions in Linux, including working with hidden files, understanding permission types, and changing ownership. It explains how to view and modify permissions using both symbolic and numeric modes, as well as best practices for managing user access. Additionally, it introduces user management concepts, types of users, and process monitoring commands like ps and top.

Uploaded by

bhavyashany
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Session 22

Directory Management & Permissions

1
Objective

By the end of this session, you will be able to:


 Work with hidden files and directories.
 Understand directory-specific.
 Apply file and directory permissions using symbolic.
 Change ownership and groups of files and directories
 Differentiate file vs. directory permissions (execute bit
meaning in directories).

2
Hidden Directories and Files
Any file/dir starting with . is hidden (e.g., .config/, .ssh/).
 View with ls –a
 Create hidden directory: mkdir .myhidden
 Useful for configs, system settings

[Link]
3
Permissions in Linux

Linux employs a robust system for managing directories and


controlling access through permissions.
This system ensures data security and integrity by defining who can
perform specific actions on files and directories.

4
Access Types
Each file and directory in Linux has three fundamental permission types:

1. r -- Read:
 For files: Allows viewing the file's contents
 For directories: Allows listing the contents of the directory.

2. w – Write
 For files: Allows modifying or deleting the file.
 For directories: Allows creating, deleting, or renaming files within
the directory.

3. x -- Execute
 For files: Allows running the file as a program or script.
 For directories: Allows entering and navigating into the directory.

5
Permission Groups
These permissions are assigned to three distinct categories of users:
 Owner (u): The user who created the file or directory.
 Group (g): The group that the file or directory belongs to.
 Others (o): All other users on the system who are not the owner or
members of the assigned group.

[Link]
6
Viewing/Checking Permissions
The ls -l command displays detailed information about files and
directories, including their permissions.

The permission string, such as drwxr-xr-x, indicates the file type (d


for directory, - for file) and the read, write, and execute permissions
for the owner, group, and others, respectively.

[Link]
orials/an-introduction-to-linux-permissions
7
Viewing/Checking Permissions

[Link]
[Link]/linux-file-
permissions-groups-
and-users/

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 8
Numeric Permissions
Numerical permissions in Linux, also known as octal permissions,
offer a concise way to represent file and directory access rights for the
owner, group, and others. Each permission type (read, write, execute) is
assigned a specific numerical value:
 Read (r): 4
 Write (w): 2
 Execute (x): 1
These values are then summed to represent the desired permissions.
Each digit corresponds to the sum of the permission values for the
owner, group, and others, respectively.
Examples:
7 (rwx): Read (4) + Write (2) + Execute (1) = 7 (Full permissions)
6 (rw-): Read (4) + Write (2) = 6 (Read and write)
5 (r-x): Read (4) + Execute (1) = 5 (Read and execute)

9
Numeric Permissions

[Link]
orials/how-to-set-permissions-linux
Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 10
Changing Permissions
The chmod command is used to modify file and directory permissions.
It can be used in two primary modes:
1. Symbolic Mode:
Uses letters and symbols to add, remove, or set permissions.
 chmod u+x filename: Adds execute permission for the owner.
 chmod go-w directoryname: Removes write permission for the
group and others.
 chmod a=rwx filename: Sets read, write, and execute permissions
for all (owner, group, others).

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 11
Changing Permissions
2. Numeric (Octal) Mode:
Uses Octal Numbers to add, remove, or set permissions.
 chmod 755 directoryname: Gives owner read, write, execute
(4+2+1=7), and group/others read, execute (4+1=5).
 chmod 644 filename: Gives owner read, write (4+2=6), and
group/others read only (4).

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 12
Changing Ownership
chown: Changes the owner of a file or directory.
Syntax: chown newowner filename

Example: sudo chown rajesh [Link]

Note: This command requires root privileges or the use of sudo.

13
Changing Ownership
Changing the Group Owner:
To change only the group owner of a file, use a colon (:) before the
new group name, followed by the file name.

Example: sudo chown :newgroup [Link]

Changing Ownership Recursively (for Directories).


sudo chown -R newuser:newgroup /path/to/directory

[Link]
14
Example: Directory Permissions
 mkdir lab
 chmod 700 lab # only owner can access
 chmod 755 lab # owner full, others can read/enter
Best Practice:
 Never use chmod 777 unless necessary
 Use principle of least privilege
 Regularly check permissions with ls -l

15
Group exercise

 Create a folder testdir


 Inside it, create 2 files
 Restrict one file to owner-only (chmod 700)
 Allow everyone read-only access to the other file (chmod 744)
 Show difference

16
Test Your Knowledge

 What does chmod 755 [Link] mean?


 What’s the difference between rmdir and rm -r?
 What does the x permission mean for a directory?
 How do you change group ownership of a file?

17
Test Your Knowledge: Mini Quiz

Which of the following is a hidden directory in Linux?


A. Documents
B. B. .config
C. C. /home
D. D. Downloads
Answer: B. .config

18
Test Your Knowledge: Mini Quiz

What command will display hidden files and directories?


A. ls –h
B. ls –a
C. ls –hidden
D. ls --show-all
Answer: B. .config

19
Session 23
User Management Commands
Objective

By the end of this session, you will be able to:


 Understand the concept of users, groups, and their roles in
Linux.
 Create, modify, and delete user accounts.
 Manage user groups and memberships.
 Configure user information and default settings.
 Apply basic security by controlling user access.

21
Introduction to User Management
User management in Linux is a fundamental aspect of system
administration, enabling control over access to system resources and
maintaining.
Linux is a multi-user operating system.
Every user has:
 A username
 A User ID (UID)
 A home directory
 A default shell

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 22
Types of Users
Linux is a multi-user operating system, meaning multiple users can
access and operate the system simultaneously.
The following table provides an overview of user account types in
Linux, their access levels, and uses:
 Root User
 Standard User
 Sudo User
 System Account
 Guest User
 User Groups
23
Types of Users
1. Root User:
 Access to the entire Linux system.
 Root users can initiate any command, modify system settings, edit
files, or install software without restrictions.
 Primarily used to perform system administration tasks.
 The root account is identified by a special User ID (UID) of 0 in
the /etc/passwd file.
 Any user with a UID of 0 will inherently have root privileges.
 While the UID is the defining characteristic, the account is
conventionally named "root.“
 The root user's home directory is typically located at /root, distinct
from the root directory of the filesystem, which is simply /.

24
Types of Users

1. Standard User
 User privileges are limited.
 Standard users cannot perform actions that affect core system
settings or other user accounts.
 Basic access for utilizing various system resources.

25
Types of Users
3. Sudo User:
 A standard user who has been granted permissions to execute
certain commands as the root user.
 Every command that requires root privileges must be preceded
with the sudo command.
 Before using sudo, you need to ensure it is set up correctly.
 Typically, sudo is pre-installed on most Linux distributions. If it’s
not installed, you can install it using your package manager.

[Link]
unix/sudo-command-in-linux-with-examples/

26
Types of Users
4. System Account
 User accounts for applications or automated services that need to
perform specific tasks on the Linux system.
 System accounts operate with restricted permissions to enhance
security and control over system operations.

27
Types of Users
5. Guest User:
 Temporary accounts with restricted and controlled privileges.
 Users that need access for a limited time and do not require
personal files and settings.

6. User Groups
 Permissions are assigned to a collection of users who are
organized into logical groups with identical permissions.
 Admins can manage permissions for an entire user group instead
of managing individual user accounts.

28
A User ID (UID)
UID stands for User Identifier. It is a unique numerical value assigned to
each user account. The UID is used by the system to identify and
differentiate between different users. The uses of UID are,
 Determining user permissions and access levels
 Process management to associate running processes
 Each file and directory in Linux has an associated UID that identifies
its owner.
 UID is interconnected with Group Identifier (GID), which represents
a specific user group.

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 29
A User ID (UID)

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 30
A User ID (UID)

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 31
Delete User in Linux
To delete a user in Linux, use the userdel command followed by the
user's username.
Step 1: Log in to the Linux system using the root account or an
account with sudo privileges.
Step 2: To delete a user account, use the userdel command.

Deleting a group: sudo groupdel developers

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 32
Security & Best Practices

 Use least privilege principle (don’t give sudo unnecessarily).


 Regularly remove unused accounts.
 Use strong passwords & enforce policies.
 Monitor /etc/passwd and /etc/shadow.

33
Test Your Knowledge

Q1. Which file stores encrypted passwords?


 A. /etc/passwd
 B. /etc/shadow
 C. /etc/group
 D. /etc/sudoers

34
Test Your Knowledge

Q.2 Which command is used to create a new user in Linux?


 Addgroup
 b) adduser / useradd
 c) mkuser
 d) newuser

35
Test Your Knowledge: Mini Quiz

Q3. A user has been locked using passwd -l username. What happens if
they try to log in?
 They can log in but cannot run commands
 b) They cannot log in at all
 c) They can log in only as root
 d) They can log in only via SSHAnswer: B. .config

36
Test Your Knowledge: Mini Quiz

Q4. Which command shows the groups a user belongs to?


 a) whoami
 b) id
 c) groups
 d) Both b and c

Answer: d) Both b and c

37
Session 24
Process Monitoring: top, ps, kill

38
Objective

By the end of this session, you will be able to:


 Understand Linux process concepts
 Monitor running processes using ps and top
 Identify resource usage (CPU, memory, etc.)
 Manage processes with kill
 Perform hands-on process management

39
What is a Process?
A process = program in execution
Each process has:
 PID (Process ID)
 PPID (Parent PID)
 UID (User ID)

States: Running, Sleeping, Zombie, Stopped

 Process monitoring and management in Linux systems are facilitated


by commands such as top, ps, and kill
Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 40
Process Tree
Parent and Child relationship
Example:
$ ps -ef | head
$ pstree

init or systemd is the root of all processes

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 41
The ps Command
Lists running processes: In contrast to top's real-time display, ps
(process status) provides a static snapshot of the currently running
processes.

❑ Various options can be used with ps to customize the output, such as


ps aux to display all processes, including those not associated with a
terminal, along with user and CPU/memory usage details.

❑ Options:
 ps → current shell’s processes
 ps -e → all processes
 ps -ef → full details
 ps aux → BSD style, CPU/memory view

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 42
The ps Command
ps Output Fields:

 PID → Process ID
 TTY → Terminal used
 TIME → CPU time used
 CMD → Command name

[Link]
Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 43
The top Command
 This command provides a dynamic, real-time view of the running
processes:
 It displays system summary information, including uptime, load
average, and CPU/memory usage, alongside a list of processes sorted
by default based on CPU utilization.
 Users can interact with top to sort by other criteria (e.g., memory
usage using M) and even kill processes by pressing k and entering the
Process ID (PID).

Keys inside top:


 q → quitk → kill process
 h → help
 Shift + P → sort by CPU
 Shift + M → sort by memory

44
The top Command
Understanding top Output
 Load Average → system load over 1, 5, 15 mins
 Tasks → total, running, sleeping, zombie
 CPU% → user/system/idle time
 Memory Usage → used vs free

[Link]
command-in-linux-with-examples/

45
The kill Command
This command is used to terminate processes by sending signals to
them:
 The kill command requires the PID of the target process.

 By default, kill sends the SIGTERM (signal 15) which requests a


graceful termination.

 If a process is unresponsive to SIGTERM, SIGKILL (signal 9) can be


sent using kill -9 <PID> for a forceful termination.

 It is important to note that SIGKILL cannot be caught or ignored by a


process.
 Permissions are required to kill processes, and sudo may be necessary
for processes owned by other users or the system.

46
The kill Command
Common signals:
 SIGTERM (15) → request termination (default)
 SIGKILL (9) → force kill
 SIGHUP (1) → restart

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 47
Hands-On Demo
Tasks for Students:
 Use ps -ef to list all processes
 Run sleep 1000 & in background, find PID
 Use top to monitor it
 Kill process with kill
 Verify it is terminated with ps

48
Common Scenarios

 High CPU process hogging → find via top


 Zombie process → detect with ps
 Hanging application → kill with kill -9
 Process monitoring for debugging

49
Test Your Knowledge

Q1. Which command gives a real-time view of processes?


 Ps
 top
 kill

50
Test Your Knowledge

Q.2 What signal does kill send by default?


 a) SIGKILL
 b) SIGTERM
 c) SIGHUP

51
Test Your Knowledge: Mini Quiz

Q3. How do you kill all processes of a user?


 a) kill all -u username
 b) ps -u username
 c) kill -9 username

52
Session 25
Network Commands: ping, wget, curl

53
Objective

By the end of this session, you will be able to:


 Test connectivity using ping
 Download files and web content using wget
 Interact with web APIs using curl
 Differentiate use cases of ping, wget, and curl

54
Why Networking Commands?
The network commands ping, wget, and curl are fundamental tools
used for network diagnostics, data retrieval, and web interaction.

Why Networking Commands?


 Essential for troubleshooting
 Helps in downloading packages/files
 Used for testing APIs/web servers
 First step in system administration & DevOps

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 55
The ping Command
Purpose: Check network connectivity
Uses ICMP (Internet Control Message Protocol)
$ ping <hostname or IP>
Options:
 -c <count> → Limit number of pings
 -i <interval> → Set interval between pings
 -t (Windows) or -w <sec> (Linux) → Timeout

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 56
The ping Command
Example:
 ping [Link]
 ping -c 4 [Link]
 ping -i 2 [Link]
 ping -w 5 localhost

[Link]
Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 57
The wget Command (Theory)
Purpose: Download files from web servers
 The wget command is a free utility for non-interactive downloading
of files from the web. It supports HTTP, HTTPS, and FTP protocols,
as well as retrieval through HTTP proxies.
 It supports HTTP, HTTPS, and FTP protocols, as well as retrieval
through HTTP proxies.

Purpose:
 To download files from web servers or FTP servers.
 To recursively download entire websites for offline browsing.
 To resume interrupted downloads.

Syntax: wget [options] URL

58
The wget Command
Features:
 Resume downloads (-c)
 Quiet mode (-q)
 Save with a new name (-O filename)
 Download entire website (with recursion -r)

[Link]

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 59
The curl Command
The curl command is a versatile command-line tool for transferring data
with URLs. It supports a wide range of protocols, including HTTP,
HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP,
LDAPS, FILE, IMAP, SMTP, POP3, and more.

Purpose:

 To make various types of HTTP requests (GET, POST, PUT,


DELETE, etc.).
 To download or upload files using different protocols.
 To interact with APIs and web services.
 To test network connectivity and retrieve information from web
servers.

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 60
The curl Command
Features:

 Fetch webpage content


 Save output to file (-o)
 Follow redirects (-L)
 Send POST requests (-d)
 Add headers (-H)

[Link]
unix/curl-command-in-linux-with-examples/
Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 61
Comparison: ping vs wget vs curl

Comman
Use Case Protocol Output
d

Check network Latency/packe


ping ICMP
connectivity t loss

Download HTTP,
wget Files
files/websites HTTPS, FTP

Fetch & interact


curl Many Data/Text
with APIs

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 62
Hands-On Demo
Tasks for Students:
 Use ping to test connectivity with [Link]
 Download a file using wget
 Fetch a webpage using curl
 Try curl -I <URL> to fetch only headers

63
Best Practices

 Always test ping before troubleshooting higher-level issues


 Prefer wget for downloading files
 Use curl for APIs & testing server responses
 Combine with pipes (|) & grep for more control

64
Test Your Knowledge

Q1. Which command checks packet loss?


a) curl
b) ping
c) wget
d) ls

65
Test Your Knowledge

Q.2 Which option in wget resumes a download?


a) -r
b) –c
c) –q
d) -O

66
Test Your Knowledge

Q.3 Which curl option saves output to a file?


a) -o
b) –d
c) –L
d) -q

67
Summary

Q4. How do you kill all processes of a user?


 ping → Connectivity check
 wget → Download files
 curl → Fetch web data & interact with APIs
 Essential tools for network troubleshooting & automation

68
Session 26
Shell Scripting Basics: Writing Simple Bash Scripts

69
Objective

By the end of this session, you will be able to:


 Understand the role of shell scripting
 Write simple Bash scripts
 Use variables, input, and output in scripts
 Add conditional logic and loops
 Execute and debug basic scripts

70
What is a Shell Script?
Shell scripting is an important part of process automation in Linux.
Scripting helps you write a sequence of commands in a file and then
execute them.
Features
 A text file containing commands
 Executes commands sequentially
 Automates repetitive tasks
 Commonly uses Bash (Bourne Again Shell)

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 71
Writing Your First Script
Create a file with .sh extension → nano [Link]
Scripts start with a bash bang.
 Scripts are also identified with a shebang.
 Shebang is a combination of bash # and bang ! followed is the bash
shell path.
 This is the first line of the script. Shebang tells the shell to execute it
via bash shell. Shebang is simply an absolute path to the bash
interpreter.
 Example: #! /bin/bash

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 72
Writing Your First Script

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 73
Write the command in Script
First Script:
#! /usr/bin/bash
echo "Hello World"
 Provide execution rights to your user.
Modify the file permissions and allow execution of the script by using
the command below:
chmod u+x hello_world.sh
chmod modifies the existing rights of a file for a particular user. We are
adding +x to user u.

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 74
Run the script.
You can run the script in the following ways:
You can run the script in the following ways:
 ./hello_world.sh
 bash hello_world.sh.

[Link]
scripting-crash-course-how-to-write-bash-
scripts-in-linux/
Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 75
Variables and data types in Bash
Variables let you store data. You can use variables to read, access,
and manipulate data throughout your script.
 There are no data types in Bash. In Bash, a variable is capable of
storing numeric values, individual characters, or strings of characters.
 We can define a variable by using the syntax variable_name=value.
To get the value of the variable, add $ before the variable.

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 76
Arithmetic Expressions
Below are the operators supported by bash for mathematical
calculations:
Numerical expressions can also be calculated and stored in a variable
using the syntax below:
var=$((expression))
Oper Usage
+ addition
- subtraction
* multiplication
/ division
** exponentiation
% modulus

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 77
How to read user input
In bash, we can take user input using the read command.
read variable_name
To prompt the user with a custom message, use the -p flag.
read -p "Enter your age" variable_name

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 78
Numeric Comparison logical operators

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 79
Numeric Comparison logical operators
Example:
Let's compare two numbers and find their relationship:

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 80
Conditional Statements (if)

if [[ condition ]]
then
statement
elif [[ condition ]]; then
statement
else
do this by default
fi

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 81
Looping and skipping
Looping in shell scripts allows for the repeated execution of a block of
commands until a certain condition is met or for a specified number of
iterations.

The primary types of loops available in shell scripting are:


for loop:
 Iterating over a list of items: This is useful for processing files,
arguments, or elements in an array.

While loop:
 Executes commands as long as a condition is true: Ideal for scenarios
where the number of iterations is unknown beforehand.

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 82
While loop

#!/bin/bash
i=1
while [[ $i -le 10 ]] ; do
echo "$i"
(( i += 1 ))
done

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 83
for loop

#!/bin/bash

for i in {1..5}
do
echo $i
Done

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 84
Useful Script Examples
Backup Script:
cp [Link] backup_file.txt
echo "Backup completed!“

System Info Script:


echo "Today's Date: $(date)"
echo "Logged in User: $USER"
echo "Current Directory: $(pwd)“

Debugging Scripts:
bash -x [Link]

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 85
Hands-On Demo

Write a script that:


 Greets the user with their name.
 Asks for a number and checks if it’s even/odd.
 Prints numbers 1–5 in a loop.

86
Best Practices

 Always use #!/bin/bash


 Comment your code (# This is a comment)
 Use meaningful variable names
 Test scripts before production use

87
Test Your Knowledge

Q1. Which symbol is used to store the output of a command into a


variable in Bash?
A) $()
B) #()
C) @@
D) []

Answer: A) $()

88
Test Your Knowledge

Q.2 Which line should always be included at the top of a Bash script to
specify the interpreter?
A) #!/bin/python
B) #!/bin/bash
C) #bash
D) bash start

Answer: B) #!/bin/bash

89
Test Your Knowledge

Q.3 If you make a script [Link] executable using chmod +x


[Link], how can you run it?
A) run [Link]
B) sh [Link]
C) ./[Link]
D) exec [Link]

Answer: C) ./[Link]

90
Summary

 Shell scripts automate tasks


 Scripts need chmod +x before running
 Variables, input, conditionals, and loops are core concepts
 Debug with bash -x

91
Session 27
Open-Source Philosophy & Licensing

92
Objective

By the end of this session, you will be able to:


 Understand the philosophy behind open-source software
 Learn key differences between open-source and
proprietary models
 Explore major open-source licenses (GPL, MIT, Apache,
etc.)
 Analyze why licensing matters in software development

93
What is Open Source?
Open-source philosophy is a collaborative development model where
users have access to source code to study, modify, and distribute,
fostering transparency and community-driven innovation.
Open-source licenses, defined by entities like:
 Open-Source Initiative (OSI) and
 based on the Open-Source Definition (OSD),Automates repetitive
tasks
 serve as legal frameworks that grant these freedoms while often
imposing conditions,

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 94
Open-Source vs Proprietary Software

Feature Open Source Proprietary

Source Code Access Yes No

Cost Usually free Paid/licensed


Customization Flexible Restricted
Support Community-driven Vendor-driven

Linux, MySQL, Windows, Oracle


Examples
LibreOffice DB, MS Office

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 95
Philosophy of Open Source
Freedom to use (no restrictions on usage)
Freedom to study & modify (learn & improve code)
Freedom to share (collaboration & distribution)
Freedom to improve & contribute (innovation through community)

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 96
Philosophy of Open Source

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 97
Open-Source Licenses

[Link]
507/open-source-presentation
Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 98
Major Open-Source Licenses
GNU General Public License (GPL)
Strong "copyleft" → modifications must also be open source
MIT License
Very permissive, minimal restrictions
Apache License 2.0
Allows commercial use, explicit patent rights
BSD License
Flexible, fewer restrictions, similar to MIT

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 99
Major Open-Source Licenses

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 100
Major Open-Source Licenses

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 101
Copyleft vs Permissive Licenses
Copyleft (e.g., GPL):
Derivative works must remain open-source
Permissive (e.g., MIT, Apache):
Derivatives can be closed-source

[Link]
Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 102
Why Licensing Matters

 Protects authors’ rights


 Prevents unauthorized usage
 Ensures compliance in commercial use
 Encourages fair collaboration

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 103
Real-World Examples

 Linux (GPL) → Free OS, powers most servers


 Android (Apache 2.0) → Open but allows vendor
modifications
 Python (PSF License) → Used in academia & industry
 MySQL (GPL + commercial) → Dual-licensing model

Mr. Rajesh Kumar, Dr. Surbhi Computer Science Fundamentals and Pathways 104
Hands-On Demo

Ask students to:


 Visit GitHub project of their choice
 Identify which license it uses (MIT, GPL, Apache, etc.)
 Discuss in class why the project might have chosen that
license

105
Test Your Knowledge

Q1. Which license enforces “copyleft”?


A) MIT
B) GPL
C) Apache
D) BSD
Answer: B) GPL

106
Test Your Knowledge

MIT License is best described as:


A) Restrictive
B) Copyleft
C) Permissive
D) Proprietary
Answer: C) Permissive

107
Test Your Knowledge

Android is primarily licensed under:


•A) GPL
•B) Apache License 2.0
•C) BSD
•D) MIT
✅ Answer: B) Apache License 2.0

108
Summary

 Open source promotes freedom & collaboration


 Licenses ensure legal clarity
 Understanding licenses = essential skill for developers

109

You might also like