Tarcisio Coutinho16 Nov 2012Dev-dayLinux - 101
Timeline● 1965 :: MULTICS :: MTI, Bell Labs (AT&T) e GeneralEletric● 1969 :: Ken Thompson :: Unics (Assembly)● 1971 :: Ken...
GNU/Linux Distribution Timelinehttp://futurist.se/gldt/
GNU/Linux
GNU/Linux Structure
Shell
What is Shell?● Provides the command prompt and to interpretcommands● Provides user interface for the OS and Kernel
Shell implementations● bash (bourne again shell :: GNU implementation)● ash (Almquist Shell :: BSD)● csh (C shell :: BSD)●...
Shell Variable Basics● bash maintains a set of shell variables○ PS1 :: Prompt String 1 :: Default interaction○ PS2 :: Prom...
Export Variables● When a variable is exported to the environment, it ispassed into the environment of all child processes●...
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 colo...
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, Pipesand Redirects
Streams● Everything is a file.○ a program reading from the terminal’s device filewill receive characters typed at the keyb...
Pipes and Redirects● Pipes |○ provides communication inter-process■ tie the output of one program to the input ofanother■ ...
GNU and UnixCommands
Tricks● cd - :: go to the recent directory○ Works with git branches■ git checkout -● !! :: call most recent command○ bang-...
GNU and Unixsed & awk
Sed● Stream based processing text editorecho "sed tutorial. sed is a powerful text editor" |sed s/sed/awk/echo "sed tutori...
Sedecho "line without numbers nline with numbers: 1 2 3 " |sed -r s/[0-9]+/X/gecho "line without numbers nline with number...
Sed● Delete lines○ sed 1,2-3 d [FILE]○ sed /[pattern]/d [FILE]○ sed -i 1 d [FILE]● Add lines○ sed /[pattern]/ i [text] [FI...
Awk● AWK○ processing text programming language■ column basedawk -F [pattern] { [CMD] }$n -> variable from split by pattern...
Quests
Fun with Seds● Parse rails logs○ Request count development.log○ Top 10 most slow compound log jobgrep awk head wcuniq sort...
Dev-dayLinux - 101
Upcoming SlideShare
Loading in …5
×

Dev day linux redu

367 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
367
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Dev day linux redu

  1. 1. Tarcisio Coutinho16 Nov 2012Dev-dayLinux - 101
  2. 2. Timeline● 1965 :: MULTICS :: MTI, Bell Labs (AT&T) e GeneralEletric● 1969 :: Ken Thompson :: Unics (Assembly)● 1971 :: Ken Thompson :: Rewrites the system on Blanguage (to solve portability problems)● 1973 :: Thompson and Denis Richie :: C programminglanguage● 1974 :: UNIX o/● 1983 :: AT&T closes the UNIXs source code● 1983 :: Andrew Tanenbaum :: MINIX● 1984 :: Richard Stallman :: GNU (GCC, Emacs)● 1991 :: Linux Torvalds :: GNU/Linux
  3. 3. GNU/Linux Distribution Timelinehttp://futurist.se/gldt/
  4. 4. GNU/Linux
  5. 5. GNU/Linux Structure
  6. 6. Shell
  7. 7. What is Shell?● Provides the command prompt and to interpretcommands● Provides user interface for the OS and Kernel
  8. 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. 9. Shell Variable Basics● bash maintains a set of shell variables○ PS1 :: Prompt String 1 :: Default interaction○ PS2 :: Prompt String 1 :: Continuation interactiveprompt○ PATH :: contains a list of all the directories thathold commands or other programs you are likely toexecute● bash variables are untyped
  10. 10. Export Variables● When a variable is exported to the environment, it ispassed into the environment of all child processes● lets 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. 11. Fun with PS1 :: Information● u - Username● h - Hostname● w - Full path of the current woking directory
  12. 12. export PS1="u@h w"
  13. 13. export PS1="u@redu: w "
  14. 14. Fun with PS1 :: Colors● e[ :: indicates the beginning of color● x;ym :: indicates color code● e[m :: indicates end of color promptWhite 1;37Green 1;32Cyan 1;36Yellow 1;33
  15. 15. PS1="e[01;32mue[m@redu: w "
  16. 16. PS1="e[01;32mue[me[1;37m@e[mredu: w "
  17. 17. PS1="e[01;32mue[me[1;37m@e[me[1;36mredu:e[m w "
  18. 18. PS1="e[01;32mue[me[1;37m@e[me[1;36mredu:e[me[1;33mwe[m "
  19. 19. Streams, Pipesand Redirects
  20. 20. Streams● Everything is a file.○ a program reading from the terminal’s device filewill receive characters typed at the keyboard● When a program is launched, it is automaticallyprovided 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. 21. Pipes and Redirects● Pipes |○ provides communication inter-process■ tie the output of one program to the input ofanother■ e.g. echo "echo Hello Redu" | bash● Redirection○ allows you to manage the origin of input streamsand the destination of output streams■ > :: Redirection operator■ >> :: Append operator■ < :: Receive stdin from file
  22. 22. GNU and UnixCommands
  23. 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)/..
  24. 24. GNU and Unixsed & awk
  25. 25. Sed● Stream based processing text editorecho "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/gecho "sed tutorial. sed is a powerful text editor" |sed s/sed/awk/2g
  26. 26. Sedecho "line without numbers nline with numbers: 1 2 3 " |sed -r s/[0-9]+/X/gecho "line without numbers nline with numbers: 1 2 3 " |sed -rn s/[0-9]+/X/gecho "line without numbers nline with numbers: 1 2 3 " |sed -rn s/[0-9]+/X/gp
  27. 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. 28. Awk● AWK○ processing text programming language■ column basedawk -F [pattern] { [CMD] }$n -> variable from split by pattern matchls -l | awk -F {print $0}
  29. 29. Quests
  30. 30. Fun with Seds● Parse rails logs○ Request count development.log○ Top 10 most slow compound log jobgrep awk head wcuniq sort tail sed N;sed cut nl expandtr
  31. 31. Dev-dayLinux - 101

×