Bikin Dokumentasi atau Tutorial Sistem Linux Menggunakan Perintah Script

Hai semuanya, apa kabar? Kali ini saya mau nulis yang masih terkait dengan Linux.

Seorang SysAdmin seringkali perlu membuat dokumentasi dari apa yang ia kerjakan. Misalkan untuk keperluan catatan pekerjaan ataupun untuk laporan ke klien.

Untuk tampilan sistem dengan GUI mungkin masih bisa menggunakan screenshot. Namun bagaimana kalau sistem yang digunakan adalah full menggunakan CLI? Bagaimana kita bisa capture tampilan yang ada di Terminal?

Nah ada suatu perintah di Linux yang dapat digunakan, yaitu script. Saya juga baru tahu ini kemarin hehe. Awalnya saya kira -dari namanya- perintah ini adalah untuk membuat skrip untuk otomatisasi seperti crontab. Ternyata bukan.

Perintah script ini adalah suatu tool yang berfungsi untuk capture atau mengambil apapun yang terjadi pada terminal. Baik itu input, tampilan proses, hasil perintah atau output, maupun pesan galat (error) yang terjadi. Ibarat screen recording tapi versi CLI/teks.

Gimana cara pakainya?

Sintaksnya cukup mudah. Kita bisa gunakan perintah script [nama-file]. Misalnya, saya akan coba jalankan perintah script dan hasilnya akan disimpan pada file testing-perintah-script.txt

Untuk pengujian kali ini, saya akan coba untuk pasang NGINX. Oiya, untuk menghentikan perekaman skrip, kita bisa gunakan tombol Ctrl + D.

Berikut hasil “perekaman” dari script:

 

Panjang juga ya hehe. Tentu saja bisa kita sesuaikan untuk penulisan dokumentasi agar lebih rapi. Nah, demikian sekilas tentang perintah Script di Linux yang saya juga baru tahu. Gimana menurut teman-teman? Gampang atau susah nih penggunaannya?

Untuk tulisan kali ini sampai disini dulu ya. Sampai jumpa, bye~

Script started on 2024-07-24 10:15:54+07:00 [TERM="xterm-256color" TTY="/dev/pts/0" COLUMNS="82" LINES="22"]

