Techbuddy: Introduction to Linux session

114
Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses Introduction to Linux by Ashish Bhatia TechBuddy Consulting Pvt. Ltd. 19-21 June 2010 Ashish Bhatia Introduction to Linux
  • date post

    18-Oct-2014
  • Category

    Technology

  • view

    450
  • download

    1

description

A talk I gave at Techbuddy session in 2010 in Noida to a group of students.

Transcript of Techbuddy: Introduction to Linux session

Page 1: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Introduction to Linux

by Ashish Bhatia

TechBuddy Consulting Pvt. Ltd.

19-21 June 2010

Ashish Bhatia Introduction to Linux

Page 2: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Why learn Linux?

Ashish Bhatia Introduction to Linux

Page 3: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

What is OS?

What is OS?

1 BIOS - Boot Loader - OS

2 Hardware - OS - Application Software - User

3 multi-user?

4 multi-tasking?

Ashish Bhatia Introduction to Linux

Page 4: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

History of GNU/Linux

based on ideas from UNIX (originated in 1969 at AT&T)

created by Linus Torvalds in 1991

General Public License

GPL

distribution of source code with binary is mustmore details later

Ashish Bhatia Introduction to Linux

Page 5: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Files and Processes

A running program is a process

it has unique process identifier (PID)

Everything else is file

even devices like mouse, keyboard etc.every file has a unique inode number in Linux

Ashish Bhatia Introduction to Linux

Page 6: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

Unlike windows(except recent versions) where data storage ispartitioned into various drives

In Linux all (accessible) data is under /

Ashish Bhatia Introduction to Linux

Page 7: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 8: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 9: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 10: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 11: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 12: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 13: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 14: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 15: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

File Hierarchy

/ The ancestor of all directories on the system

/bin Essential tools and other programs (or binaries)

/dev Files representing the system’s various hardware devices(eg. /dev/dvd)

/etc Misc system configuration files, startup files (eg./etc/networking)

/home The home dir for all of the system’s users

/proc Files that give information about current systemprocesses

/root superuser’s home directory, whose username is root

/tmp Temp files

/usr Subdir with files related to user tools and applications

Ashish Bhatia Introduction to Linux

Page 16: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Linux Alternative for Windows

Internet Explorer = Firefox

Outlook Express = Thunderbird

Google Talk = Pidgin (and Skype)

media player = amarok

Microsoft Office = Open Office

Notepad = kate,vim

A more comprehensive list athttp://wiki.linuxquestions.org/wiki/Linux software equivalent to Windows software

Ashish Bhatia Introduction to Linux

Page 17: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Linux Alternative for Windows

Internet Explorer = Firefox

Outlook Express = Thunderbird

Google Talk = Pidgin (and Skype)

media player = amarok

Microsoft Office = Open Office

Notepad = kate,vim

A more comprehensive list athttp://wiki.linuxquestions.org/wiki/Linux software equivalent to Windows software

Ashish Bhatia Introduction to Linux

Page 18: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Linux Alternative for Windows

Internet Explorer = Firefox

Outlook Express = Thunderbird

Google Talk = Pidgin (and Skype)

media player = amarok

Microsoft Office = Open Office

Notepad = kate,vim

A more comprehensive list athttp://wiki.linuxquestions.org/wiki/Linux software equivalent to Windows software

Ashish Bhatia Introduction to Linux

Page 19: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Linux Alternative for Windows

Internet Explorer = Firefox

Outlook Express = Thunderbird

Google Talk = Pidgin (and Skype)

media player = amarok

Microsoft Office = Open Office

Notepad = kate,vim

A more comprehensive list athttp://wiki.linuxquestions.org/wiki/Linux software equivalent to Windows software

Ashish Bhatia Introduction to Linux

Page 20: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Linux Alternative for Windows

Internet Explorer = Firefox

Outlook Express = Thunderbird

Google Talk = Pidgin (and Skype)

media player = amarok

Microsoft Office = Open Office

Notepad = kate,vim

A more comprehensive list athttp://wiki.linuxquestions.org/wiki/Linux software equivalent to Windows software

Ashish Bhatia Introduction to Linux

Page 21: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Linux Alternative for Windows

Internet Explorer = Firefox

Outlook Express = Thunderbird

Google Talk = Pidgin (and Skype)

media player = amarok

Microsoft Office = Open Office

