SlideShare a Scribd company logo
1 of 54
Download to read offline
Team Emertxe
Linux Internals
Day 1
Introduction
Introduction
Let us ponder ...
● What exactly is an Operating System (OS)?
● Why do we need OS?
● How would the OS would look like?
● Is it possible for a team of us (in the room) to create an
OS of our own?
● Is it necessary to have an OS running in a Embedded
System?
● Will the OS ever stop at all?
Introduction
Operating System
Compiler Assembler Text Editor Database
System and Application Programs
Operating System
Humans
Program
Interface
User
Programs
Operating
System
OS
Interface
HW
Interface/
Privileged
Instr
Hardware
Introduction
What is Linux?
● Linux is a free and open source operating system that is
causing a revolution in the computer world
● Originally created by Linus Torvalds with the assistance of
developers called community
● This operating system in only a few short years is
beginning to dominate markets worldwide
Introduction
Why use Linux?
● Free & Open Source –GPL license, no cost
● Reliability –Build systems with 99.999% upstream
● Secure –Monolithic kernel offering high security
● Scalability –From mobile phone to stock market servers
Introduction
What is Open Source?
Freedom of
software
Freedom of
redistribute
Freedom of
copy
Freedom of
modify
Freedom of
use
Introduction
Open Source - How it all started?
● With GNU (GNU is not UNIX)
● Richard Stallman made the initial announcement in 1983, Free
Software Foundation (FSF) got formed during 1984
● Volunteer driven GNU started developing multiple projects,
but making it as an operating system was always a challenge
● During 1991 a Finnish Engineer Linus Torvalds developed core
OS functionality, called it as “Linux Kernel”
● Linux Kernel got licensed under GPL, which laid strong
platform for the success of Open Source
● Rest is history!
Introduction
Open Source - How it evolved?
● Multiple Linux distributions started emerging around the Kernel
● Some applications became platform independent
● Community driven software development started picking up
● Initially seen as a “geek-phenomenon”, eventually turned out to be
an engineering marvel
●
Centered around Internet
● Building a business around open source started becoming viable
● Redhat set the initial trend in the OS business
Customization
Applications
Kernel
Introduction
Open Source - Where it stands now?
OS Databases Server/Cloud Enterprise
Consumer Education CMS eCommerce
Introduction
Open Source vs Freeware
OSS Freeware
 Users have the right to access &
modify the source codes
 In case original programmer
disappeared, users & developer
group of the S/W usually keep its
support to the S/W.
 OSS usually has the strong users &
developers group that manage and
maintain the project
 Freeware is usually distributed in a
form of binary at ‘Free of Charge’,
but does not open source codes
itself.
 Developer of freeware could
abandon development at any time
and then final version will be the
last version of the freeware. No
enhancements will be made by
others.
 Possibility of changing its licensing
