SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
L2B Second Linux Course



Session4



           Please visit our Facebook Group
L2B Second Linux Course
L2B Linux course



      Session outlines:
        Text Processing Tools
        Text Processing Tools Exercises
        VIM
        VIM Exercises
        Basic System Configuration Tools
L2B Second Linux Course
L2B Linux course




               Text Processing Tools
L2B Second Linux Course
L2B Linux course


     Extracting Text
        cat
            • One or more files
         less
            •   Easy to read
            •   /text
            •   n/N
            •   v     open an editor
            •   Used by man command to present man pages
L2B Second Linux Course
L2B Linux course


     Extracting Text
        head
            • First 10 lines only
            • -n     change number of lines
         tail
            • Last 10 lines only
            • -n change number of lines
            • -f   monitoring the file
L2B Second Linux Course
L2B Linux course


     Extracting Text
        cut
            •   Display specific columns
            •   -d column delimiter
            •   -f   number of field
            •   -c cut by characters
                   – cut -c2-5   /usr/share/dict/words
L2B Second Linux Course
L2B Linux course


     Extracting Text
        Grep
            •   Display lines where a pattern is matched
            •   -i   case-insensitively
            •   -n print line numbers of matches
            •   -v print lines not containing pattern
            •   -AX     include the X lines after each match
            •   -Bx      include the X lines before each match
L2B Second Linux Course
L2B Linux course


     Tools for Analyzing Text
        wc
            •   Counts words, lines, bytes and characters
            •   -l  only line count
            •   -w only word count
            •   -c only byte count
            •   -m character count (not displayed)
L2B Second Linux Course
L2B Linux course


     Tools for Analyzing Text
        sort
            •   Sort text and original file is not changed
            •   -r   reverse (descending) sort
            •   -n numeric sort
            •   -u (unique) removes duplicate lines
            •   -t c field separator
            •   -k X which field
            •   uniq & uniq -c
L2B Second Linux Course
L2B Linux course


     Tools for Analyzing Text
        diff and patch
            • diff foo.conf-broken foo.conf-works
            • -u better for patchfiles
            • Patching
                   – diff -u foo.conf-broken foo.conf-works > foo.patch
                   – patch -b foo.conf-broken foo.patch
L2B Second Linux Course
L2B Linux course


     Tools for Analyzing Text
        aspell
            • Interactively spell-check files:
                   – aspell check letter.txt
            • Non-interactively list mis-spelled words in
                   – Only reads data from standard input
                   – aspell list < letter.txt
L2B Second Linux Course
L2B Linux course


     Tools for Manipulating Text




                     tr and sed
L2B Second Linux Course
L2B Linux course


     Tools for Manipulating Text
        Tr
            • Converts characters in one set to corresponding
              characters in another set
            • Only reads data from STDIN
            • tr 'a-z' 'A-Z' < lowercase.txt
L2B Second Linux Course
L2B Linux course


     sed (stream editor)
        search/replace operations on a stream of text
        Normally does not alter source file
        -i to alter source file
        -i.bak to back-up and alter source file
L2B Second Linux Course
L2B Linux course


     sed Examples
        sed 's/dog/cat/i' pets
        sed 's/dog/cat/g' pets
        sed '1,50s/dog/cat/g' pets
        sed '/digby/,/duncan/s/dog/cat/g' pets
        sed -e 's/dog/cat/' -e 's/hi/lo/' pets
L2B Second Linux Course
L2B Linux course


     Characters for Complex Searches
       ^ represents beginning of line
       $ represents end of line
       Character classes as in bash:
            • [abc], [^abc]
            • [[:upper:]], [^[:upper:]]
         Used by: grep, sed, less, others
L2B Second Linux Course
L2B Linux course




                        VIM
L2B Second Linux Course
L2B Linux course


     VIM Advantages:
       Speed: Do more with fewer keystrokes
       Simplicity: No dependence on mouse/GUI
       Availability: Included with most Unix-like OSes
     Disadvantages
       Difficulty: Steeper learning curve than simpler
        editors