Notepad = kate,vim

A more comprehensive list athttp://wiki.linuxquestions.org/wiki/Linux software equivalent to Windows software

Ashish Bhatia Introduction to Linux

Page 22: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Linux Alternative for Windows

Internet Explorer = Firefox

Outlook Express = Thunderbird

Google Talk = Pidgin (and Skype)

media player = amarok

Microsoft Office = Open Office

Notepad = kate,vim

A more comprehensive list athttp://wiki.linuxquestions.org/wiki/Linux software equivalent to Windows software

Ashish Bhatia Introduction to Linux

Page 23: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

What is a user

A user represents a real-world entity and it has

username (and user ID)

group (and group ID)

Password

Home Dir

Default Shell

User Details

Ashish Bhatia Introduction to Linux

Page 24: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

What is a user

A user represents a real-world entity and it has

username (and user ID)

group (and group ID)

Password

Home Dir

Default Shell

User Details

Ashish Bhatia Introduction to Linux

Page 25: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

What is a user

A user represents a real-world entity and it has

username (and user ID)

group (and group ID)

Password

Home Dir

Default Shell

User Details

Ashish Bhatia Introduction to Linux

Page 26: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

What is a user

A user represents a real-world entity and it has

username (and user ID)

group (and group ID)

Password

Home Dir

Default Shell

User Details

Ashish Bhatia Introduction to Linux

Page 27: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

What is a user

A user represents a real-world entity and it has

username (and user ID)

group (and group ID)

Password

Home Dir

Default Shell

User Details

Ashish Bhatia Introduction to Linux

Page 28: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

What is a user

A user represents a real-world entity and it has

username (and user ID)

group (and group ID)

Password

Home Dir

Default Shell

User Details

Ashish Bhatia Introduction to Linux

Page 29: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Processes

GNU/Linux is a multi-user OS

Everything is a file or a process

Each process must specify which user is the owner

No one except owner has right to access that process*

what about files?

Ashish Bhatia Introduction to Linux

Page 30: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Processes

GNU/Linux is a multi-user OS

Everything is a file or a process

Each process must specify which user is the owner

No one except owner has right to access that process*

what about files?

Ashish Bhatia Introduction to Linux

Page 31: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Processes

GNU/Linux is a multi-user OS

Everything is a file or a process

Each process must specify which user is the owner

No one except owner has right to access that process*

what about files?

Ashish Bhatia Introduction to Linux

Page 32: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Processes

GNU/Linux is a multi-user OS

Everything is a file or a process

Each process must specify which user is the owner

No one except owner has right to access that process*

what about files?

Ashish Bhatia Introduction to Linux

Page 33: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Processes

GNU/Linux is a multi-user OS

Everything is a file or a process

Each process must specify which user is the owner

No one except owner has right to access that process*

what about files?

Ashish Bhatia Introduction to Linux

Page 34: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

Each file has three (boolean) permissions

Read(r)Write(w)Execute(x)

All users can be grouped into

Owner(u)Group (members) (g)Others (o)

9 bitsr w x r w x r w x

Super-user bypasses file permissions

Ashish Bhatia Introduction to Linux

Page 35: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

Each file has three (boolean) permissions

Read(r)Write(w)Execute(x)

All users can be grouped into

Owner(u)Group (members) (g)Others (o)

9 bitsr w x r w x r w x

Super-user bypasses file permissions

Ashish Bhatia Introduction to Linux

Page 36: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

Each file has three (boolean) permissions

Read(r)Write(w)Execute(x)

All users can be grouped into

Owner(u)Group (members) (g)Others (o)

9 bitsr w x r w x r w x

Super-user bypasses file permissions

Ashish Bhatia Introduction to Linux

Page 37: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

Each file has three (boolean) permissions

Read(r)Write(w)Execute(x)

All users can be grouped into

Owner(u)Group (members) (g)Others (o)

9 bitsr w x r w x r w x

Super-user bypasses file permissions

Ashish Bhatia Introduction to Linux

Page 38: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

A few examples

chmod 600 file1

chmod 400 file2

chmod 711 file3

chmod 644 file4

chmod -R 644 dir1

Ashish Bhatia Introduction to Linux

Page 39: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

A few examples

chmod 600 file1

chmod 400 file2

chmod 711 file3

chmod 644 file4

chmod -R 644 dir1

Ashish Bhatia Introduction to Linux