[?2004h]0;phantom-zorin2@phantom-zorin: ~[01;32mphantom-zorin2@phantom-zorin[00m:[01;34m~[00m$ sudo apt install nginx

[?2004l

[sudo] password for phantom-zorin2:

Reading package lists... 0%

Reading package lists... 100%

Reading package lists... Done





Building dependency tree... 0%

Building dependency tree... 0%

Building dependency tree... 50%

Building dependency tree... 50%

Building dependency tree... Done





Reading state information... 0%

Reading state information... 0%

Reading state information... Done



The following packages were automatically installed and are no longer required:
python3-attr python3-docker python3-dockerpty python3-docopt python3-dotenv
python3-jsonschema python3-pyrsistent python3-texttable python3-websocket
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libnginx-mod-http-geoip2 libnginx-mod-http-image-filter
libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
libnginx-mod-stream-geoip2 nginx-common nginx-core
Suggested packages:
fcgiwrap nginx-doc
The following NEW packages will be installed:
libnginx-mod-http-geoip2 libnginx-mod-http-image-filter
libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
libnginx-mod-stream-geoip2 nginx nginx-common nginx-core
0 upgraded, 9 newly installed, 0 to remove and 242 not upgraded.
Need to get 697 kB of archives.
After this operation, 2.395 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
[33m
0% [Working][0m



Get:1 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 nginx-common all 1.18.0-6ubuntu14.4 [40,0 kB]

[33m

2% [1 nginx-common 14,2 kB/40,0 kB 35%][0m[33m

7% [Working][0m

Get:2 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-geoip2 amd64 1.18.0-6ubuntu14.4 [11,9 kB]
[33m
8% [2 libnginx-mod-http-geoip2 11,9 kB/11,9 kB 100%][0m[33m



0% [Waiting for headers][0m



Get:3 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-image-filter amd64 1.18.0-6ubuntu14.4 [15,4 kB]

[33m

12% [3 libnginx-mod-http-image-filter 15,4 kB/15,4 kB 100%][0m[33m
14% [Working][0m

Get:4 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-http-xslt-filter amd64 1.18.0-6ubuntu14.4 [13,7 kB]
[33m
16% [4 libnginx-mod-http-xslt-filter 13,7 kB/13,7 kB 100%][0m[33m

18% [Waiting for headers][0m

Get:5 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-mail amd64 1.18.0-6ubuntu14.4 [45,7 kB]
[33m
19% [5 libnginx-mod-mail 6.956 B/45,7 kB 15%][0m[33m

26% [Working][0m

Get:6 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-stream amd64 1.18.0-6ubuntu14.4 [72,9 kB]
[33m
26% [6 libnginx-mod-stream 2.635 B/72,9 kB 4%][0m[33m


36% [Working][0m
Get:7 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libnginx-mod-stream-geoip2 amd64 1.18.0-6ubuntu14.4 [10,1 kB]
[33m
36% [7 libnginx-mod-stream-geoip2 1.196 B/10,1 kB 12%][0m[33m

40% [Waiting for headers][0m

Get:8 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 nginx-core amd64 1.18.0-6ubuntu14.4 [484 kB]
[33m
41% [8 nginx-core 11,3 kB/484 kB 2%][0m[33m

97% [Waiting for headers][0m

Get:9 http://id.archive.ubuntu.com/ubuntu jammy-updates/main amd64 nginx amd64 1.18.0-6ubuntu14.4 [3.872 B]
[33m

100% [Working][0m

Fetched 697 kB in 0s (1.396 kB/s)
Preconfiguring packages ...


7[0;21r8[1ASelecting previously unselected package nginx-common.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 410576 files and directories currently installed.)
Preparing to unpack .../0-nginx-common_1.18.0-6ubuntu14.4_all.deb ...
7[22;0f[42m[30mProgress: [  0%][49m[39m [............................................................] 87[22;0f[42m[30mProgress: [  3%][49m[39m [#...........................................................] 8Unpacking nginx-common (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [  5%][49m[39m [###.........................................................] 8Selecting previously unselected package libnginx-mod-http-geoip2.
Preparing to unpack .../1-libnginx-mod-http-geoip2_1.18.0-6ubuntu14.4_amd64.deb ...
7[22;0f[42m[30mProgress: [  8%][49m[39m [####........................................................] 8Unpacking libnginx-mod-http-geoip2 (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 11%][49m[39m [######......................................................] 8Selecting previously unselected package libnginx-mod-http-image-filter.
Preparing to unpack .../2-libnginx-mod-http-image-filter_1.18.0-6ubuntu14.4_amd64.deb ...
7[22;0f[42m[30mProgress: [ 14%][49m[39m [########....................................................] 8Unpacking libnginx-mod-http-image-filter (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 16%][49m[39m [#########...................................................] 8Selecting previously unselected package libnginx-mod-http-xslt-filter.
Preparing to unpack .../3-libnginx-mod-http-xslt-filter_1.18.0-6ubuntu14.4_amd64.deb ...
7[22;0f[42m[30mProgress: [ 19%][49m[39m [###########.................................................] 8Unpacking libnginx-mod-http-xslt-filter (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 22%][49m[39m [############................................................] 8Selecting previously unselected package libnginx-mod-mail.
Preparing to unpack .../4-libnginx-mod-mail_1.18.0-6ubuntu14.4_amd64.deb ...
7[22;0f[42m[30mProgress: [ 24%][49m[39m [##############..............................................] 8Unpacking libnginx-mod-mail (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 27%][49m[39m [################............................................] 8Selecting previously unselected package libnginx-mod-stream.
Preparing to unpack .../5-libnginx-mod-stream_1.18.0-6ubuntu14.4_amd64.deb ...
7[22;0f[42m[30mProgress: [ 30%][49m[39m [#################...........................................] 8Unpacking libnginx-mod-stream (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 32%][49m[39m [###################.........................................] 8Selecting previously unselected package libnginx-mod-stream-geoip2.
Preparing to unpack .../6-libnginx-mod-stream-geoip2_1.18.0-6ubuntu14.4_amd64.deb ...
7[22;0f[42m[30mProgress: [ 35%][49m[39m [#####################.......................................] 8Unpacking libnginx-mod-stream-geoip2 (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 38%][49m[39m [######################......................................] 8Selecting previously unselected package nginx-core.
Preparing to unpack .../7-nginx-core_1.18.0-6ubuntu14.4_amd64.deb ...
7[22;0f[42m[30mProgress: [ 41%][49m[39m [########################....................................] 8Unpacking nginx-core (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 43%][49m[39m [#########################...................................] 8Selecting previously unselected package nginx.
Preparing to unpack .../8-nginx_1.18.0-6ubuntu14.4_amd64.deb ...
7[22;0f[42m[30mProgress: [ 46%][49m[39m [###########################.................................] 8Unpacking nginx (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 49%][49m[39m [#############################...............................] 8Setting up nginx-common (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 51%][49m[39m [##############################..............................] Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
7[22;0f[42m[30mProgress: [ 54%][49m[39m [################################............................] 8Setting up libnginx-mod-http-xslt-filter (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 57%][49m[39m [##################################..........................] 87[22;0f[42m[30mProgress: [ 59%][49m[39m [###################################.........................] 8Setting up libnginx-mod-http-geoip2 (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 62%][49m[39m [#####################################.......................] 87[22;0f[42m[30mProgress: [ 65%][49m[39m [######################################......................] 8Setting up libnginx-mod-mail (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 68%][49m[39m [########################################....................] 87[22;0f[42m[30mProgress: [ 70%][49m[39m [##########################################..................] 8Setting up libnginx-mod-http-image-filter (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 73%][49m[39m [###########################################.................] 87[22;0f[42m[30mProgress: [ 76%][49m[39m [#############################################...............] 8Setting up libnginx-mod-stream (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 78%][49m[39m [###############################################.............] 87[22;0f[42m[30mProgress: [ 81%][49m[39m [################################################............] 8Setting up libnginx-mod-stream-geoip2 (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 84%][49m[39m [##################################################..........] 87[22;0f[42m[30mProgress: [ 86%][49m[39m [###################################################.........] 8Setting up nginx-core (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 89%][49m[39m [#####################################################.......] 8 * Upgrading binary nginx   [82G
[76G[ OK ]
7[22;0f[42m[30mProgress: [ 92%][49m[39m [#######################################################.....] 8Setting up nginx (1.18.0-6ubuntu14.4) ...
7[22;0f[42m[30mProgress: [ 95%][49m[39m [########################################################....] 87[22;0f[42m[30mProgress: [ 97%][49m[39m [##########################################################..] 8Processing triggers for man-db (2.10.2-1) ...
Processing triggers for ufw (0.36.1-4ubuntu0.1) ...



7[0;22r8[1A[J[?2004h]0;phantom-zorin2@phantom-zorin: ~[01;32mphantom-zorin2@phantom-zorin[00m:[01;34m~[00m$ sudo[K[K[Kystemctl status nginx
[?2004l
[?1h=
[0;1;32m●[0m nginx.service - A high performance web server and a reverse proxy server[m
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: e[m[7m>[27m
Active: [0;1;32mactive (running)[0m since Wed 2024-07-24 10:16:13 WIB; 3min 6s ago[m
Docs: man:nginx(8)[m
Process: 16773 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_proces[m[7m>[27m
Process: 16774 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (co[m[7m>[27m
Main PID: 16875 (nginx)[m
Tasks: 13 (limit: 18105)[m
Memory: 11.5M[m
CPU: 162ms[m
CGroup: /system.slice/nginx.service[m
├─16875 "nginx: master process /usr/sbin/nginx -g daemon on; master_[m[7m>[27m
├─16877 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
├─16878 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
├─16879 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
├─16880 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
├─16881 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
├─16882 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
├─16883 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
├─16884 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
├─16885 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" [m[7m>[27m
[7mlines 1-21[27m[K
[K [K^X^X
[K[?1l>
[1]+  Stopped             systemctl status nginx
[?2004h]0;phantom-zorin2@phantom-zorin: ~[01;32mphantom-zorin2@phantom-zorin[00m:01;34m~[00m$ cd /etc/nginx/
[?2004l
[?2004h]0;phantom-zorin2@phantom-zorin: /etc/nginx[01;32mphantom-zorin2@phantom-zorin[00m:01;34m/etc/nginx[00m$ ls
[?2004l
[0m[01;34mconf.d[0m      koi-win        nginx.conf   [01;34msites-enabled[0m
fastcgi.conf mime.types     proxy_params [01;34msnippets[0m
fastcgi_params  [01;34mmodules-available[0m  scgi_params  uwsgi_params
koi-utf     [01;34mmodules-enabled[0m [01;34msites-available[0m  win-utf
[?2004h]0;phantom-zorin2@phantom-zorin: /etc/nginx[01;32mphantom-zorin2@phantom-zorin[00m:01;34m/etc/nginx[00m$ cat nginx.conf
[?2004l
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;

}
http {

##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;

include /etc/nginx/sites-enabled/*;

}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
#    listen localhost:110;
#    protocol   pop3;
#    proxy  on;
# }
#
# server {
#    listen localhost:143;
#    protocol   imap;
#    proxy  on;
# }
#}

[?2004h]0;phantom-zorin2@phantom-zorin: /etc/nginx[01;32mphantom-zorin2@phantom-zorin[00m:[01;34m/etc/nginx[00m$ [?2004l
exit
There are stopped jobs.
[?2004h]0;phantom-zorin2@phantom-zorin: /etc/nginx[01;32mphantom-zorin2@phantom-zorin[00m:[01;34m/etc/nginx[00m$ [?2004l
exit
Script done on 2024-07-24 10:20:05+07:00 [COMMAND_EXIT_CODE="0"]

Leave a Comment