L2B Second Linux Course
L2B Linux course


     Three main modes:
        Command Mode (default): Move cursor,
         cut/paste text
        Insert Mode: Modify text
        Exit Mode: Save, quit, etc
L2B Second Linux Course
L2B Linux course

     First steps with vim
         vim filename(command mode)
         Insert mode
            •   I          at the cursor
            •   A   append to end of line
            •   I   insert at beginning of line
            •   o   insert new a line (below)
            •   O   insert new line (above)
         Exit mode
            • :w    writes (saves) the file to disk
            • :wq   writes and quits
            • :q!   quits, even if changes are lost
L2B Second Linux Course
L2B Linux course


     Command Mode
       Right Arrow moves right one character
       5, Right Arrow moves right five characters
       Arrow Keys, h, j, k, l (the same as arrows)
       w, b Move by word
       ), (   Move by sentence
       }, {   Move by paragraph
       xG           Jump to line x
       gg           Jump to the first line
      G             Jump to the last line
L2B Second Linux Course
L2B Linux course


     Command Mode
       As in less
            • /, n, N
         As in sed
         The selected line only
            • :1,5s/cat/dog/
         All of the entire file
            • :%s/cat/dog/gi
L2B Second Linux Course
L2B Linux course


     Command Mode
       Line
            • cc
            • dd
            • yy
         Letter
            • cl
            • dl
            • yl
L2B Second Linux Course
L2B Linux course


     Command Mode
       Word
            • cw
            • dw
            • yw
         Sentence ahead
            • c)
            • d)
            • y)