Page 40: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

A few examples

chmod 600 file1

chmod 400 file2

chmod 711 file3

chmod 644 file4

chmod -R 644 dir1

Ashish Bhatia Introduction to Linux

Page 41: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

A few examples

chmod 600 file1

chmod 400 file2

chmod 711 file3

chmod 644 file4

chmod -R 644 dir1

Ashish Bhatia Introduction to Linux

Page 42: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

A few examples

chmod 600 file1

chmod 400 file2

chmod 711 file3

chmod 644 file4

chmod -R 644 dir1

Ashish Bhatia Introduction to Linux

Page 43: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

File Permissions on Dir

Execute permission is required for a user to cd into a directory

Execute-only permission allows a user to access the files in adirectory as long as the user knows the names of the files inthe directory(and the user is allowed to read the files)

Execute+Read permission is required to view files containedin dir (eg. ls)

Execute+Read+Write permission allows the user to create,delete, or modify any files or subdirectories(even if the file orsubdirectory is owned by another user)

Ashish Bhatia Introduction to Linux

Page 44: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

File Permissions on Dir

Execute permission is required for a user to cd into a directory

Execute-only permission allows a user to access the files in adirectory as long as the user knows the names of the files inthe directory(and the user is allowed to read the files)

Execute+Read permission is required to view files containedin dir (eg. ls)

Execute+Read+Write permission allows the user to create,delete, or modify any files or subdirectories(even if the file orsubdirectory is owned by another user)

Ashish Bhatia Introduction to Linux

Page 45: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

File Permissions on Dir

Execute permission is required for a user to cd into a directory

Execute-only permission allows a user to access the files in adirectory as long as the user knows the names of the files inthe directory(and the user is allowed to read the files)

Execute+Read permission is required to view files containedin dir (eg. ls)

Execute+Read+Write permission allows the user to create,delete, or modify any files or subdirectories(even if the file orsubdirectory is owned by another user)

Ashish Bhatia Introduction to Linux

Page 46: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

File Permissions on Dir

Execute permission is required for a user to cd into a directory

Execute-only permission allows a user to access the files in adirectory as long as the user knows the names of the files inthe directory(and the user is allowed to read the files)

Execute+Read permission is required to view files containedin dir (eg. ls)

Execute+Read+Write permission allows the user to create,delete, or modify any files or subdirectories(even if the file orsubdirectory is owned by another user)

Ashish Bhatia Introduction to Linux

Page 47: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

Something More

SetUID(u+s)

SetGID(g+s)

Sticky Bit(t)

Ashish Bhatia Introduction to Linux

Page 48: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

Something More

SetUID(u+s)

SetGID(g+s)

Sticky Bit(t)

Ashish Bhatia Introduction to Linux

Page 49: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

Something More

SetUID(u+s)

SetGID(g+s)

Sticky Bit(t)

Ashish Bhatia Introduction to Linux

Page 50: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Users and Files

Something More

SetUID(u+s)

SetGID(g+s)

Sticky Bit(t)

Ashish Bhatia Introduction to Linux

Page 51: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Is Linux (really) secure?

Security of system or data?

1 Security by design

designed for connectivity and securityusers do not login into admin account (by default)users do not install packages from unverified sourcessome distros require admin account even for connecting usb

2 intelligent users

3 Smaller market to target for attackers

Ashish Bhatia Introduction to Linux

Page 52: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Is Linux (really) secure?

Security of system or data?1 Security by design

designed for connectivity and securityusers do not login into admin account (by default)users do not install packages from unverified sourcessome distros require admin account even for connecting usb

2 intelligent users

3 Smaller market to target for attackers

Ashish Bhatia Introduction to Linux

Page 53: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Is Linux (really) secure?

Security of system or data?1 Security by design

designed for connectivity and securityusers do not login into admin account (by default)users do not install packages from unverified sourcessome distros require admin account even for connecting usb

2 intelligent users

3 Smaller market to target for attackers

Ashish Bhatia Introduction to Linux

Page 54: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Is Linux (really) secure?

Security of system or data?1 Security by design

designed for connectivity and securityusers do not login into admin account (by default)users do not install packages from unverified sourcessome distros require admin account even for connecting usb

2 intelligent users

3 Smaller market to target for attackers

Ashish Bhatia Introduction to Linux

Page 55: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Shell

provides the traditional user interface for the Unix operatingsystem and for Unix-like systems

Some popular shells

bash

ksh

csh

Unless mentioned all slides assume bash

Ashish Bhatia Introduction to Linux

Page 56: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Shell

provides the traditional user interface for the Unix operatingsystem and for Unix-like systemsSome popular shells

bash

ksh

csh

Unless mentioned all slides assume bash

Ashish Bhatia Introduction to Linux

Page 57: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Process in Linux

Main Attributes

uid - user with whose permissions process executes

pid - process id

ppid - parent process id

terminal - to which process is attached

Ashish Bhatia Introduction to Linux

Page 58: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Process in Linux

Main Attributes

uid - user with whose permissions process executes

pid - process id

ppid - parent process id

terminal - to which process is attached

Ashish Bhatia Introduction to Linux

Page 59: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Process in Linux

Main Attributes

uid - user with whose permissions process executes

pid - process id

ppid - parent process id

terminal - to which process is attached

Ashish Bhatia Introduction to Linux

Page 60: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Process in Linux

Main Attributes

uid - user with whose permissions process executes

pid - process id

ppid - parent process id

terminal - to which process is attached

Ashish Bhatia Introduction to Linux

Page 61: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Standard I/O

Every process has access to three (standard) files

stdin (usually keyboard) - 0

stdout (usually monitor) - 1

stderr (usually monitor) - 2

Ashish Bhatia Introduction to Linux

Page 62: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Standard I/O

Every process has access to three (standard) files

stdin (usually keyboard) - 0

stdout (usually monitor) - 1

stderr (usually monitor) - 2

Ashish Bhatia Introduction to Linux

Page 63: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Standard I/O

Every process has access to three (standard) files

stdin (usually keyboard) - 0

stdout (usually monitor) - 1

stderr (usually monitor) - 2

Ashish Bhatia Introduction to Linux

Page 64: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

I/O Redirection

Standard I/O of the process can be redirected to other file(s)

cmd >filename

redirects output from stdout to filenameoriginal contents of file are overwrittenuse >>to append the output to original content

cmd 2>filename

redirects output from stderr to filenameoriginal contents of file are overwrittenuse >>to append the output to original content

cmd <filename

redirects input from stdin to filename

use /dev/null as output file to discard the output

Ashish Bhatia Introduction to Linux

Page 65: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

I/O Redirection

Standard I/O of the process can be redirected to other file(s)

cmd >filename

redirects output from stdout to filenameoriginal contents of file are overwrittenuse >>to append the output to original content

cmd 2>filename

redirects output from stderr to filenameoriginal contents of file are overwrittenuse >>to append the output to original content

cmd <filename

redirects input from stdin to filename

use /dev/null as output file to discard the output

Ashish Bhatia Introduction to Linux

Page 66: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

I/O Redirection

Standard I/O of the process can be redirected to other file(s)

cmd >filename

redirects output from stdout to filenameoriginal contents of file are overwrittenuse >>to append the output to original content

cmd 2>filename

redirects output from stderr to filenameoriginal contents of file are overwrittenuse >>to append the output to original content

cmd <filename

redirects input from stdin to filename

use /dev/null as output file to discard the output

Ashish Bhatia Introduction to Linux

Page 67: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

I/O Redirection

Standard I/O of the process can be redirected to other file(s)

cmd >filename

redirects output from stdout to filenameoriginal contents of file are overwrittenuse >>to append the output to original content

cmd 2>filename

redirects output from stderr to filenameoriginal contents of file are overwrittenuse >>to append the output to original content

cmd <filename

redirects input from stdin to filename

use /dev/null as output file to discard the output

Ashish Bhatia Introduction to Linux

Page 68: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(sequentially)

What are the possible cases?

cmd1 ; cmd2

cmd2 is executed after completion of cmd1

cmd1 && cmd2

cmd2 is executed after successful completion of cmd1eg. rm abc && mkdir abccreates directory abc only if abc file is deleted successfully

cmd1 || cmd2

cmd2 is executed on un-successful completion of cmd1

cmd1 | cmd2

cmd2 is executed on successful completion of cmd1 and takesoutput of cmd1 as its input

Ashish Bhatia Introduction to Linux

Page 69: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(sequentially)

What are the possible cases?

cmd1 ; cmd2

cmd2 is executed after completion of cmd1

cmd1 && cmd2

