SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
Tarcisio Coutinho
16 Nov 2012
Dev-day
Linux - 101
Timeline
● 1965 :: MULTICS :: MTI, Bell Labs (AT&T) e General
Eletric
● 1969 :: Ken Thompson :: Unics (Assembly)
● 1971 :: Ken Thompson :: Rewrites the system on B
language (to solve portability problems)
● 1973 :: Thompson and Denis Richie :: C programming
language
● 1974 :: UNIX o/
● 1983 :: AT&T closes the UNIX's source code
● 1983 :: Andrew Tanenbaum :: MINIX
● 1984 :: Richard Stallman :: GNU (GCC, Emacs)
● 1991 :: Linux Torvalds :: GNU/Linux
GNU/Linux Distribution Timeline
http://futurist.se/gldt/
GNU/Linux
GNU/Linux Structure
Shell
What is Shell?
● Provides the command prompt and to interpret
commands
● Provides user interface for the OS and Kernel
Shell implementations
● bash (bourne again shell :: GNU implementation)
● ash (Almquist Shell :: BSD)
● csh (C shell :: BSD)
● tcsh (tee-shell)
● sh (Stephen Bourne)
● ksh (Korn shell)
Shell Variable Basics
● bash maintains a set of shell variables
○ PS1 :: Prompt String 1 :: Default interaction
○ PS2 :: Prompt String 1 :: Continuation interactive
prompt
○ PATH :: contains a list of all the directories that
hold commands or other programs you are likely to
execute
● bash variables are untyped
Export Variables
● When a variable is exported to the environment, it is
passed into the environment of all child processes
● let's go to the terminal
○ REDU="Redu Tech"
■ conventionally uppercase
○ echo $REDU or echo ${REDU}
■ $ prefix to interpret a shell var
○ echo "echo $REDU" | bash
Fun with PS1 :: Information
● u - Username
● h - Hostname
● w - Full path of the current woking directory
export PS1="u@h w"
export PS1="u@redu: w "
Fun with PS1 :: Colors
● e[ :: indicates the beginning of color
● x;ym :: indicates color code
● e[m :: indicates end of color prompt
White 1;37
Green 1;32
Cyan 1;36
Yellow 1;33
PS1="e[01;32mue[m@redu: w "
PS1="e[01;32mue[me[1;37m@e
[mredu: w "
PS1="e[01;32mue[me[1;37m@e
[me[1;36mredu:e[m w "
PS1="e[01;32mue[me[1;37m@e
[me[1;36mredu:e[me[1;33mwe
[m "
Streams, Pipes
and Redirects
Streams
● Everything is a file.
○ a program reading from the terminal’s device file
will receive characters typed at the keyboard
● When a program is launched, it is automatically
provided with three file descriptors
○ Standard input (abbreviated stdin) :: 0
○ Standard output (abbreviated stdout) :: 1
○ Standard error (abbreviated stderr) :: 2
● The standard input is different than parameters
Pipes and Redirects
● Pipes |
○ provides communication inter-process
■ tie the output of one program to the input of
another
■ e.g. echo "echo 'Hello Redu'" | bash
● Redirection
○ allows you to manage the origin of input streams
and the destination of output streams
■ > :: Redirection operator
■ >> :: Append operator
■ < :: Receive stdin from file
GNU and Unix
Commands
Tricks
● cd - :: go to the recent directory
○ Works with git branches
■ git checkout -
● !! :: call most recent command
○ bang-bang
● $( ) :: Command substitution or sub-shell
○ cd $(pwd)/..
GNU and Unix
sed & awk
Sed
● Stream based processing text editor
echo "sed tutorial. sed is a powerful text editor" |
sed 's/sed/awk/'
echo "sed tutorial. sed is a powerful text editor" |
sed 's/sed/awk/g'
echo "sed tutorial. sed is a powerful text editor" |
sed 's/sed/awk/2g'
Sed
echo "line without numbers nline with numbers: 1 2 3 " |
sed -r 's/[0-9]+/X/g'
echo "line without numbers nline with numbers: 1 2 3 " |
sed -rn 's/[0-9]+/X/g'
echo "line without numbers nline with numbers: 1 2 3 " |
sed -rn 's/[0-9]+/X/gp'
Sed
● Delete lines
○ sed '1,2-3 d' [FILE]
○ sed '/[pattern]/d [FILE]
○ sed -i '1 d' [FILE]
● Add lines
○ sed '/[pattern]/ i [text]' [FILE]
○ sed '/[pattern]/ a [text]' [FILE]
○ sed "1s/^/[text]" [FILE]
Awk
● AWK
○ processing text programming language
■ column based
awk -F [pattern] '{ [CMD] }'
$n -> variable from split by pattern match
ls -l | awk -F ' ' '{print $0}'
Quests
Fun with Seds
● Parse rails logs
○ Request count development.log
○ Top 10 most slow compound log job
grep awk head wc
uniq sort tail sed 'N;'
sed cut nl expand
tr
Dev-day
Linux - 101

Weitere ähnliche Inhalte

Was ist angesagt?

ncurses in your hobostove
ncurses in your hobostovencurses in your hobostove
ncurses in your hobostove
SmartLogic
 
Trip itparsing
Trip itparsingTrip itparsing
Trip itparsing
CapIpad
 

Was ist angesagt? (19)

Ssh
SshSsh
Ssh
 
bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018bpftrace - Tracing Summit 2018
bpftrace - Tracing Summit 2018
 
Code Smart - Makefile (special release)
Code Smart - Makefile (special release)Code Smart - Makefile (special release)
Code Smart - Makefile (special release)
 
FSE 2008
FSE 2008FSE 2008
FSE 2008
 
IPython from 30,000 feet
IPython from 30,000 feetIPython from 30,000 feet
IPython from 30,000 feet
 
ncurses in your hobostove
ncurses in your hobostovencurses in your hobostove
ncurses in your hobostove
 
Unix command quickref
Unix command quickrefUnix command quickref
Unix command quickref
 
Cryptography : From Demaratus to RSA
Cryptography : From Demaratus to RSACryptography : From Demaratus to RSA
Cryptography : From Demaratus to RSA
 
Trip itparsing
Trip itparsingTrip itparsing
Trip itparsing
 
MFC Menu
MFC MenuMFC Menu
MFC Menu
 
Jose dossantos.doc
Jose dossantos.docJose dossantos.doc
Jose dossantos.doc
 
関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方関西Vim勉強会#5 vimrcの書き方
関西Vim勉強会#5 vimrcの書き方
 
Class & sub class
Class & sub classClass & sub class
Class & sub class
 
Graphics 32 bit
Graphics 32 bitGraphics 32 bit
Graphics 32 bit
 
Doubly linklist
Doubly linklistDoubly linklist
Doubly linklist
 
Code
CodeCode
Code
 
Script
ScriptScript
Script
 
Golang勉強会
Golang勉強会Golang勉強会
Golang勉強会
 
Linux for Beginners
Linux for  BeginnersLinux for  Beginners
Linux for Beginners
 

Ähnlich wie Dev day linux redu

101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
Acácio Oliveira
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
root_fibo
 
Unix fundamentals and_shell scripting
Unix fundamentals and_shell scriptingUnix fundamentals and_shell scripting
Unix fundamentals and_shell scripting
Ganesh Bhosale
 

Ähnlich wie Dev day linux redu (20)

Unix Ramblings
Unix RamblingsUnix Ramblings
Unix Ramblings
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
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
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one liners
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
lect01.ppt
lect01.pptlect01.ppt
lect01.ppt
 
Terminals and Shells
Terminals and ShellsTerminals and Shells
Terminals and Shells
 
Linux tech talk
Linux tech talkLinux tech talk
Linux tech talk
 
Mac OSX Terminal 101
Mac OSX Terminal 101Mac OSX Terminal 101
Mac OSX Terminal 101
 
101 3.1 gnu and unix commands
101 3.1 gnu and unix commands101 3.1 gnu and unix commands
101 3.1 gnu and unix commands
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
 
Getting started with the Terminal
Getting started with the TerminalGetting started with the Terminal
Getting started with the Terminal
 
01 linux basics
01 linux basics01 linux basics
01 linux basics
 
10.8.2018
10.8.201810.8.2018
10.8.2018
 
01_linux_basics.ppt
01_linux_basics.ppt01_linux_basics.ppt
01_linux_basics.ppt
 
Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3
 
Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 
Linuxcommands 091018105536-phpapp01
Linuxcommands 091018105536-phpapp01Linuxcommands 091018105536-phpapp01
Linuxcommands 091018105536-phpapp01
 
Unix fundamentals and_shell scripting
Unix fundamentals and_shell scriptingUnix fundamentals and_shell scripting
Unix fundamentals and_shell scripting
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 

Dev day linux redu

  • 1. Tarcisio Coutinho 16 Nov 2012 Dev-day Linux - 101
  • 2. Timeline ● 1965 :: MULTICS :: MTI, Bell Labs (AT&T) e General Eletric ● 1969 :: Ken Thompson :: Unics (Assembly) ● 1971 :: Ken Thompson :: Rewrites the system on B language (to solve portability problems) ● 1973 :: Thompson and Denis Richie :: C programming language ● 1974 :: UNIX o/ ● 1983 :: AT&T closes the UNIX's source code ● 1983 :: Andrew Tanenbaum :: MINIX ● 1984 :: Richard Stallman :: GNU (GCC, Emacs) ● 1991 :: Linux Torvalds :: GNU/Linux
  • 7. What is Shell? ● Provides the command prompt and to interpret commands ● Provides user interface for the OS and Kernel
  • 8. Shell implementations ● bash (bourne again shell :: GNU implementation) ● ash (Almquist Shell :: BSD) ● csh (C shell :: BSD) ● tcsh (tee-shell) ● sh (Stephen Bourne) ● ksh (Korn shell)
  • 9. Shell Variable Basics ● bash maintains a set of shell variables ○ PS1 :: Prompt String 1 :: Default interaction ○ PS2 :: Prompt String 1 :: Continuation interactive prompt ○ PATH :: contains a list of all the directories that hold commands or other programs you are likely to execute ● bash variables are untyped
  • 10. Export Variables ● When a variable is exported to the environment, it is passed into the environment of all child processes ● let's go to the terminal ○ REDU="Redu Tech" ■ conventionally uppercase ○ echo $REDU or echo ${REDU} ■ $ prefix to interpret a shell var ○ echo "echo $REDU" | bash
  • 11. Fun with PS1 :: Information ● u - Username ● h - Hostname ● w - Full path of the current woking directory
  • 14. Fun with PS1 :: Colors ● e[ :: indicates the beginning of color ● x;ym :: indicates color code ● e[m :: indicates end of color prompt White 1;37 Green 1;32 Cyan 1;36 Yellow 1;33
  • 20. Streams ● Everything is a file. ○ a program reading from the terminal’s device file will receive characters typed at the keyboard ● When a program is launched, it is automatically provided with three file descriptors ○ Standard input (abbreviated stdin) :: 0 ○ Standard output (abbreviated stdout) :: 1 ○ Standard error (abbreviated stderr) :: 2 ● The standard input is different than parameters
  • 21. Pipes and Redirects ● Pipes | ○ provides communication inter-process ■ tie the output of one program to the input of another ■ e.g. echo "echo 'Hello Redu'" | bash ● Redirection ○ allows you to manage the origin of input streams and the destination of output streams ■ > :: Redirection operator ■ >> :: Append operator ■ < :: Receive stdin from file
  • 23. Tricks ● cd - :: go to the recent directory ○ Works with git branches ■ git checkout - ● !! :: call most recent command ○ bang-bang ● $( ) :: Command substitution or sub-shell ○ cd $(pwd)/..
  • 25. Sed ● Stream based processing text editor echo "sed tutorial. sed is a powerful text editor" | sed 's/sed/awk/' echo "sed tutorial. sed is a powerful text editor" | sed 's/sed/awk/g' echo "sed tutorial. sed is a powerful text editor" | sed 's/sed/awk/2g'
  • 26. Sed echo "line without numbers nline with numbers: 1 2 3 " | sed -r 's/[0-9]+/X/g' echo "line without numbers nline with numbers: 1 2 3 " | sed -rn 's/[0-9]+/X/g' echo "line without numbers nline with numbers: 1 2 3 " | sed -rn 's/[0-9]+/X/gp'
  • 27. Sed ● Delete lines ○ sed '1,2-3 d' [FILE] ○ sed '/[pattern]/d [FILE] ○ sed -i '1 d' [FILE] ● Add lines ○ sed '/[pattern]/ i [text]' [FILE] ○ sed '/[pattern]/ a [text]' [FILE] ○ sed "1s/^/[text]" [FILE]
  • 28. Awk ● AWK ○ processing text programming language ■ column based awk -F [pattern] '{ [CMD] }' $n -> variable from split by pattern match ls -l | awk -F ' ' '{print $0}'
  • 30. Fun with Seds ● Parse rails logs ○ Request count development.log ○ Top 10 most slow compound log job grep awk head wc uniq sort tail sed 'N;' sed cut nl expand tr