policy
Introduction
GPL
● Basic rights under the GPL – access to source code, right
to make derivative works
● Reciprocity/Copy-left
● Purpose is to increase amount of publicly available
software and ensure compatibility
● Licensees have right to modify, use or distribute
software, and to access the source code
Introduction
GPL - Issues
● Linking to GPL programs
● No explicit patent grant
● Does no discuss trademark rights
● Does not discuss duration
● Silent on sub-licensing
● Relies exclusively on license law, not contract
Introduction
Linux Properties
● Multitasking
● Multi-user
● Multiprocessing
● Protected Memory
● Hierarchical File System
Introduction
Linux Components
● Hardware Controllers: This subsystem is
comprised of all the possible physical devices
in a Linux installation - CPU, memory
hardware, hard disks
● Linux Kernel: The kernel abstracts and
mediates access to the hardware resources,
including the CPU. A kernel is the core of the
operating system
● O/S Services: These are services that are
typically considered part of the operating
system (e.g. windowing system, command
shell)
● User Applications: The set of applications in
use on a particular Linux system (e.g. web
browser)
User
Application
GNU
C
Library
System Call Interface
Kernel
Architecture Dependent
Kernel Code
Hardware Platform
Linux
UserSpaceKernelSpace
Introduction
Linux Directory Structure
/
/boot
/dev
/bin
/etc
/lib
/media
/mnt
/opt
/sbin
/tmp
/usr
/root
/home
/var
/proc
User home directories
Root user's home directory
Essential user command binaries
Essential super user command binaries
Essential shared libraries and kernel modules
Multi user utilities and application
Add-on application software packages
Host specific configuration
Device files
Mount point for removable media
Mount point for temporarily mounted file systems
Static boot-able images
Temporary files
Variable files (Logs)
Virtual FS documenting kernel and process status
User Interfaces
User Interfaces
GUI
● Can use Mouse, Keyboard, Touch Screens
User Interfaces
CLI
● Textual mode used to execute requested commands
User Interfaces
The Shell
● What is a Shell
● Types of shells
– Login
– Non Login
● sh
● bash
● ksh
● csh
● Hands on:
– cat /etc/shells
– echo $0
User Interfaces
The Shell - Invocation
● The main task of a shell is providing a user environment
shell
Input
(ls)
List all
the
files
List all
the
files
User Interfaces
The Shell - bash
● Bash – The command interpreter
– .bash_profile (During login)
– .bashrc (New instance)
– .bash_logout (Logout)
– .bash_history (Command history)
● Hands on:
– Enter ls -a in your home directory
– Display contents of all files mentioned above
User Interfaces
The Shell – Environmental Variables
● Login-shell's responsibility is to set the non-login shell and
it will set the environment variables
● Environment variables are set for every shell and generally
at login time
● Environmental variables are set by the system.
● Environmental variables hold special values. For instance
$ echo $SHELL
● Environmental variables are defined in /etc/profile,
/etc/profile.d/ and ~/.bash_profile.
● When a login shell exits, bash reads ~/.bash_logout
User Interfaces
The Shell – Environmental Variables
● env - lists shell environment variable/value pairs
● export [var_name] - exports/sets a shell variable
– HOME - path to user’s home directory
– PATH - executable search path
– PWD - present working directory
– PS1 - command prompt
● N=10 - Assigning the variable. This a temporary variable
effective only inside the current shell)
● unset N - Unset the environment variable N
Basic Shell Commands
Basic Shell Commands
Types
●
An executable program like all those files can have in
/usr/bin.
●
A command built into the shell itself. bash provides a number
of commands internally called shell built-ins The cd
command, for example, is a shell built-in
●
A shell function. These are miniature shell scripts
incorporated into the environment.
●
An alias. Commands that you can define yourselves, built
from other commands.
●
To know the type, try
$ type <command>
Basic Shell Commands
Information
●
ls - list's all the files
●
pwd - gives present working directory
●
man - gives information about command
●
info <topic> - information pages on <topic>
●
which - shows full path of command
●
df - disk free
●
du - disk usage
●
stat - File and Inode information
●
uname - print system information
Basic Shell Commands
User Specific
● All Accesses into a Linux System are through a User
● User related Shell Command Set
– useradd - create user
– userdel - delete user
– su - [username] - start new shell as different user
– finger - user information lookup
– passwd - change or create user password
– who, w - to find out who is logged in
– whoami - who are you
Basic Shell Commands
Remote Access
● ssh - (secured login) is a program for logging into a
remote machine and for executing commands on a
remote machine.
Example: ssh username@ipaddress
● scp - (secured copy) copies files between hosts on a
network.
Example: scp filename username@ipaddress:/path/
Basic Shell Commands
File System related
● Every thing is viewed as a file in Linux. Even a directory
is a file.
– mount - Mounting filesystem
– find, locate - Search for files
– cd - change directory.
– cp - copy
– mv - move, rename
– rm – remove
Basic Shell Commands
File System related
– mkdir - make directory
– rmdir - remove directory
– cat, less, head, tail - used to view text files
– touch - create and update files
– wc - counts the number of lines in a file
Basic Shell Commands
Archiving
● gzip - This will compress folder or file
● gunzip - This will uncompress
● tar - Archiving files
Basic Shell Commands
Filters
● Filters are the programs, which read some input, perform
the transformation on it and gives the output. Some
commonly used filters are as follow
– tail - Print the last 10 lines of each FILE to standard
output.
– sort - Sort lines of text files
– tr - Translate, squeeze, and/or delete characters from
standard input, writing to standard output.
– wc - Print newline, word, and byte counts for each file
Basic Shell Commands
Pattern Matching
● Grep is pattern matching tool used to search the name
input file. Basically its used for lines matching a pattern
Example:
$ ls | grep *.c
This will list the files from the current directory with .c
extension
Files
Listing
user@user:~] ls -l
total 12
drwxrwxr-x 2 user user 4096 Jun 23 16:48 A-Direcory
brw-r--r-- 1 root root 7, 0 Jun 23 16:55 block_file
crw-r--r-- 1 root root 108, 0 Jun 23 16:49 character_file
lrwxrwxrwx 1 user user 12 Jun 23 16:50 link_to_regular_file -> regular_file
prw-rw-r-- 1 user user 0 Jun 23 16:50 named_pipe
-rw-rw-r-- 1 user user 0 Jun 23 16:48 regular_file
-rwxrwxr-x 1 user user 7639 Jun 23 16:54 server
srwxrwxr-x 1 user user 0 Jun 23 16:55 server_socket
permissions
owner
& group
file
size
created date
& time
file name
Files
Types
user@user:~] ls -l
total 12
drwxrwxr-x 2 user user
brw-r--r-- 1 root root
crw-r--r-- 1 root root
lrwxrwxrwx 1 user user
prw-rw-r-- 1 user user
-rwxrwxr-x 1 user user
srwxrwxr-x 1 user user
Directory
Block
Character
Soft Link
FIFO (sometimes =)
Plain Text
Socket
Files
Permissions
user@user:~] ls -l
total 1
-r w x r w x r - x 2 user user
Read 100 - 4
Write 010 - 2
Execute 001 - 1
Value used to Set
Files
Permissions
user@user:~] ls -l
total 1
-r w x r w x r w x 2 user user
user group others
Files
Permission Modification
● chmod – Change file permissions
● chown – Change file owner
● chmod [ ug+r, 746 ] file.txt
● chown -R user:group [ filename | dir ]
I/O Redirection
Output
●
Output redirection ( > )
●
Redirecting to append ( >> )
●
Redirecting the error (2>)
Examples:
$ ls > /tmp/output_file
Redirects the output of ls to output_file
$ ls -l >> /tmp/output_file
Appends the output of ls -l to output_file
$ ls 2> /tmp/output_file
Redirects the error output of ls to output_file
I/O Redirection
Pipe
● A pipe is a form of redirection that is used in Linux
operating systems to send the output of one program to
another program for further processing.
● A pipe is designated in commands by the vertical bar
character
Example:
$ ls -al /bin | less
Visual Editor - vi
Visual Editor - vi
● Screen-oriented text editor originally created for the
Unix operating system
● The name vi is derived from the shortest unambiguous
abbreviation for the ex command visual
● Improved version is called as vim
● To open a file
$ vi <filename>
or
$ vim <filename>
Visual Editor - vi
● vi opens a file in command mode to start mode.
● The power of vi comes from its 3 modes
– Escape mode (Command mode)
●
Search mode
● File mode
– Editing mode
● Insert mode
● Append mode
● Open mode
●
Replace mode
– Visual mode
Visual Editor – vi
Cursor Movement
● You will clearly need to move the cursor around your file.
You can move the cursor in command mode.
● vi has many different cursor movement commands. The
four basic keys appear below
– k move up one line
– h line move one character to the left
– l line move one character to the right
– j move down one line
● Yes! Arrow keys also do work. But these makes typing
faster
Visual Editor – vi
Basic Commands
● Open a file
$ vi <file_name>
● How to exit
:q -> Close with out saving.
:wq -> Close the file with saving.
:q! -> Close the file forcefully with out saving
● Already looks too complicated?
● Try by yourself, let us write a C program
Visual Editor – vi
Escape / Command Mode
● In command mode, characters you perform actions like moving the
cursor, cutting or copying text, or searching for some particular text
– Search mode
● vi can search the entire file for a given string of text. A string is a
sequence of characters. vi searches forward with the slash (/) key
and string to search. To cancel the search, press ESC .You can
search again by typing n (forward) or N (backward). Also, when vi
reaches the end of the text, it continues searching from the
beginning. This feature is called wrap scan
● Instead of (/), you may also use question (?). That would have
direction reversed
● Now, try out. Start vi as usual and try a simple search. Type
/<string> and press n and N a few times to see where the cursor
goes.
Visual Editor – vi
Escape / Command Mode
– File mode
●
Changing (Replacing) Text
:%s/first/sec - Replaces the first by second every where in
the file
:%s/orange/apple/gc - For all lines in a file, find string
"orange" and replace with string "apple" for each instance on
a line
●
File Interactions (edit and read)
:e filename - open another file without closing the current
:r filename - reads file named filename in place
●
Editor Settings
:set all - display all settings of your session
Visual Editor – vi
Escape / Command Mode – Useful Shortcuts
Command Operation
G Go to last line of the file
gg Go to first line of the file
. Repeat the previous command
Ctrl a Increment number under the cursor by 1
Ctrl x Decrements numbers under the cursor by 1
J Joining the two adjacent lines
(n)gg Move cursor to nth
line
Visual Editor – vi
Editing Mode
Command Mode Name Insertion Point
a Append just after the current character
A Append end of the current line
i Insert just before the current character
I Insert beginning of the current line
o Open new line below the current line
O Open new line above the current line
Visual Editor – vi
Editing Mode – Editing Text
Command Operation
dd For deleting a line
(n)dd For deleting a n lines
x To delete a single character
D Delete contents of line after cursor
dw Delete word
(n)dw Delete n words
● Deleting Text Sometimes you will want to delete some of
the text you are editing. To do so, first move the cursor
so that it covers the first character of the group you want
to delete, then type the desired command from the table
below.
Visual Editor – vi
Visual Mode – Editing Text
● Visual Mode
– Visual mode helps to visually select some text, may be
seen as a sub mode of the command mode to switch
from the command mode to the visual mode type one
of
● v - visual mode
● ctrl+v - Go's to visual block mode.
● d or y Delete or Yank selected text
● I or A Insert or Append text in all lines (visual block
only)
Stay connected
About us: Emertxe is India’s one of the top IT finishing schools & self learning kits
provider. Our primary focus is on Embedded with diversification focus on Java,
Oracle and Android areas
Branch Office: Corporate Headquarters:
Emertxe Information Technologies, Emertxe Information Technologies,
No-1, 9th Cross, 5th Main, 83, Farah Towers, 1st
Floor,
Jayamahal Extension, MG Road,
Bangalore, Karnataka 560046 Bangalore, Karnataka - 560001
T: +91 809 555 7333 (M), +91 80 41289576 (L)
E: training@emertxe.com
https://www.facebook.com/Emertxe https://twitter.com/EmertxeTweet https://www.slideshare.net/EmertxeSlides
Thank You