cmd2 is executed after successful completion of cmd1eg. rm abc && mkdir abccreates directory abc only if abc file is deleted successfully

cmd1 || cmd2

cmd2 is executed on un-successful completion of cmd1

cmd1 | cmd2

cmd2 is executed on successful completion of cmd1 and takesoutput of cmd1 as its input

Ashish Bhatia Introduction to Linux

Page 70: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(sequentially)

What are the possible cases?

cmd1 ; cmd2

cmd2 is executed after completion of cmd1

cmd1 && cmd2

cmd2 is executed after successful completion of cmd1eg. rm abc && mkdir abccreates directory abc only if abc file is deleted successfully

cmd1 || cmd2

cmd2 is executed on un-successful completion of cmd1

cmd1 | cmd2

cmd2 is executed on successful completion of cmd1 and takesoutput of cmd1 as its input

Ashish Bhatia Introduction to Linux

Page 71: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(sequentially)

What are the possible cases?

cmd1 ; cmd2

cmd2 is executed after completion of cmd1

cmd1 && cmd2

cmd2 is executed after successful completion of cmd1eg. rm abc && mkdir abccreates directory abc only if abc file is deleted successfully

cmd1 || cmd2

cmd2 is executed on un-successful completion of cmd1

cmd1 | cmd2

cmd2 is executed on successful completion of cmd1 and takesoutput of cmd1 as its input

Ashish Bhatia Introduction to Linux

Page 72: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(sequentially)

What are the possible cases?

cmd1 ; cmd2

cmd2 is executed after completion of cmd1

cmd1 && cmd2

cmd2 is executed after successful completion of cmd1eg. rm abc && mkdir abccreates directory abc only if abc file is deleted successfully

cmd1 || cmd2

cmd2 is executed on un-successful completion of cmd1

cmd1 | cmd2

cmd2 is executed on successful completion of cmd1 and takesoutput of cmd1 as its input

Ashish Bhatia Introduction to Linux

Page 73: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

what is background mode?

start process in background mode directly

using & at the end of command

start process normally (foreground)

press z (stops the process)execute bg (to start most recently stopped process inbackground mode)

Ashish Bhatia Introduction to Linux

Page 74: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

what is background mode?

start process in background mode directly

using & at the end of command

start process normally (foreground)

press z (stops the process)execute bg (to start most recently stopped process inbackground mode)

Ashish Bhatia Introduction to Linux

Page 75: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

what is background mode?

start process in background mode directly

using & at the end of command

start process normally (foreground)

press z (stops the process)execute bg (to start most recently stopped process inbackground mode)

Ashish Bhatia Introduction to Linux

Page 76: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

Handling processes running in background

jobs - print currently pending (running + stopped) jobs

kill %1 - kills job corresponding to number 1 in the jobsoutput

fg - brings a background process back to foreground

Ashish Bhatia Introduction to Linux

Page 77: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

Handling processes running in background

jobs - print currently pending (running + stopped) jobs

kill %1 - kills job corresponding to number 1 in the jobsoutput

fg - brings a background process back to foreground

Ashish Bhatia Introduction to Linux

Page 78: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

Handling processes running in background

jobs - print currently pending (running + stopped) jobs

kill %1 - kills job corresponding to number 1 in the jobsoutput

fg - brings a background process back to foreground

Ashish Bhatia Introduction to Linux

Page 79: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

Handling processes running in background

jobs - print currently pending (running + stopped) jobs

kill %1 - kills job corresponding to number 1 in the jobsoutput

fg - brings a background process back to foreground

Ashish Bhatia Introduction to Linux

Page 80: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

More process handling

ps [-ely] - see all processes of all users

pstree - shows processes in tree-like (father-child) relation

top - show list of running processes interactively

q - quitk - kill a process

signal -9 kill without warningsignal -15 kill after warning (allows cleanup)

kill [signal] process-id

kill -9 process-id

killall [signal] process-cmd-name

Ashish Bhatia Introduction to Linux

Page 81: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

More process handling

ps [-ely] - see all processes of all users

pstree - shows processes in tree-like (father-child) relation

top - show list of running processes interactively

q - quitk - kill a process

signal -9 kill without warningsignal -15 kill after warning (allows cleanup)

kill [signal] process-id

kill -9 process-id

killall [signal] process-cmd-name

Ashish Bhatia Introduction to Linux

Page 82: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

More process handling

ps [-ely] - see all processes of all users

pstree - shows processes in tree-like (father-child) relation

top - show list of running processes interactively

q - quitk - kill a process

signal -9 kill without warningsignal -15 kill after warning (allows cleanup)

kill [signal] process-id

kill -9 process-id

killall [signal] process-cmd-name

Ashish Bhatia Introduction to Linux

Page 83: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

More process handling

ps [-ely] - see all processes of all users

pstree - shows processes in tree-like (father-child) relation

top - show list of running processes interactively

q - quitk - kill a process

signal -9 kill without warningsignal -15 kill after warning (allows cleanup)

kill [signal] process-id

kill -9 process-id

killall [signal] process-cmd-name

Ashish Bhatia Introduction to Linux

Page 84: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

More process handling

ps [-ely] - see all processes of all users

pstree - shows processes in tree-like (father-child) relation

top - show list of running processes interactively

q - quitk - kill a process

signal -9 kill without warningsignal -15 kill after warning (allows cleanup)

kill [signal] process-id

kill -9 process-id

killall [signal] process-cmd-name

Ashish Bhatia Introduction to Linux

Page 85: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Executing multiple processes(in parallel)

More process handling

ps [-ely] - see all processes of all users

pstree - shows processes in tree-like (father-child) relation

top - show list of running processes interactively

q - quitk - kill a process

signal -9 kill without warningsignal -15 kill after warning (allows cleanup)

kill [signal] process-id

kill -9 process-id

killall [signal] process-cmd-name

Ashish Bhatia Introduction to Linux

Page 86: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Free Software

As defined by FSF (1986)

1 run the program (for any purpose)

2 study how the program works (and change it to your needs)

3 redistribute copies

4 improve the program and release your improvements to thepublic

Ashish Bhatia Introduction to Linux

Page 87: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Free Software

As defined by FSF (1986)

1 run the program (for any purpose)

2 study how the program works (and change it to your needs)

3 redistribute copies

4 improve the program and release your improvements to thepublic

Ashish Bhatia Introduction to Linux

Page 88: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Free Software

As defined by FSF (1986)

1 run the program (for any purpose)

2 study how the program works (and change it to your needs)

3 redistribute copies

4 improve the program and release your improvements to thepublic

Ashish Bhatia Introduction to Linux

Page 89: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Free Software

As defined by FSF (1986)

1 run the program (for any purpose)

2 study how the program works (and change it to your needs)

3 redistribute copies

4 improve the program and release your improvements to thepublic

Ashish Bhatia Introduction to Linux

Page 90: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Licenses

1 GNU General Purpose License

2 GNU Lesser General Purpose License

3 Apache License

4 BSD License

5 lot of others

Disclaimer: I am not a legal expert

Ashish Bhatia Introduction to Linux

Page 91: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Licenses

1 GNU General Purpose License

2 GNU Lesser General Purpose License

3 Apache License

4 BSD License

5 lot of others

Disclaimer: I am not a legal expert

Ashish Bhatia Introduction to Linux

Page 92: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Licenses

1 GNU General Purpose License

2 GNU Lesser General Purpose License

3 Apache License

4 BSD License

5 lot of others

Disclaimer: I am not a legal expert

Ashish Bhatia Introduction to Linux

Page 93: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Licenses

1 GNU General Purpose License

2 GNU Lesser General Purpose License

3 Apache License

4 BSD License

5 lot of others

Disclaimer: I am not a legal expert

Ashish Bhatia Introduction to Linux

Page 94: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Licenses

1 GNU General Purpose License

2 GNU Lesser General Purpose License

3 Apache License

4 BSD License

5 lot of others

Disclaimer: I am not a legal expert

Ashish Bhatia Introduction to Linux

Page 95: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

GNU GPL

1 most popular (and most sophisticated)

2 a work derived from GPL licensed work must be licensedunder GPL

3 linking to GPL code?

Ashish Bhatia Introduction to Linux

Page 96: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

GNU GPL

1 most popular (and most sophisticated)

2 a work derived from GPL licensed work must be licensedunder GPL

3 linking to GPL code?

Ashish Bhatia Introduction to Linux

Page 97: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

GNU GPL

1 most popular (and most sophisticated)

2 a work derived from GPL licensed work must be licensedunder GPL

3 linking to GPL code?

Ashish Bhatia Introduction to Linux

