Menggunakan Perintah Screen di Linux

Menggunakan Perintah Screen di Linux - Halooo selamat siang semuanya. Pada kesempatan kali ini saya akan membahas mengenai perintah screen. Sepenting apakah screen sehingga kita harus tau ? Berikut pembahasannya.
Menurut manual dari screen sendiri inilah deskripsinya :

       When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the  program as  you  normally  would.  Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill existing windows, view a list of windows, turn output logging on and off, copy-and-paste text between windows, view the scrollback  history,  switch  between  windows  in whatever  manner  you  wish, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the user's terminal.  When a program terminates, screen (per  default)  kills  the window that contained it.  If this window was in the foreground, the display switches to the previous window; if none are left, screen exits.

       Everything  you type is sent to the program running in the current window.  The only exception to this is the one keystroke that is used to initiate a command to the window manager.  By default, each command begins with a control-a (abbreviated C-a from now on), and is followed by one other keystroke.   The  command character and all the key bindings can be fully customized to be anything you like, though they are always two characters in length.

Jadi Screen ini bisa dibilang lebih diperuntukkan bagi sysadmin atau system adminstrator. Gampangnya, screen ini bisa dugunakan untuk miltitasking. jadi misal kalian memasukkan perintah di screen 1, sambil menunggu proses tersebut selesai kalian bisa pindah ke screen 2 untuk compile sesuatu, pindah lagi ke screen 3 untuk install aplikasi misalnya.

Dan yang lebih diutamakan, screen ini akan terus terhubung sampai kalian menutupnya secara manual. Jadi misal lagi upgrade server dari koneksi ssh tiba tiba diskonek kan repot karena bisa saja malah server error. Nah dengan screen ini, meski tiba tiba koneksi ssh mu terputus proses upgrade yang ada di screen tetap berjalan.

Oke ke contohnya saja ya biar gak bingung.
Pertama install dulu screen di linux mu. gunakan apt untuk debian dan turunannya, yum untuk redhat dan centos.
apt-get install install screen
atau
yum install screen
Untuk melihat perintah screen yang bisa digunakan.
screen -h
Oke disini saya langsung kasih contoh saja biar gak ribet.
Disini saya akan membuat dua screen dan dua perintah berbeda di dalamnya.
Screen pertama saya kasih nama firefox, yang kedua saya kasih nama chrome. Ini contoh saya loh ya, untuk penamaannya bebas.
screen -R firefox
Selanjutnya masukkan perintah
apt install firefox -y
Tidak usah ditunggu, langsung tekan tombol
ctrl+a setelah itu c
Masukkan perintah
screen -R chrome
lalu 
apt-get install google-chrome-stable
Nah selanjutnya tekan
ctrl+a lalu d
Jadi perintah diatas adalah membuat screen firefox, lalu pindah ke screen berikutnya (ctrl+a c), buat screen chrome, lalu detach (ctrl+a d) untuk kembali ke terminal awal.
Untuk melihat daftar screen yang berjalan masukkan perintah
screen -list
Contoh output :
There are screens on:
7864.chrome (06/15/17 14:38:43) (Attached)
6352.firefox (06/15/17 14:30:45) (Detached)
Nah misal kita ingin kembali ke screen chrome, masukkan perintah :
screen -d chrome
Perintah ini untuk detach screen chrome karena statusnya masih attached. lalu resume screen chrome
screen -r chrome
Pokok kalo status screen nya masih attached, di detach dulu pakai perintah screen -d. Jika ingin keluar dari screen gimana ?
ctrl+a lalu k
Saat uncul pertanyaan Really kill this window?, tekan y, lalu enter.
Oke sekian tutorial kali ini, semoga bermanfaat. Jika ada yang kurang jelas bisa ditanyakan.

Posting Komentar untuk "Menggunakan Perintah Screen di Linux"