More Related Content

What's hot

Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
Linux internal
Linux internalLinux internal
Linux internalmcganesh
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal BootloaderSatpal Parmar
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driverVandana Salve
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelDivye Kapoor
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingTushar B Kute
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/CoreShay Cohen
 

What's hot (20)

Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
 
Linux internal
Linux internalLinux internal
Linux internal
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
Linux Kernel Overview
Linux Kernel OverviewLinux Kernel Overview
Linux Kernel Overview
 
Android Things : Building Embedded Devices
Android Things : Building Embedded DevicesAndroid Things : Building Embedded Devices
Android Things : Building Embedded Devices
 
Linux device drivers
Linux device driversLinux device drivers
Linux device drivers
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Linux Internals - Interview essentials - 1.0
Linux Internals - Interview essentials - 1.0Linux Internals - Interview essentials - 1.0
Linux Internals - Interview essentials - 1.0
 
Linux Internals - Interview essentials 4.0
Linux Internals - Interview essentials 4.0Linux Internals - Interview essentials 4.0
Linux Internals - Interview essentials 4.0
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 

Similar to Linux Internals - Part I

Similar to Linux Internals - Part I (20)

Linux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platformLinux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platform
 
Linux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell ScriptingLinux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell Scripting
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Basic orientation to Linux
Basic orientation to LinuxBasic orientation to Linux
Basic orientation to Linux
 
Linux
LinuxLinux
Linux
 
Tips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development EfficiencyTips and Tricks for Increased Development Efficiency
Tips and Tricks for Increased Development Efficiency
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
 
Linux introduction (eng)
Linux introduction (eng)Linux introduction (eng)
Linux introduction (eng)
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
 
3. intro
3. intro3. intro
3. intro
 
cisco
ciscocisco
cisco
 
Tutorial 2
Tutorial 2Tutorial 2
Tutorial 2
 
Adhocr T-dose 2012
Adhocr T-dose 2012Adhocr T-dose 2012
Adhocr T-dose 2012
 
Lesson 1 Linux System Fundamentals
Lesson 1 Linux System Fundamentals  Lesson 1 Linux System Fundamentals
Lesson 1 Linux System Fundamentals
 
Basics of Linux Commands, Git and Github
Basics of Linux Commands, Git and GithubBasics of Linux Commands, Git and Github
Basics of Linux Commands, Git and Github
 
UNIX/Linux training
UNIX/Linux trainingUNIX/Linux training
UNIX/Linux training
 
Linux programming - Getting self started
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started
 
Linux basics
Linux basics Linux basics
Linux basics
 

More from Emertxe Information Technologies Pvt Ltd

More from Emertxe Information Technologies Pvt Ltd (20)

premium post (1).pdf
premium post (1).pdfpremium post (1).pdf
premium post (1).pdf
 
Career Transition (1).pdf
Career Transition (1).pdfCareer Transition (1).pdf
Career Transition (1).pdf
 
10_isxdigit.pdf
10_isxdigit.pdf10_isxdigit.pdf
10_isxdigit.pdf
 
01_student_record.pdf
01_student_record.pdf01_student_record.pdf
01_student_record.pdf
 
02_swap.pdf
02_swap.pdf02_swap.pdf
02_swap.pdf
 
01_sizeof.pdf
01_sizeof.pdf01_sizeof.pdf
01_sizeof.pdf
 
07_product_matrix.pdf
07_product_matrix.pdf07_product_matrix.pdf
07_product_matrix.pdf
 
06_sort_names.pdf
06_sort_names.pdf06_sort_names.pdf
06_sort_names.pdf
 
05_fragments.pdf
05_fragments.pdf05_fragments.pdf
05_fragments.pdf
 
04_magic_square.pdf
04_magic_square.pdf04_magic_square.pdf
04_magic_square.pdf
 
03_endianess.pdf
03_endianess.pdf03_endianess.pdf
03_endianess.pdf
 
02_variance.pdf
02_variance.pdf02_variance.pdf
02_variance.pdf
 
01_memory_manager.pdf
01_memory_manager.pdf01_memory_manager.pdf
01_memory_manager.pdf
 
09_nrps.pdf
09_nrps.pdf09_nrps.pdf
09_nrps.pdf
 
11_pangram.pdf
11_pangram.pdf11_pangram.pdf
11_pangram.pdf
 
10_combinations.pdf
10_combinations.pdf10_combinations.pdf
10_combinations.pdf
 
08_squeeze.pdf
08_squeeze.pdf08_squeeze.pdf
08_squeeze.pdf
 
07_strtok.pdf
07_strtok.pdf07_strtok.pdf
07_strtok.pdf
 
06_reverserec.pdf
06_reverserec.pdf06_reverserec.pdf
06_reverserec.pdf
 
05_reverseiter.pdf
05_reverseiter.pdf05_reverseiter.pdf
05_reverseiter.pdf
 

Recently uploaded

Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 

Recently uploaded (20)

Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 