Page 98: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

GNU LGPL

1 less restrictive than GPL

2 LGPL licensed code can be linked by non-(L)GPL code

3 derivative work must still release code for personal use (ofcustomer)

4 LGPL vs GPL? which one to use?

Ashish Bhatia Introduction to Linux

Page 99: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

GNU LGPL

1 less restrictive than GPL

2 LGPL licensed code can be linked by non-(L)GPL code

3 derivative work must still release code for personal use (ofcustomer)

4 LGPL vs GPL? which one to use?

Ashish Bhatia Introduction to Linux

Page 100: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

GNU LGPL

1 less restrictive than GPL

2 LGPL licensed code can be linked by non-(L)GPL code

3 derivative work must still release code for personal use (ofcustomer)

4 LGPL vs GPL? which one to use?

Ashish Bhatia Introduction to Linux

Page 101: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

GNU LGPL

1 less restrictive than GPL

2 LGPL licensed code can be linked by non-(L)GPL code

3 derivative work must still release code for personal use (ofcustomer)

4 LGPL vs GPL? which one to use?

Ashish Bhatia Introduction to Linux

Page 102: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

BSD

1 Very permissive

2 just give credits to the previous contributors

3 no need to release source-code

4 “If you want to give your software away for free, use BSD. Ifyou want to share your software, use the GPL”(Courtesy:OSnews)

Ashish Bhatia Introduction to Linux

Page 103: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

BSD

1 Very permissive

2 just give credits to the previous contributors

3 no need to release source-code

4 “If you want to give your software away for free, use BSD. Ifyou want to share your software, use the GPL”(Courtesy:OSnews)

Ashish Bhatia Introduction to Linux

Page 104: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

BSD

1 Very permissive

2 just give credits to the previous contributors

3 no need to release source-code

4 “If you want to give your software away for free, use BSD. Ifyou want to share your software, use the GPL”(Courtesy:OSnews)

Ashish Bhatia Introduction to Linux

Page 105: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

BSD

1 Very permissive

2 just give credits to the previous contributors

3 no need to release source-code

4 “If you want to give your software away for free, use BSD. Ifyou want to share your software, use the GPL”(Courtesy:OSnews)

Ashish Bhatia Introduction to Linux

Page 106: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Apache

1 Permissiveness same as BSD but legally more explicit

2 handles the problem of software patents

3 author of the code (automatically) gives up the right to any of(his/her) patent used in the code

Ashish Bhatia Introduction to Linux

Page 107: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Apache

1 Permissiveness same as BSD but legally more explicit

2 handles the problem of software patents

3 author of the code (automatically) gives up the right to any of(his/her) patent used in the code

Ashish Bhatia Introduction to Linux

Page 108: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Apache

1 Permissiveness same as BSD but legally more explicit

2 handles the problem of software patents

3 author of the code (automatically) gives up the right to any of(his/her) patent used in the code

Ashish Bhatia Introduction to Linux

Page 109: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Case 1

ACME systems internally uses CRM whose codebase is basedon a GPL based CRM. Can an employee of the company askfor the source code?

Ashish Bhatia Introduction to Linux

Page 110: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Case 2

Microspecial Inc. supplies embedded systems to thegovernment, as per the government orders they cannot releasethe source code to anyone but their codebase is based on GPLbased code. What if someone asks for the source code? dothey have to give it?

Ashish Bhatia Introduction to Linux

Page 111: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Case 3

Stickpoint Solutions released Office software 1.0 under GPLand in the next version, they decide to move to BSD license?can they do it?

Ashish Bhatia Introduction to Linux

Page 112: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Case 4

Tivo used parts of Linux kernel code for its consumerelectronics product, so they had to release the source codebut they put on the hardware check to avoid customised codefrom execution. Is this a violation of GPL?

Ashish Bhatia Introduction to Linux

Page 113: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

Case 5

Web Ultimates released source code of CMS(web application)under GPL, Web Peers Inc. used the code to develop theirwebsite, do they have to release the source code of theirwebsite?

Ashish Bhatia Introduction to Linux

Page 114: Techbuddy: Introduction to Linux session

Philosophy Concept of Users File Handling in Linux Process Handling in Linux Licenses

References

1 Linux Man Pages

2 The Linux Documentation Project

3 Free Software Foundation (FSF) website

Ashish Bhatia Introduction to Linux