“tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install...

48
“tmux” ir “GNU Screen” Į nuotolinį serverį jungiamės patogiau! Sergej Kurakin

Transcript of “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install...

Page 1: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

“tmux” ir “GNU Screen”Į nuotolinį serverį jungiamės patogiau!

Sergej Kurakin

Page 2: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Sergej KurakinAmžius: 36

Dirbu: NFQ Technologies

Pareigos: Programuotojas

Page 3: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Mes visi tai darome.

Page 4: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Ir darome kelis kartus per dieną.

Page 5: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Jungiamės į nuotolinį serverį per Internetą naudodami SSH.

Page 7: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Ir tenka paleisti kokį procesą, kuris veikia ilgiau nei akimirką.

Page 8: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Gerokai ilgiau nei akimirka:

● 1 sekundė● 5 minutės● 15 minučių● 1 valanda● 6 valandos● 1 para● Ilgiau?

Page 9: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

O kas tai?

● Kodo derinimas.● Failų kopijavimas iš disko į diską.● Failų kopijavimas per tinklą (su sftp, scp, rsync).● Archyvavimas (tar, gzip, bzip2).● Duomenų atsarginių kopijų darymas ar atstatymas (dump, import).

Page 10: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Ir sėkmingam rezultatui gali trukdyti daug išorės veiksnių.

Page 11: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Net esant tokiai situacijai

Image from http://techwiser.com/how-to-connect-pc-to-pc-lan-cable/

Page 12: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Gali būti blogai “apspaustas” LAN kabelis

Image from https://mysku.ru/blog/aliexpress/34487.html

Page 13: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Nestabilus bevielis ryšys

Image from https://en.wikipedia.org/wiki/Duga_radar

Page 14: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Kažkas atlieka tinklo darbus● Tinklo administratoriai

○ Tvarko tinką○ Perkrauną įrangą○ Keičia konfiguraciją

● Interneto tiekėjas

Image from http://smb.ixbt.com/articles/tehnologii-i-produkty/2016-03-20/organizacija-seti

Page 15: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Magistralinio tinklo gedimai

Page 16: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Ugniasienės ar apsaugos sprendimai nutraukinėja ilgesnius prisijungimus.

Page 17: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

O kartais tiesiog norisi pakeisti fizinę lokaciją.

Page 18: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Tęsti pradėtus darbus iš sėdmaišio, hamako ar lauko terasos.

Page 19: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Ir neprarąsti nei vieno jau paleisto proceso.

Page 20: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Trumpai tariant - Interneto ryšys dings.

Page 21: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Kartu su juo bus nutraukta SSH sesija.

Page 22: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Jūsų paleisti procesai bus “nužudyti”.

Page 23: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Image from http://imgur.com/3Ux1HFF

Page 24: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Kažkas iš karto pagalvos apie “nohup”

Page 25: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Bet, tai nėra taip patogu, kaip...

Page 26: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Terminal multiplexer

Page 27: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Terminal multiplexer

● Dauginis kelių virtualių konsolių paleidimas● Vartotojas gali prieiti kelias skirtingas prisijungimo sesijas

viename terminalo lange● Atjungi ir prijungti sesiją prie terminalo lango

Page 28: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Terminal multiplexer

Naudingas jei reikia dirbti su keliomis programomis per terminalą.

Naudinga jei reikia kad programa veiktų vartotojui atsijungus.

Page 29: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Terminal multiplexer

tmuxPradėtas kurti: 2007; (9 metai)

Kalba: C (Si)

Licencija: ISC license

GNU ScreenPradėtas kurti: 1987; (30 metų)

Kalba: C (Si)

Licencija: GNU GPL v3

Page 30: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Diegimas

tmux

# apt-get install tmux

# yum install tmux

GNU Screen

# apt-get install screen

# yum install screen

Gali tekti panaudoti trečiųjų šalių repozitorijas. Orientuokitės į tai, kas yra Jūsų Linux distribucijoje arba ką rekomenduoja Jūsų sistemų administratoriai.

Page 31: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Paleidimas

tmux

$ tmux

GNU Screen

$ screen

Page 32: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Paleiskime kokį ilgą procesą ir nutraukime SSH sesiją.

Page 33: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

O dabar vėl prisijunkime

tmux

$ tmux

$ tmux ls

$ tmux attach

GNU Screen

$ screen

$ screen -list

$ screen -r

Page 34: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Atsijungti nuo SSH, bet palikti procesus veikiančius

tmux

Ctrl+b d

GNU Screen

Ctrl+a d

Page 35: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Noriu paleisti daugiau programų

tmux

Ctrl+b c

Ctrl+b n

Ctrl+b p

GNU Screen

Ctrl+a c

Ctrl+a n

Ctrl+a p

Page 36: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Pasirinkti langą

tmux

Ctrl+b w

GNU Screen

Ctrl+a “

Page 37: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Pervadinti langą

tmux

Ctrl+b ,

GNU Screen

Ctrl+a A

Page 38: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Uždaryti langą

tmux

Ctrl+d

GNU Screen

Ctrl+d

Page 39: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Uždaryti langą (kill)

tmux

Ctrl+b &

GNU Screen

Ctrl+a Ctrl+k

Page 40: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Image from https://thenextweb.com/media/2012/06/02/jayse-hansen-on-creating-tools-the-avengers-use-to-fight-evil-touch-interfaces-and-project-glass/

Page 41: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Vertikalus suskaldymas (top, bottom)

tmux

Ctrl+b “

GNU Screen

Ctrl+a S

Page 42: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Horizontalus suskaldymas (left, right)

tmux

Ctrl+b %

GNU Screen* jei veikia

Ctrl+a |

Page 43: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Navigacija suskaldžius

tmux

Ctrl+b <top>

Ctrl+b <bottom>

Ctrl+b <left>

Ctrl+b <right>

GNU Screen

Ctrl+a <tab>

Page 44: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų
Page 45: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Bet tai tik aisbergo viršūnė

Image from http://www.wikiwand.com/ms/Aisberg

Page 46: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

Keli panaudojimo pavyzdžiaiPrograminės įrangos diegimas ir konfigūravimas.

PHP “background” procesų testavimas.

Node.js aplikacijų rašymas ir derinimas.

Didesnio MySQL “dump” importas.

Vagrant + AWS.

Page 48: “tmux” ir “GNU Screen” - · PDF fileDiegimas tmux # apt-get install tmux # yum install tmux GNU Screen # apt-get install screen # yum install screen Gali tekti panaudoti trečiųjų

DiskusijaSergej Kurakin

Darbo @paštas: [email protected]

Asmeninis @paštas: [email protected]

https://www.linkedin.com/in/sergejkurakin