Linux Internals - Part I

  • 3. Introduction Let us ponder ... ● What exactly is an Operating System (OS)? ● Why do we need OS? ● How would the OS would look like? ● Is it possible for a team of us (in the room) to create an OS of our own? ● Is it necessary to have an OS running in a Embedded System? ● Will the OS ever stop at all?
  • 4. Introduction Operating System Compiler Assembler Text Editor Database System and Application Programs Operating System Humans Program Interface User Programs Operating System OS Interface HW Interface/ Privileged Instr Hardware
  • 5. Introduction What is Linux? ● Linux is a free and open source operating system that is causing a revolution in the computer world ● Originally created by Linus Torvalds with the assistance of developers called community ● This operating system in only a few short years is beginning to dominate markets worldwide
  • 6. Introduction Why use Linux? ● Free & Open Source –GPL license, no cost ● Reliability –Build systems with 99.999% upstream ● Secure –Monolithic kernel offering high security ● Scalability –From mobile phone to stock market servers
  • 7. Introduction What is Open Source? Freedom of software Freedom of redistribute Freedom of copy Freedom of modify Freedom of use
  • 8. Introduction Open Source - How it all started? ● With GNU (GNU is not UNIX) ● Richard Stallman made the initial announcement in 1983, Free Software Foundation (FSF) got formed during 1984 ● Volunteer driven GNU started developing multiple projects, but making it as an operating system was always a challenge ● During 1991 a Finnish Engineer Linus Torvalds developed core OS functionality, called it as “Linux Kernel” ● Linux Kernel got licensed under GPL, which laid strong platform for the success of Open Source ● Rest is history!
  • 9. Introduction Open Source - How it evolved? ● Multiple Linux distributions started emerging around the Kernel ● Some applications became platform independent ● Community driven software development started picking up ● Initially seen as a “geek-phenomenon”, eventually turned out to be an engineering marvel ● Centered around Internet ● Building a business around open source started becoming viable ● Redhat set the initial trend in the OS business Customization Applications Kernel
  • 10. Introduction Open Source - Where it stands now? OS Databases Server/Cloud Enterprise Consumer Education CMS eCommerce
  • 11. Introduction Open Source vs Freeware OSS Freeware  Users have the right to access & modify the source codes  In case original programmer disappeared, users & developer group of the S/W usually keep its support to the S/W.  OSS usually has the strong users & developers group that manage and maintain the project  Freeware is usually distributed in a form of binary at ‘Free of Charge’, but does not open source codes itself.  Developer of freeware could abandon development at any time and then final version will be the last version of the freeware. No enhancements will be made by others.  Possibility of changing its licensing policy
  • 12. Introduction GPL ● Basic rights under the GPL – access to source code, right to make derivative works ● Reciprocity/Copy-left ● Purpose is to increase amount of publicly available software and ensure compatibility ● Licensees have right to modify, use or distribute software, and to access the source code
  • 13. Introduction GPL - Issues ● Linking to GPL programs ● No explicit patent grant ● Does no discuss trademark rights ● Does not discuss duration ● Silent on sub-licensing ● Relies exclusively on license law, not contract
  • 14. Introduction Linux Properties ● Multitasking ● Multi-user ● Multiprocessing ● Protected Memory ● Hierarchical File System
  • 15. Introduction Linux Components ● Hardware Controllers: This subsystem is comprised of all the possible physical devices in a Linux installation - CPU, memory hardware, hard disks ● Linux Kernel: The kernel abstracts and mediates access to the hardware resources, including the CPU. A kernel is the core of the operating system ● O/S Services: These are services that are typically considered part of the operating system (e.g. windowing system, command shell) ● User Applications: The set of applications in use on a particular Linux system (e.g. web browser) User Application GNU C Library System Call Interface Kernel Architecture Dependent Kernel Code Hardware Platform Linux UserSpaceKernelSpace
  • 16. Introduction Linux Directory Structure / /boot /dev /bin /etc /lib /media /mnt /opt /sbin /tmp /usr /root /home /var /proc User home directories Root user's home directory Essential user command binaries Essential super user command binaries Essential shared libraries and kernel modules Multi user utilities and application Add-on application software packages Host specific configuration Device files Mount point for removable media Mount point for temporarily mounted file systems Static boot-able images Temporary files Variable files (Logs) Virtual FS documenting kernel and process status
  • 18. User Interfaces GUI ● Can use Mouse, Keyboard, Touch Screens
  • 19. User Interfaces CLI ● Textual mode used to execute requested commands
  • 20. User Interfaces The Shell ● What is a Shell ● Types of shells – Login – Non Login ● sh ● bash ● ksh ● csh ● Hands on: – cat /etc/shells – echo $0
  • 21. User Interfaces The Shell - Invocation ● The main task of a shell is providing a user environment shell Input (ls) List all the files List all the files
  • 22. User Interfaces The Shell - bash ● Bash – The command interpreter – .bash_profile (During login) – .bashrc (New instance) – .bash_logout (Logout) – .bash_history (Command history) ● Hands on: – Enter ls -a in your home directory – Display contents of all files mentioned above
  • 23. User Interfaces The Shell – Environmental Variables ● Login-shell's responsibility is to set the non-login shell and it will set the environment variables ● Environment variables are set for every shell and generally at login time ● Environmental variables are set by the system. ● Environmental variables hold special values. For instance $ echo $SHELL ● Environmental variables are defined in /etc/profile, /etc/profile.d/ and ~/.bash_profile. ● When a login shell exits, bash reads ~/.bash_logout
  • 24. User Interfaces The Shell – Environmental Variables ● env - lists shell environment variable/value pairs ● export [var_name] - exports/sets a shell variable – HOME - path to user’s home directory – PATH - executable search path – PWD - present working directory – PS1 - command prompt ● N=10 - Assigning the variable. This a temporary variable effective only inside the current shell) ● unset N - Unset the environment variable N
  • 26. Basic Shell Commands Types ● An executable program like all those files can have in /usr/bin. ● A command built into the shell itself. bash provides a number of commands internally called shell built-ins The cd command, for example, is a shell built-in ● A shell function. These are miniature shell scripts incorporated into the environment. ● An alias. Commands that you can define yourselves, built from other commands. ● To know the type, try $ type <command>
  • 27. Basic Shell Commands Information ● ls - list's all the files ● pwd - gives present working directory ● man - gives information about command ● info <topic> - information pages on <topic> ● which - shows full path of command ● df - disk free ● du - disk usage ● stat - File and Inode information ● uname - print system information
  • 28. Basic Shell Commands User Specific ● All Accesses into a Linux System are through a User ● User related Shell Command Set – useradd - create user – userdel - delete user – su - [username] - start new shell as different user – finger - user information lookup – passwd - change or create user password – who, w - to find out who is logged in – whoami - who are you
  • 29. Basic Shell Commands Remote Access ● ssh - (secured login) is a program for logging into a remote machine and for executing commands on a remote machine. Example: ssh username@ipaddress ● scp - (secured copy) copies files between hosts on a network. Example: scp filename username@ipaddress:/path/
  • 30. Basic Shell Commands File System related ● Every thing is viewed as a file in Linux. Even a directory is a file. – mount - Mounting filesystem – find, locate - Search for files – cd - change directory. – cp - copy – mv - move, rename – rm – remove
  • 31. Basic Shell Commands File System related – mkdir - make directory – rmdir - remove directory – cat, less, head, tail - used to view text files – touch - create and update files – wc - counts the number of lines in a file
  • 32. Basic Shell Commands Archiving ● gzip - This will compress folder or file ● gunzip - This will uncompress ● tar - Archiving files
  • 33. Basic Shell Commands Filters ● Filters are the programs, which read some input, perform the transformation on it and gives the output. Some commonly used filters are as follow – tail - Print the last 10 lines of each FILE to standard output. – sort - Sort lines of text files – tr - Translate, squeeze, and/or delete characters from standard input, writing to standard output. – wc - Print newline, word, and byte counts for each file
  • 34. Basic Shell Commands Pattern Matching ● Grep is pattern matching tool used to search the name input file. Basically its used for lines matching a pattern Example: $ ls | grep *.c This will list the files from the current directory with .c extension
  • 35. Files Listing user@user:~] ls -l total 12 drwxrwxr-x 2 user user 4096 Jun 23 16:48 A-Direcory brw-r--r-- 1 root root 7, 0 Jun 23 16:55 block_file crw-r--r-- 1 root root 108, 0 Jun 23 16:49 character_file lrwxrwxrwx 1 user user 12 Jun 23 16:50 link_to_regular_file -> regular_file prw-rw-r-- 1 user user 0 Jun 23 16:50 named_pipe -rw-rw-r-- 1 user user 0 Jun 23 16:48 regular_file -rwxrwxr-x 1 user user 7639 Jun 23 16:54 server srwxrwxr-x 1 user user 0 Jun 23 16:55 server_socket permissions owner & group file size created date & time file name
  • 36. Files Types user@user:~] ls -l total 12 drwxrwxr-x 2 user user brw-r--r-- 1 root root crw-r--r-- 1 root root lrwxrwxrwx 1 user user prw-rw-r-- 1 user user -rwxrwxr-x 1 user user srwxrwxr-x 1 user user Directory Block Character Soft Link FIFO (sometimes =) Plain Text Socket
  • 37. Files Permissions user@user:~] ls -l total 1 -r w x r w x r - x 2 user user Read 100 - 4 Write 010 - 2 Execute 001 - 1 Value used to Set
  • 38. Files Permissions user@user:~] ls -l total 1 -r w x r w x r w x 2 user user user group others
  • 39. Files Permission Modification ● chmod – Change file permissions ● chown – Change file owner ● chmod [ ug+r, 746 ] file.txt ● chown -R user:group [ filename | dir ]
  • 40. I/O Redirection Output ● Output redirection ( > ) ● Redirecting to append ( >> ) ● Redirecting the error (2>) Examples: $ ls > /tmp/output_file Redirects the output of ls to output_file $ ls -l >> /tmp/output_file Appends the output of ls -l to output_file $ ls 2> /tmp/output_file Redirects the error output of ls to output_file
  • 41. I/O Redirection Pipe ● A pipe is a form of redirection that is used in Linux operating systems to send the output of one program to another program for further processing. ● A pipe is designated in commands by the vertical bar character Example: $ ls -al /bin | less
  • 43. Visual Editor - vi ● Screen-oriented text editor originally created for the Unix operating system ● The name vi is derived from the shortest unambiguous abbreviation for the ex command visual ● Improved version is called as vim ● To open a file $ vi <filename> or $ vim <filename>
  • 44. Visual Editor - vi ● vi opens a file in command mode to start mode. ● The power of vi comes from its 3 modes – Escape mode (Command mode) ● Search mode ● File mode – Editing mode ● Insert mode ● Append mode ● Open mode ● Replace mode – Visual mode
  • 45. Visual Editor – vi Cursor Movement ● You will clearly need to move the cursor around your file. You can move the cursor in command mode. ● vi has many different cursor movement commands. The four basic keys appear below – k move up one line – h line move one character to the left – l line move one character to the right – j move down one line ● Yes! Arrow keys also do work. But these makes typing faster
  • 46. Visual Editor – vi Basic Commands ● Open a file $ vi <file_name> ● How to exit :q -> Close with out saving. :wq -> Close the file with saving. :q! -> Close the file forcefully with out saving ● Already looks too complicated? ● Try by yourself, let us write a C program
  • 47. Visual Editor – vi Escape / Command Mode ● In command mode, characters you perform actions like moving the cursor, cutting or copying text, or searching for some particular text – Search mode ● vi can search the entire file for a given string of text. A string is a sequence of characters. vi searches forward with the slash (/) key and string to search. To cancel the search, press ESC .You can search again by typing n (forward) or N (backward). Also, when vi reaches the end of the text, it continues searching from the beginning. This feature is called wrap scan ● Instead of (/), you may also use question (?). That would have direction reversed ● Now, try out. Start vi as usual and try a simple search. Type /<string> and press n and N a few times to see where the cursor goes.
  • 48. Visual Editor – vi Escape / Command Mode – File mode ● Changing (Replacing) Text :%s/first/sec - Replaces the first by second every where in the file :%s/orange/apple/gc - For all lines in a file, find string "orange" and replace with string "apple" for each instance on a line ● File Interactions (edit and read) :e filename - open another file without closing the current :r filename - reads file named filename in place ● Editor Settings :set all - display all settings of your session
  • 49. Visual Editor – vi Escape / Command Mode – Useful Shortcuts Command Operation G Go to last line of the file gg Go to first line of the file . Repeat the previous command Ctrl a Increment number under the cursor by 1 Ctrl x Decrements numbers under the cursor by 1 J Joining the two adjacent lines (n)gg Move cursor to nth line
  • 50. Visual Editor – vi Editing Mode Command Mode Name Insertion Point a Append just after the current character A Append end of the current line i Insert just before the current character I Insert beginning of the current line o Open new line below the current line O Open new line above the current line
  • 51. Visual Editor – vi Editing Mode – Editing Text Command Operation dd For deleting a line (n)dd For deleting a n lines x To delete a single character D Delete contents of line after cursor dw Delete word (n)dw Delete n words ● Deleting Text Sometimes you will want to delete some of the text you are editing. To do so, first move the cursor so that it covers the first character of the group you want to delete, then type the desired command from the table below.
  • 52. Visual Editor – vi Visual Mode – Editing Text ● Visual Mode – Visual mode helps to visually select some text, may be seen as a sub mode of the command mode to switch from the command mode to the visual mode type one of ● v - visual mode ● ctrl+v - Go's to visual block mode. ● d or y Delete or Yank selected text ● I or A Insert or Append text in all lines (visual block only)
  • 53. Stay connected About us: Emertxe is India’s one of the top IT finishing schools & self learning kits provider. Our primary focus is on Embedded with diversification focus on Java, Oracle and Android areas Branch Office: Corporate Headquarters: Emertxe Information Technologies, Emertxe Information Technologies, No-1, 9th Cross, 5th Main, 83, Farah Towers, 1st Floor, Jayamahal Extension, MG Road, Bangalore, Karnataka 560046 Bangalore, Karnataka - 560001 T: +91 809 555 7333 (M), +91 80 41289576 (L) E: training@emertxe.com https://www.facebook.com/Emertxe https://twitter.com/EmertxeTweet https://www.slideshare.net/EmertxeSlides