L2B Second Linux Course
L2B Linux course


     Command Mode
       Sentence behind
            • c(
            • d(
            • y(
         Paragraph above
            • c{
            • d{
            • y{
L2B Second Linux Course
L2B Linux course


     Command Mode
       Paragraph below
            • c}
            • d}
            • y}
        u        undo
         Ctrl-r redo
         U undo all changes to the last modified line
L2B Second Linux Course
L2B Linux course

     Command Mode
       v starts character-oriented highlighting
       V starts line-oriented highlighting
       Visual keys used with movement keys:
            • w, ), }, arrows
         Highlighted text can be
            •   Deleted
            •   Yanked
            •   Changed
            •   Filtered
            •   search/replaced, etc.
L2B Second Linux Course
L2B Linux course


     Command Mode
       Ctrl-w, s splits the screen horizontally
       Ctrl-w, v splits the screen vertically
       Ctrl-w, Arrow moves between windows
       Ctrl-w twice, Arrow moves between windows
       To search for help inside vim convert to the
        exit mode and ask for help by running the
        following
            • :help
L2B Second Linux Course
L2B Linux course

     Configuring vi and vim
       :set
            •   :set number
            •   :set all
            •   :set number (:se nu)
            •   :set nonumber (:se nonu)
            •   :set ignorecase (:se ic)
            •   :set noignorecase (:se noic)
            •   :set showmatch (:se sm)
            •   :set noshowmatch(:se nosm)
            •   :set autoindent
            •   :set noautoindent
L2B Second Linux Course
L2B Linux course


     Configuring vi and vim
       :help
       :help something
       :set
            •   :set textwidth=3
            •   :set textwidth=0
            •   :set wrapmargin=10
            •   :set wrapmargin=0
         ~/.vimrc
         vimtutor
L2B Second Linux Course
L2B Linux course




                      Basic System
                   Configuration Tools
L2B Second Linux Course
L2B Linux course

     Introduction
        Network interfaces are named sequentially:
         eth0, eth1, etc
        Multiple addresses can be assigned to a
         device with aliases
        Aliases are labeled eth0:1, eth0:2, etc.
        Aliases are treated like separate interfaces
        View interface configuration with :
          ifconfig [ethX]
        Enable interface with ifup ethX
        Disable interface with ifdown ethX
L2B Second Linux Course
L2B Linux course


     Graphical Network Configuration
       system-config-network
       System > Administration > Network
     Network Configuration Files For Devices
       /etc/sysconfig/network-scripts/ifcfg-ethX
       Complete list of options in
        /usr/share/doc/initscripts-*/sysconfig.txt
L2B Second Linux Course
L2B Linux course


     Example Of Dynamic Configuration
        DEVICE=ethX
        HWADDR=0:02:8A:A6:30:45
        BOOTPROTO=dhcp
        ONBOOT=yes
        Type=Ethernet
L2B Second Linux Course
L2B Linux course


     Example Of Static Configuration
        DEVICE=ethX
        HWADDR=0:02:8A:A6:30:45
        IPADDR=192.168.0.254
        NETMASK=255.255.255.0
        GATEWAY=192.168.2.254
        ONBOOT=yes
        Type=Ethernet
L2B Second Linux Course
L2B Linux course


     Network Configuration Files and Other
      Global Network Settings
       /etc/sysconfig/network
            • NETWORKING=yes
            • HOSTNAME=server1.example.com
            • GATEWAY=192.168.2.254
L2B Second Linux Course
L2B Linux course

     DNS configuration
       Server address is specified by dhcp or in
        /etc/resolv.conf
            • nameserver 192.168.0.254
            • nameserver 192.168.1.254
L2B Second Linux Course
L2B Linux course


     Setting the System's Date and Time
       GUI:
            • system-config-date
            • System->Administration->Date & Time
         CLI: date [MMDDhhmm[[CC]YY][.ss]]
            •   date 01011330
            •   Date 010113302007.05
            •   Date 12312359
            •   Date 123123592007
            •   Date 01010101.01
L2B Second Linux Course
L2B Linux course


     Scripting
       Taking input with positional parameters
            •   $1
            •   $2
            •   $3
            •   $4, etc.
            •   $*
            •   $#
L2B L2B Second Linux
                       Course Second Linux
L2B Linux course
                       Course
     Scripting
       Taking input with the read command
            • read x
            • read -p "Enter a filename: " file
For More info Please Visit Our Facebook Group

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Linux
LinuxLinux
Linux
 
101 2.3 manage shared libraries
101 2.3 manage shared libraries101 2.3 manage shared libraries
101 2.3 manage shared libraries
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
Unix _linux_fundamentals_for_hpc-_b
Unix  _linux_fundamentals_for_hpc-_bUnix  _linux_fundamentals_for_hpc-_b
Unix _linux_fundamentals_for_hpc-_b
 
cisco
ciscocisco
cisco
 
Linux
LinuxLinux
Linux
 
Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems Course 102: Lecture 28: Virtual FileSystems
Course 102: Lecture 28: Virtual FileSystems
 
Linux beginner's Workshop
Linux beginner's WorkshopLinux beginner's Workshop
Linux beginner's Workshop
 
Linux CLI
Linux CLILinux CLI
Linux CLI
 
3. intro
3. intro3. intro
3. intro
 
UNIX/Linux training
UNIX/Linux trainingUNIX/Linux training
UNIX/Linux training
 
Linux admin interview questions
Linux admin interview questionsLinux admin interview questions
Linux admin interview questions
 
Linux
LinuxLinux
Linux
 
Linux system administration
Linux system administrationLinux system administration
Linux system administration
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Unit 7
Unit 7Unit 7
Unit 7
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Unix reference sheet
Unix reference sheetUnix reference sheet
Unix reference sheet
 
Lpi lição 01 exam 101 objectives
Lpi lição 01  exam 101 objectivesLpi lição 01  exam 101 objectives
Lpi lição 01 exam 101 objectives
 
Linux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on EduonixLinux Administrator - The Linux Course on Eduonix
Linux Administrator - The Linux Course on Eduonix
 

Similar a Session4

ITCP PRACTICAL-1.pptx
ITCP PRACTICAL-1.pptxITCP PRACTICAL-1.pptx
ITCP PRACTICAL-1.pptxHemantJadhao3
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotationsmametter
 
Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3mametter
 
Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...André Oriani
 
The Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneThe Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneJames Long
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptxGuhanSenthil2
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talkReuven Lerner
 
001 linux revision
001 linux revision001 linux revision
001 linux revisionSherif Mousa
 
Version control with subversion
Version control with subversionVersion control with subversion
Version control with subversionxprayc
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3mametter
 
Presentation for RHCE in linux
Presentation  for  RHCE in linux Presentation  for  RHCE in linux
Presentation for RHCE in linux Kuldeep Tiwari
 
L lpic1-v3-103-1-pdf
L lpic1-v3-103-1-pdfL lpic1-v3-103-1-pdf
L lpic1-v3-103-1-pdfhellojdr
 
A Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and UnderstandingA Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and Understandingmametter
 
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON
 
Peeling back the Lambda layers
Peeling back the Lambda layersPeeling back the Lambda layers
Peeling back the Lambda layersPatrick McCaffrey
 

Similar a Session4 (20)

Linux1
Linux1Linux1
Linux1
 
ITCP PRACTICAL-1.pptx
ITCP PRACTICAL-1.pptxITCP PRACTICAL-1.pptx
ITCP PRACTICAL-1.pptx
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
 
Ch3 gnu make
Ch3 gnu makeCh3 gnu make
Ch3 gnu make
 
Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3
 
Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...Strategies to improve embedded Linux application performance beyond ordinary ...
Strategies to improve embedded Linux application performance beyond ordinary ...
 
The Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhoneThe Scheme Language -- Using it on the iPhone
The Scheme Language -- Using it on the iPhone
 
LinuxCommands (1).pdf
LinuxCommands (1).pdfLinuxCommands (1).pdf
LinuxCommands (1).pdf
 
Linex
LinexLinex
Linex
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptx
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
 
001 linux revision
001 linux revision001 linux revision
001 linux revision
 
Version control with subversion
Version control with subversionVersion control with subversion
Version control with subversion
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
 
Presentation for RHCE in linux
Presentation  for  RHCE in linux Presentation  for  RHCE in linux
Presentation for RHCE in linux
 
LISP.ppt
LISP.pptLISP.ppt
LISP.ppt
 
L lpic1-v3-103-1-pdf
L lpic1-v3-103-1-pdfL lpic1-v3-103-1-pdf
L lpic1-v3-103-1-pdf
 
A Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and UnderstandingA Type-level Ruby Interpreter for Testing and Understanding
A Type-level Ruby Interpreter for Testing and Understanding
 
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
44CON London 2015 - Reverse engineering and exploiting font rasterizers: the ...
 
Peeling back the Lambda layers
Peeling back the Lambda layersPeeling back the Lambda layers
Peeling back the Lambda layers
 

Último

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Session4

  • 1. L2B Second Linux Course Session4 Please visit our Facebook Group
  • 2. L2B Second Linux Course L2B Linux course  Session outlines:  Text Processing Tools  Text Processing Tools Exercises  VIM  VIM Exercises  Basic System Configuration Tools
  • 3. L2B Second Linux Course L2B Linux course Text Processing Tools
  • 4. L2B Second Linux Course L2B Linux course  Extracting Text  cat • One or more files  less • Easy to read • /text • n/N • v open an editor • Used by man command to present man pages
  • 5. L2B Second Linux Course L2B Linux course  Extracting Text  head • First 10 lines only • -n change number of lines  tail • Last 10 lines only • -n change number of lines • -f monitoring the file
  • 6. L2B Second Linux Course L2B Linux course  Extracting Text  cut • Display specific columns • -d column delimiter • -f number of field • -c cut by characters – cut -c2-5 /usr/share/dict/words
  • 7. L2B Second Linux Course L2B Linux course  Extracting Text  Grep • Display lines where a pattern is matched • -i case-insensitively • -n print line numbers of matches • -v print lines not containing pattern • -AX include the X lines after each match • -Bx include the X lines before each match
  • 8. L2B Second Linux Course L2B Linux course  Tools for Analyzing Text  wc • Counts words, lines, bytes and characters • -l only line count • -w only word count • -c only byte count • -m character count (not displayed)
  • 9. L2B Second Linux Course L2B Linux course  Tools for Analyzing Text  sort • Sort text and original file is not changed • -r reverse (descending) sort • -n numeric sort • -u (unique) removes duplicate lines • -t c field separator • -k X which field • uniq & uniq -c
  • 10. L2B Second Linux Course L2B Linux course  Tools for Analyzing Text  diff and patch • diff foo.conf-broken foo.conf-works • -u better for patchfiles • Patching – diff -u foo.conf-broken foo.conf-works > foo.patch – patch -b foo.conf-broken foo.patch
  • 11. L2B Second Linux Course L2B Linux course  Tools for Analyzing Text  aspell • Interactively spell-check files: – aspell check letter.txt • Non-interactively list mis-spelled words in – Only reads data from standard input – aspell list < letter.txt
  • 12. L2B Second Linux Course L2B Linux course  Tools for Manipulating Text tr and sed
  • 13. L2B Second Linux Course L2B Linux course  Tools for Manipulating Text  Tr • Converts characters in one set to corresponding characters in another set • Only reads data from STDIN • tr 'a-z' 'A-Z' < lowercase.txt
  • 14. L2B Second Linux Course L2B Linux course  sed (stream editor)  search/replace operations on a stream of text  Normally does not alter source file  -i to alter source file  -i.bak to back-up and alter source file
  • 15. L2B Second Linux Course L2B Linux course  sed Examples  sed 's/dog/cat/i' pets  sed 's/dog/cat/g' pets  sed '1,50s/dog/cat/g' pets  sed '/digby/,/duncan/s/dog/cat/g' pets  sed -e 's/dog/cat/' -e 's/hi/lo/' pets
  • 16. L2B Second Linux Course L2B Linux course  Characters for Complex Searches  ^ represents beginning of line  $ represents end of line  Character classes as in bash: • [abc], [^abc] • [[:upper:]], [^[:upper:]]  Used by: grep, sed, less, others
  • 17. L2B Second Linux Course L2B Linux course VIM
  • 18. L2B Second Linux Course L2B Linux course  VIM Advantages:  Speed: Do more with fewer keystrokes  Simplicity: No dependence on mouse/GUI  Availability: Included with most Unix-like OSes  Disadvantages  Difficulty: Steeper learning curve than simpler editors
  • 19. L2B Second Linux Course L2B Linux course  Three main modes:  Command Mode (default): Move cursor, cut/paste text  Insert Mode: Modify text  Exit Mode: Save, quit, etc
  • 20. L2B Second Linux Course L2B Linux course  First steps with vim  vim filename(command mode)  Insert mode • I at the cursor • A append to end of line • I insert at beginning of line • o insert new a line (below) • O insert new line (above)  Exit mode • :w writes (saves) the file to disk • :wq writes and quits • :q! quits, even if changes are lost
  • 21. L2B Second Linux Course L2B Linux course  Command Mode  Right Arrow moves right one character  5, Right Arrow moves right five characters  Arrow Keys, h, j, k, l (the same as arrows)  w, b Move by word  ), ( Move by sentence  }, { Move by paragraph  xG Jump to line x  gg Jump to the first line G Jump to the last line
  • 22. L2B Second Linux Course L2B Linux course  Command Mode  As in less • /, n, N  As in sed  The selected line only • :1,5s/cat/dog/  All of the entire file • :%s/cat/dog/gi
  • 23. L2B Second Linux Course L2B Linux course  Command Mode  Line • cc • dd • yy  Letter • cl • dl • yl
  • 24. L2B Second Linux Course L2B Linux course  Command Mode  Word • cw • dw • yw  Sentence ahead • c) • d) • y)
  • 25. L2B Second Linux Course L2B Linux course  Command Mode  Sentence behind • c( • d( • y(  Paragraph above • c{ • d{ • y{
  • 26. L2B Second Linux Course L2B Linux course  Command Mode  Paragraph below • c} • d} • y} u undo  Ctrl-r redo  U undo all changes to the last modified line
  • 27. L2B Second Linux Course L2B Linux course  Command Mode  v starts character-oriented highlighting  V starts line-oriented highlighting  Visual keys used with movement keys: • w, ), }, arrows  Highlighted text can be • Deleted • Yanked • Changed • Filtered • search/replaced, etc.
  • 28. L2B Second Linux Course L2B Linux course  Command Mode  Ctrl-w, s splits the screen horizontally  Ctrl-w, v splits the screen vertically  Ctrl-w, Arrow moves between windows  Ctrl-w twice, Arrow moves between windows  To search for help inside vim convert to the exit mode and ask for help by running the following • :help
  • 29. L2B Second Linux Course L2B Linux course  Configuring vi and vim  :set • :set number • :set all • :set number (:se nu) • :set nonumber (:se nonu) • :set ignorecase (:se ic) • :set noignorecase (:se noic) • :set showmatch (:se sm) • :set noshowmatch(:se nosm) • :set autoindent • :set noautoindent
  • 30. L2B Second Linux Course L2B Linux course  Configuring vi and vim  :help  :help something  :set • :set textwidth=3 • :set textwidth=0 • :set wrapmargin=10 • :set wrapmargin=0  ~/.vimrc  vimtutor
  • 31. L2B Second Linux Course L2B Linux course Basic System Configuration Tools
  • 32. L2B Second Linux Course L2B Linux course  Introduction  Network interfaces are named sequentially: eth0, eth1, etc  Multiple addresses can be assigned to a device with aliases  Aliases are labeled eth0:1, eth0:2, etc.  Aliases are treated like separate interfaces  View interface configuration with : ifconfig [ethX]  Enable interface with ifup ethX  Disable interface with ifdown ethX
  • 33. L2B Second Linux Course L2B Linux course  Graphical Network Configuration  system-config-network  System > Administration > Network  Network Configuration Files For Devices  /etc/sysconfig/network-scripts/ifcfg-ethX  Complete list of options in /usr/share/doc/initscripts-*/sysconfig.txt
  • 34. L2B Second Linux Course L2B Linux course  Example Of Dynamic Configuration  DEVICE=ethX  HWADDR=0:02:8A:A6:30:45  BOOTPROTO=dhcp  ONBOOT=yes  Type=Ethernet
  • 35. L2B Second Linux Course L2B Linux course  Example Of Static Configuration  DEVICE=ethX  HWADDR=0:02:8A:A6:30:45  IPADDR=192.168.0.254  NETMASK=255.255.255.0  GATEWAY=192.168.2.254  ONBOOT=yes  Type=Ethernet
  • 36. L2B Second Linux Course L2B Linux course  Network Configuration Files and Other Global Network Settings  /etc/sysconfig/network • NETWORKING=yes • HOSTNAME=server1.example.com • GATEWAY=192.168.2.254
  • 37. L2B Second Linux Course L2B Linux course  DNS configuration  Server address is specified by dhcp or in /etc/resolv.conf • nameserver 192.168.0.254 • nameserver 192.168.1.254
  • 38. L2B Second Linux Course L2B Linux course  Setting the System's Date and Time  GUI: • system-config-date • System->Administration->Date & Time  CLI: date [MMDDhhmm[[CC]YY][.ss]] • date 01011330 • Date 010113302007.05 • Date 12312359 • Date 123123592007 • Date 01010101.01
  • 39. L2B Second Linux Course L2B Linux course  Scripting  Taking input with positional parameters • $1 • $2 • $3 • $4, etc. • $* • $#
  • 40. L2B L2B Second Linux Course Second Linux L2B Linux course Course  Scripting  Taking input with the read command • read x • read -p "Enter a filename: " file
  • 41. For More info Please Visit Our Facebook Group