cle
play

CLE Command Live Environment Michael Arbet November 2019 AGENDA - PowerPoint PPT Presentation

CLE Command Live Environment Michael Arbet November 2019 AGENDA Command Line Environment What, Why, for Who What CLE does, What are its purpose and benefjts Living with CLE Installation, confjguration, usage The magic inside Priciples,


  1. CLE Command Live Environment Michael Arbet November 2019

  2. AGENDA Command Line Environment What, Why, for Who What CLE does, What are its purpose and benefjts Living with CLE Installation, confjguration, usage The magic inside Priciples, variables, tweaks 2 CLE 11/2018

  3. What, Why & for Who ”Thou shalt have no other shells before bash” 3 CLE 11/2018

  4. What CLE provides Colorful prompt! Distinguish commands and outputs Alias management Have important information visible Define and remember aliases Create your own style Edit your alias set Live sessions Seamless login with the same environment without installation No harm to default settings Multi-admin environment Open framework Options to add custom features Rich history Self documented More information about your work All in one compact script Endless and easy to search 4 CLE 11/2018

  5. Alternatives 2. 'powerline' 1. Your own .bashrc / .zshrc Nice, well known solution You know what is there Huge complicated python scripts behind Need to edit the file, relogin Running daemon! (for just cmdline...) Required to be added on each new Requires installation on destination boxes account 3. 'sshrc' Partially solves seamless transfer Yes this one inspired me! 5 CLE 11/2018

  6. Who can benefjt from CLE ● Administrators , accessing a lot of servers * ● Support engineers creating reproducers ● Developers ● ... anybody using command line daily *) more users access the same root account with individual settings! Why this all? ● Install once, use anywhere ● Easy configuration without reload ● Lazy admin's live becomes more comfortable 6 CLE 11/2018

  7. Living with CLE “Remember the sabbath outage day, to keep it holy” 7 CLE 11/2018

  8. Start Exercise #1 : download & run Main source: http://raw.githubusercontent.com/micharbet/CLE/master/clerc • Easy going: https://git.io/clerc • $ w g e t h t t p : / / g i t . i o / c l e r c $ . c l e r c $ c l e d e p l o y 8 CLE 11/2018

  9. First aid kit You will never walk alone! CLE employs TAB autocompletion CLE is documented, use following ways to learn more: Quick help (strings inside the script) or c • c l e h e l p l e - h Thorough documentation (download) • c l e d o c 9 CLE 11/2018

  10. Prompting [0] 12:15 fool stalker.usersys ~ $ _ CLE_P2 CLE_P0 CLE_P1 CLE_P3 Shortened hostname Return code + time Username Working dierctory ‘^h’ ‘^E \A’ ‘\u’ ‘\w \$’ Exercise #2: setup prompt colors c l e c o l o r Use predefined scheme or try your own c l e c o l o r g r e e n combinations. c l e c o l o r R g B c l e c o l o r C g G Y 10 CLE 11/2018

  11. Prompting Exercise #3: setup your prompt strings c l e t i m e o ff Note: distinguish between c l e p 1 ' \ u @ ^ h ' bash sequences e.g. ‘\u’ c l e p 2 ' $ V A R I A B L E \ n ' and CLE additions introduced with caret sign c l e p 2 ' ^ c M ^ v V A R I A B L E ' e.g. ‘^h’ c l e p 2 ' d a t e $ ( d a t e ) ' c l e p 3 ' \ w : ^ g \ $ ' Pro tips: - use TAB completion to get current parts definitions - find more escape sequences using cle doc 11 CLE 11/2018

  12. Live sessions CLE can pass itself over remote login and su* Exercise #4: Use lssh instead of ssh CLE Workstation [0] fool ws ~ $ lssh root@srv1 ( CLE packs itself, transfers through ssh and runs) s r v 1 [0] me-root srv1 ~ # lssh virtual v i r t u a l [0] me-root virtual ~ # _ 12 INSERT DESIGNATOR, IF NEEDED

  13. Live sessions CLE can pass itself over remote login and su* Exercise #5: Use lsu, lsudo or lksu CLE Workstation [0] fool ws ~ $ lssh srv1 ( CLE packs itself, transfers through ssh and runs) f o o l @ r o o t @ [0] fool srv1 ~ # lksu s r v 1 s r v 1 [0] me-root srv1 ~ # _ Note: Regular ‘ssh’ and ‘su*’ commands will behave normally, like if CLE does’t exist 13 INSERT DESIGNATOR, IF NEEDED

  14. CLE in screen Use command l to start CLE session in GNU screen s c r e e n Features: Customized confjguration • Automatic rejoin detached screens • Easier screen sharing • Exercise #6: work with l s c r e e n Open more shells <ctrl-A><ctrl-C> • Do something (e.g. ‘ls’) • Switch windows with <ctrl-Left/Right> • Detach screen session <ctrl-A><ctrl-D> • Start over, just type ‘ l ’ • s c r e e n 14 CLE 11/2018

  15. Work with aliases Exercise #7: use command aa Defjne new alias, watch the alias set a a a a t l g = ' t a i l - f / v a r / l o g / m e s s a g e s Open new session, new aliases are there! a a a a - e (you can edit your aliases!) 15 CLE 11/2018

  16. Rich history Basic history usage using h h h (known bash colored history) h h (this is the rich history) h h 1 5 (recent 15 entries) h h g a m . * g r o u p (use regexp) Timestamp session secs rc dir command 2018-08-02 11:02:14 mich-8300 15 2 ~/gam-rh gam add group cpq-development-team 2018-08-02 11:02:30 mich-8300 2 0 ~/gam-rh gam create group cpq-development-team 2018-08-02 11:02:37 mich-8300 2 0 ~/gam-rh gam create group clm-development-team Did you know shell's < to C t r l - R > interactive search through history? 16 CLE 11/2018

  17. Rich history Advanced searches h h - d g r e p (all today’s greps) h h - s h h - t s c (see only successful commands issued in this terminal) h h - d s c (guess the difference) h h - f 5 0 0 (folder history within recent 500 commands) Exercise #8: inspect rich history over multiple sessions • Open live session on the same account and watch history • records of other users Use ‘ cle help hh ’ to see all rich history options 17 CLE 11/2018

  18. The magic inside “Thou shalt not steal unless it is open source” 18 CLE 11/2018

  19. How CLE works Resource file lives in separate folder $ H O M E / . c l e - y o u r n a m e • Hooked into . with command c $ { C L E _ S H } r c ( l e d e p l o y ) • All in one file, including basic documentation • Defines bash functions – to be executed in context of current shell • process Seamless live sessions use t and b encoding to pass CLE a r a s e 6 4 • files to remote hosts Self-contained documentation uses '##' double-hash to denote • comments worth to print out using ' c ' l e h e l p 19 CLE 11/2018

  20. Internal variables Variable Purpose C L E _ U S E R Username from fjrst login on CLE workstation, inherited over all live sessions. Most important variable used to name cle fjles C L E _ R C Full path to the resource fjle itself C L E _ T W Relative path to tweak fjle C L E _ D Directory with working fjles (confjguration and more) C L E _ C F Confjguration fjle C L E _ C L R Color scheme, related command ‘cle color’ C L E _ P x ( x = 0 . . 3 ) Prompt parts defjnitions, related commands ‘cle p1..p3’ _ C x Color table, e.g. $ contains escape code for red _ C r Issue ' c ' to inspect all variables l e e n v Use ‘ c ’ and chose file H to read more l e d o c O W T O . m d 20 CLE 11/2018

  21. Files File/folder Purpose $ H O M E / . c l e - $ C L E _ U S E R Here is almost all that CLE needs. Other mentioned fjles are related to this directory ($CLE_D) … r c Resource fjle with the environment itself ($CLE_RC) … c f Confjguration fjle ($CLE_CF) … t w T weak fjle ($CLE_TW) … a l i a s e s Locally defjned aliases $ H O M E / . h i s t o r y - A L L Rich history fjle $ H O M E / . h i s t o r y - $ C L E _ U S E R User’s personal history (replaces .bash_history) Inspect file H using ‘ c ’ to read more O W T O . m d l e d o c 21 CLE 11/2018

  22. T weaks and modules Make it yours! Try not to edit CLE resource file itself. Instead submit bugs or feature • requests on Github Place following code into your $ : H O M E / . c l e - $ C L E _ U S E R / t w • # # t t h h i i s s i i s s m m y y C C L L E E t t w w e e a a k k e e c c h h o o W W e e l l c c o o m m e e $ $ C C L L E E _ _ U U S S E E R R a a s s $ $ U U S S E E R R a a t t $ $ ( ( h h o o s s t t n n a a m m e e - - f f ) ) # # Y Y e e l l l l o o w w e e r r r r o o r r c c o o d d e e _ _ C C e e = = $ $ _ _ C C Y Y Use ‘ c ’ to enhance functionality, e.g.: l e m o d c l e m o d a d d p r o m p t c l e p r o m p t t r i l i n e r Using ‘ c ’ inspect following files: l e d o c TipsAndTweaks.md Modularity.md 22 CLE 11/2018

  23. Go deeper, have fun Review the script! Check how things are coded • Close look at use of variable $ – how it is created then C L E _ U S E R • inherited over sessions and how it ensures multi-admin environment. See comments, esp. Self-documentation • Note, it might be sometimes not easy to read, code is quite dense, • heavily using regular expressions, etc... Exercise #9: find Easter Egg! ● It's there! ● Uses function ' c l e ' 23 CLE 11/2018

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend