CLE
Command Live Environment
Michael Arbet November 2019
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,
Command Live Environment
Michael Arbet November 2019
CLE 11/2018 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
CLE 11/2018 3
”Thou shalt have no other shells before bash”
CLE 11/2018 4
Colorful prompt!
Distinguish commands and outputs Have important information visible Create your own style
Alias management
Define and remember aliases Edit your alias set
Rich history
More information about your work Endless and easy to search
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 Self documented All in one compact script
CLE 11/2018 5
Alternatives
You know what is there Need to edit the file, relogin Required to be added on each new account
Nice, well known solution Huge complicated python scripts behind Running daemon! (for just cmdline...) Requires installation on destination boxes
Partially solves seamless transfer Yes this one inspired me!
CLE 11/2018 6
Who can benefjt from CLE
*) more users access the same root account with individual settings!
Why this all?
CLE 11/2018 7
“Remember the sabbath outage day, to keep it holy”
CLE 11/2018 8
Start
http://raw.githubusercontent.com/micharbet/CLE/master/clerc
https://git.io/clerc
$ w g e t h t t p : / / g i t . i
c l e r c $ . c l e r c $ c l e d e p l
Exercise #1: download & run
CLE 11/2018 9
First aid kit
CLE employs TAB autocompletion CLE is documented, use following ways to learn more:
c l e h e l p
l e
c l e d
You will never walk alone!
CLE 11/2018 10
Prompting [0] 12:15 fool stalker.usersys ~ $ _
CLE_P1 Username ‘\u’ CLE_P3 Working dierctory ‘\w \$’ CLE_P2 Shortened hostname ‘^h’ CLE_P0 Return code + time ‘^E \A’
Exercise #2: setup prompt colors c l e c
c l e c
g r e e n c l e c
R g B c l e c
C g G Y
Use predefined scheme or try your own combinations.
CLE 11/2018 11
Prompting
Exercise #3: setup your prompt strings c l e t i m e
c l e p 1 ' \ u @ ^ h ' c l e p 2 ' $ V A R I A B L E \ n ' c l e p 2 ' ^ c M ^ v V A R I A B L E ' c l e p 2 ' d a t e $ ( d a t e ) ' c l e p 3 ' \ w : ^ g \ $ '
Pro tips:
Note: distinguish between bash sequences e.g. ‘\u’ and CLE additions introduced with caret sign e.g. ‘^h’
INSERT DESIGNATOR, IF NEEDED 12
Live sessions
CLE can pass itself over remote login and su*
Exercise #4: Use lssh instead of ssh
CLE Workstation
s r v 1
[0] fool ws ~ $ lssh root@srv1 (CLE packs itself, transfers through ssh and runs) [0] me-root srv1 ~ # lssh virtual [0] me-root virtual ~ # _
v i r t u a l
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) [0] fool srv1 ~ # lksu [0] me-root srv1 ~ # _
r
@ s r v 1 f
@ s r v 1
Note: Regular ‘ssh’ and ‘su*’ commands will behave normally, like if CLE does’t exist
CLE 11/2018 14
CLE in screen
Use command l s c r e e n to start CLE session in GNU screen Features:
Exercise #6: work with l s c r e e n
s c r e e n ’
CLE 11/2018 15
Work with aliases
a a a a t l g = ' t a i l
/ v a r / l
/ m e s s a g e s
Exercise #7: use command aa
Open new session, new aliases are there!
a a a a
(you can edit your aliases!)
Defjne new alias, watch the alias set
CLE 11/2018 16
Rich history
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
Timestamp session secs rc dir command
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
p
(use regexp)
Basic history usage using h h
Did you know shell's < C t r l
> to interactive search through history?
CLE 11/2018 17
Rich history
Advanced searches
h h
g r e p
(all today’s greps)
h h
h h
s c
(see only successful commands issued in this terminal)
h h
s c
(guess the difference)
h h
5
(folder history within recent 500 commands)
Use ‘cle help hh’ to see all rich history
Exercise #8:
records of other users
CLE 11/2018 18
“Thou shalt not steal unless it is open source”
CLE 11/2018 19
How CLE works
H O M E / . c l e
r n a m e
$ { C L E _ S H } r c ( with command c l e d e p l
)
process
a r and b a s e 6 4 encoding to pass CLE files to remote hosts
comments worth to print out using 'c l e h e l p '
CLE 11/2018 20
Internal variables
Issue 'c l e e n v ' to inspect all variables Use ‘c l e d
’ and chose file H O W T O . m d to read more
Variable Purpose C L E _ U S E R Username from fjrst login on CLE workstation, inherited
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 = . . 3 ) Prompt parts defjnitions, related commands ‘cle p1..p3’ _ C x Color table, e.g. $ _ C r contains escape code for red
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
y
L L Rich history fjle $ H O M E / . h i s t
y
C L E _ U S E R User’s personal history (replaces .bash_history)
Inspect file H O W T O . m d using ‘c l e d
’ to read more
CLE 11/2018 22
T weaks and modules
# t h i s i s m y C L E t w e a k e c h
e l c
e $ C L E _ U S E R a s $ U S E R a t $ ( h
t n a m e
) # Y e l l
e r r
c
e _ C e = $ _ C Y
Using ‘c l e d
’ inspect following files: TipsAndTweaks.md Modularity.md
requests on Github
H O M E / . c l e
C L E _ U S E R / t w :
Make it yours!
Use ‘c l e m
’ to enhance functionality, e.g.: c l e m
a d d p r
p t c l e p r
p t t r i l i n e r # t h i s i s m y C L E t w e a k e c h
e l c
e $ C L E _ U S E R a s $ U S E R a t $ ( h
t n a m e
) # Y e l l
e r r
c
e _ C e = $ _ C Y
CLE 11/2018 23
Go deeper, have fun
C L E _ U S E R – how it is created then inherited over sessions and how it ensures multi-admin environment.
heavily using regular expressions, etc...
Exercise #9: find Easter Egg!
c l e '
Review the script!
“Make love, not core dumps!” The creator: micharbet@gmail.com The project: https://github.com/micharbet/CLE