0% found this document useful (0 votes)
77 views38 pages

Workshop On Free/Open Source Software

The document provides an overview of a workshop on free and open source software (FOSS) and Linux. It discusses why FOSS is used, who uses it, principles of FOSS development like releasing early and often and reusing components. It also covers Linux boot sequence, file systems like ext2/3/4 and FAT, and shell scripting basics.

Uploaded by

techie2go1968
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views38 pages

Workshop On Free/Open Source Software

The document provides an overview of a workshop on free and open source software (FOSS) and Linux. It discusses why FOSS is used, who uses it, principles of FOSS development like releasing early and often and reusing components. It also covers Linux boot sequence, file systems like ext2/3/4 and FAT, and shell scripting basics.

Uploaded by

techie2go1968
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
You are on page 1/ 38

Welcome

Workshop on Free/Open Source Software


We are Linux
Introduction to FOSS

● Introduction to FOSS/Linux
● An overview of Development Tools in Linux
● Introduction to Using Command Line & Shell
Scripting
● An introduction to Scripting Languages
● (Optional) Hands On
Introduction to FOSS

● Why F/OSS?
● Who Uses F/OSS?
Why F/OSS

● Freedom to Use For any Purpose


● Freedom to Look under the hood
● Freedom to Modify
● Freedom To Distribute
● Freedom to Profit
● Security & Reliability
● Believe it or not, it runs our life.
F/OSS Development

● Release Early, Release Often


● Reuse Existing Components
● Better Quality Control
● Less Total Cost of Ownership
Release Early, Release Often

● Incremental features do not wait for Years


● Quick feedback of any, even small
modifications
● Incremental Bug Fixing
Reuse Existing Components

● Open License Promotes Sharing code and


Ideas
● Do not reinvent the wheel
● Multiple point of testing, so fewer bugs
Less TCO

● For an Individual
– No Upfront Cost of Operating System
– (Mostly) all Applications Available with Linux
are F/OSS
– (in General) Very Secure, so Less Money,
Time and effort needed
– Good Support for Old Hardware
Choice

● Why do we need choice?


● What choices are available for F/OSS
– Operating System
● Active distributions : 312 (distrowatch)
– Applications
● Office, Entertainment, Graphics
– Development
● Editors, IDE, SDKs
Success Stories

● All Startup Companies


● All Large Enterprises
● Google, Yahoo, Facebook
● Your Computer Lab
● Your Operating Systems Handbook
Linux Boot Sequence

512 Bytes
Boot Loaders

● Lilo
● Grub
● Uboot (Embedded Systems)
– Boot monitors (acts both as 1st and 2nd Stage)
– Also can download kernel to the target
– Performs error checking and initialization
● Dissecting MBR
– # dd if=/dev/hda of=mbr.bin bs=512 count=1
– # od -xa mbr.bin
Anatomy Of BootLoader

Stage 2 Bootloader loaded


from active partition
Kernel

● Compressed image
● At the head a small program that Performs
some minimal hardware setup
– (./arch/i386/boot/head.S)
● Loads kernel and ramdisk to memory and
decompress the kernel
– [ decompress_kernel (located in
./arch/i386/boot/compressed/misc.c) ]
● yet another startup_32 function,
– but this function is in ./arch/i386/kernel/head.S.
Kernel Start
Partition Table

● Can contain only 4 partitions


● Extended partitions
● FileSystem Types
– FAT/NTFS
– Ext
– JFS/XFS/ZFS/ReiserFS
– More at http://tldp.org/HOWTO/Filesystems-
HOWTO.html
Food for thought

● What is journaling?
● Rationale
– Optimizations
● Physical
● Logical
FileSystems

● What?
– Blocksize
● Ext2/3/4
● FAT/NTFS
ext2
BLOCK BLOCK GROUPS
Decided when FS is Created 1,2,3,4,8K size Cluster of Blocks To reduce Fragmentation
Smaller blocks, less wastage of space Stored immediately after Super Blocks
but more accounting overhead First 2 Blocks reserved for bitmap and
Inode Information, size of bitmap=1block
Size, And next comes inode data, and
then data

Super Block Inodes & bitmaps?


Information about FS Configuration, Inode contains links to data block,
first stored in 1024bytes offset, and other Information other than name.
And then in the beginning of all blockgroups Has pointer to 12 Blocks of data, and
(later revised), also stores information about another pointer to indirect block (which in
Inodes, blocks, free inodes etc.. turn contains address of other Blocks),
And and doubly indirect blocks(?)
What is Bitmap?

● A bitmap is simply an array of bits, with the


Nth bit indicating whether the Nth block is
allocated or free
● Advantages
– Simple
● Disadvantages
– Scalable?
– 4B block, 1GB FS => 32KB Bitmap, 1TB=>?,
1PB=>?
Ext2 diagram
Ext3

● Journaling
– Writeback mode
● No journaling of data, only meta-data
– Ordered mode
● Logically groups meta-data and and data-
blocks as a single group of transaction, on
write data-blocks are written first
– Journal mode
● Slowest to write, replay of journal
● Fastest to read
Ext4

● Delayed allocation and more...


FAT File Systems

struct directory { // Short 8.3 names


unsigned char name[8]; // file name
unsigned char ext[3]; // file extension
unsigned char attr; // attribute byte
unsigned char lcase; // Case for base and extension
unsigned char ctime_ms; // Creation time, milliseconds
unsigned char ctime[2]; // Creation time
unsigned char cdate[2]; // Creation date
unsigned char adate[2]; // Last access date
unsigned char reserved[2]; // reserved values (ignored)
unsigned char time[2]; // time stamp
unsigned char date[2]; // date stamp
unsigned char start[2]; // starting cluster number
unsigned char size[4]; // size of the file
};
Filesystem Hierarchy Standard
● A Standard for Unix Like Operating Systems
– /
● /bin : Essential user command binaries (for use by all users)
● /boot : Static files of the boot loader
● /dev : Device files
● /etc : Host-specific system configuration
● /home : User home directories (optional)
● /lib : Essential shared libraries and kernel modules
● /media : Mount point for removeable media
● /mnt : Mount point for a temporarily mounted filesystem
● /root : Home directory for the root user (optional)
● /sbin : System binaries
● /srv : Data for services provided by this system
● /tmp : Temporary files
Shell Scripting

● Commands as steps
● Variables
● Variable interpolation
● Loops and Conditions
● Shebang line
● Script permissions
● Sed
● AWK
● Grep
● Find
globbing
● filename matching, doesn't match /
● man glob
● uses special characters such as * and ?
– * == any or no characters
– n* == any filename starting with an n followed
by 0 or more other characters
– ? == any single character
● ls /tmp/intermediate_bash/?on.txt
– note that on.txt is not matched
regular expressions

● uses special characters such as *, . ,+, ?, |


● globbing evaluated by shell before regex gets
evaluated
● regex are used by tools such as grep and sed
● use quotes to protect regex pattern
● two types of regular expressions
– extended
– basic
● extended/modern
– * == 0 or more of the preceding character
– + == one or more of the preceding character
– ? == zero or one of the preceding character
● basic/obsolete
– +, ?, | are not special characters
– need to escape characters such as { and
( to use them as special characters
arrays
– ${array[0]}
– must use curly brackets when specifying the variable
– 0 is the first element of an array,but not all elements have to have
values
– assigning an element deletes the old element content or creates
the element
– compound assignments wipe out previous array contents
– ${array[*]} lists all elements of the array as a single value
– ${array[@]} lists all elements of the array as seperate values
– ${#array[$i]} is the length of the value assigned to element $i
– ${#array[@]} gives the number of items in the array
– ${!array[@]} lists the indexes that have values
shell math

● use let or arithmetic evaluation syntax


– let j="i + 4"; echo $j
– j=$(( i + 4 )); echo $j
● they don't need the $ to denote a variable, but
let needs quotes to use spaces or special
characters
– for i in {1..4}; do j=$(( j + i )); done; echo $j
command substitution

– $( echo pwd )
● don't use backticks unless you need /bin/sh
compatability
– `echo pwd`
● $() syntax allows nesting, fixes quoting issues
– j=$( ls -d $( pwd ) ); echo $j
Proc FileSystem

● Mounted on /proc
– proc on /proc type proc (rw)
– /proc/cpuinfo
● Gives CPU Info
– /proc/meminfo
● Gives Memory Info
– /proc/uptime
● Individual Numbered directories are for
processes
Inside process directory

● Cmdline
– The command with which this process was
started
● Status
– Name of the program, status, Virtual Memory
size, threads etc..
● More at
– http://www.redhat.com/docs/manuals/linux/RH
L-7.2-Manual/ref-guide/ch-proc.html
Exercises

● List top 10 directories (in terms of size in


/home folder)
– Hint
● Du -hs gives the total size occupied by the
folder
● Find all xml files in a given directory and
change all occurance of “<name>...</name>”
to “<firstname>...</firstname>”
– Hint
● find and then -exec sed
Project

● A system monitor/Task Manager


– Hints
● /proc
– Assume
● Only 15 processes

You might also like