<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: johanputra</title>
    <description>The latest articles on Forem by johanputra (@johanputra).</description>
    <link>https://forem.com/johanputra</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F576820%2Ff7f2949e-70be-4e84-8dde-27234805467d.jpg</url>
      <title>Forem: johanputra</title>
      <link>https://forem.com/johanputra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/johanputra"/>
    <language>en</language>
    <item>
      <title>WireGuard Setup for Ubuntu Server (Laptop to be Remote Accessed)</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Tue, 03 Feb 2026 05:05:11 +0000</pubDate>
      <link>https://forem.com/johanputra/wireguard-setup-for-ubuntu-server-laptop-to-be-remote-accessed-4md3</link>
      <guid>https://forem.com/johanputra/wireguard-setup-for-ubuntu-server-laptop-to-be-remote-accessed-4md3</guid>
      <description>&lt;h2&gt;
  
  
  Step 1: Install WireGuard
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Update system&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Install WireGuard&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;wireguard resolvconf &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Generate Server Key Pair
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Navigate to WireGuard directory&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /etc/wireguard/

&lt;span class="c"&gt;# Generate private key and save&lt;/span&gt;
&lt;span class="nb"&gt;sudo umask &lt;/span&gt;077
wg genkey | &lt;span class="nb"&gt;sudo tee &lt;/span&gt;privatekey | wg pubkey | &lt;span class="nb"&gt;sudo tee &lt;/span&gt;publickey

&lt;span class="c"&gt;# Display keys (save these securely)&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== SERVER PRIVATE KEY ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo cat &lt;/span&gt;privatekey
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;=== SERVER PUBLIC KEY ==="&lt;/span&gt;
&lt;span class="nb"&gt;sudo cat &lt;/span&gt;publickey
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Save both keys in a secure location!&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Create Server Configuration
&lt;/h2&gt;

&lt;p&gt;Create configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/wireguard/wg0.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following content (replace &lt;code&gt;[SERVER_PRIVATE_KEY]&lt;/code&gt; with your private key from Step 2):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Interface]&lt;/span&gt;
&lt;span class="py"&gt;PrivateKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;[SERVER_PRIVATE_KEY]&lt;/span&gt;
&lt;span class="py"&gt;Address&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;10.8.0.1/24&lt;/span&gt;
&lt;span class="py"&gt;ListenPort&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;51820&lt;/span&gt;
&lt;span class="py"&gt;SaveConfig&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;

&lt;span class="c"&gt;# DNS configuration
&lt;/span&gt;&lt;span class="py"&gt;DNS&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;1.1.1.1, 8.8.8.8&lt;/span&gt;

&lt;span class="c"&gt;# Firewall and routing rules
&lt;/span&gt;&lt;span class="py"&gt;PostUp&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&lt;/span&gt;
&lt;span class="py"&gt;PostDown&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example with actual values:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Interface]&lt;/span&gt;
&lt;span class="py"&gt;PrivateKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdef=&lt;/span&gt;
&lt;span class="py"&gt;Address&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;10.8.0.1/24&lt;/span&gt;
&lt;span class="py"&gt;ListenPort&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;51820&lt;/span&gt;
&lt;span class="py"&gt;SaveConfig&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;true&lt;/span&gt;
&lt;span class="py"&gt;DNS&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;1.1.1.1, 8.8.8.8&lt;/span&gt;
&lt;span class="py"&gt;PostUp&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&lt;/span&gt;
&lt;span class="py"&gt;PostDown&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Enable IP Forwarding
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Edit sysctl configuration&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/sysctl.conf

&lt;span class="c"&gt;# Uncomment or add this line:&lt;/span&gt;
net.ipv4.ip_forward&lt;span class="o"&gt;=&lt;/span&gt;1

&lt;span class="c"&gt;# Apply changes&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;sysctl &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Configure Firewall
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Allow WireGuard port&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow 51820/udp

&lt;span class="c"&gt;# Allow SSH (don't forget!)&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow ssh

&lt;span class="c"&gt;# Enable UFW&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw &lt;span class="nb"&gt;enable&lt;/span&gt;

&lt;span class="c"&gt;# Check status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6: Start WireGuard Service
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start WireGuard interface&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0

&lt;span class="c"&gt;# Enable auto-start on boot&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;wg-quick@wg0

&lt;span class="c"&gt;# Check status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg show
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 7: Generate Client Configuration
&lt;/h2&gt;

&lt;h3&gt;
  
  
  7.1 Generate Client Keys
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Generate client keys&lt;/span&gt;
wg genkey | &lt;span class="nb"&gt;tee &lt;/span&gt;client_private.key
&lt;span class="nb"&gt;cat &lt;/span&gt;client_private.key | wg pubkey &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; client_public.key

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== CLIENT PRIVATE KEY ==="&lt;/span&gt;
&lt;span class="nb"&gt;cat &lt;/span&gt;client_private.key
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;=== CLIENT PUBLIC KEY ==="&lt;/span&gt;
&lt;span class="nb"&gt;cat &lt;/span&gt;client_public.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.2 Add Client to Server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Add client to server configuration&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg &lt;span class="nb"&gt;set &lt;/span&gt;wg0 peer &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;client_public.key&lt;span class="si"&gt;)&lt;/span&gt; allowed-ips 10.8.0.2/32

&lt;span class="c"&gt;# Save configuration permanently&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick save wg0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.3 Create Client Config File
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;ubuntu-client.conf&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Interface]&lt;/span&gt;
&lt;span class="py"&gt;PrivateKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;[CLIENT_PRIVATE_KEY]&lt;/span&gt;
&lt;span class="py"&gt;Address&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;10.8.0.2/24&lt;/span&gt;
&lt;span class="py"&gt;DNS&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;1.1.1.1, 8.8.8.8&lt;/span&gt;

&lt;span class="nn"&gt;[Peer]&lt;/span&gt;
&lt;span class="py"&gt;PublicKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;[SERVER_PUBLIC_KEY]&lt;/span&gt;
&lt;span class="py"&gt;Endpoint&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;[SERVER_IP]:51820&lt;/span&gt;
&lt;span class="py"&gt;AllowedIPs&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;0.0.0.0/0&lt;/span&gt;
&lt;span class="py"&gt;PersistentKeepalive&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;25&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How to get SERVER_IP:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# For public IP (if you have one)&lt;/span&gt;
curl &lt;span class="nt"&gt;-4&lt;/span&gt; ifconfig.me

&lt;span class="c"&gt;# For local IP&lt;/span&gt;
ip addr show | &lt;span class="nb"&gt;grep &lt;/span&gt;inet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 8: Enable Services for Remote Access
&lt;/h2&gt;

&lt;h3&gt;
  
  
  8.1 Enable SSH (if not already enabled)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install SSH server if not present&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;openssh-server &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Enable SSH service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;ssh
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start ssh

&lt;span class="c"&gt;# Check status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8.2 Optional: Enable VNC for GUI access
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install VNC server&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;x11vnc &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Set VNC password&lt;/span&gt;
x11vnc &lt;span class="nt"&gt;-storepasswd&lt;/span&gt;

&lt;span class="c"&gt;# Create VNC service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;nano /etc/systemd/system/x11vnc.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Service file content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Unit]&lt;/span&gt;
&lt;span class="py"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;x11vnc service&lt;/span&gt;
&lt;span class="py"&gt;After&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;display-manager.service network.target syslog.target&lt;/span&gt;

&lt;span class="nn"&gt;[Service]&lt;/span&gt;
&lt;span class="py"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;simple&lt;/span&gt;
&lt;span class="py"&gt;ExecStart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/usr/bin/x11vnc -forever -display :0 -auth guess -passwd /home/$(whoami)/.vnc/passwd&lt;/span&gt;
&lt;span class="py"&gt;ExecStop&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/usr/bin/killall x11vnc&lt;/span&gt;
&lt;span class="py"&gt;Restart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;on-failure&lt;/span&gt;

&lt;span class="nn"&gt;[Install]&lt;/span&gt;
&lt;span class="py"&gt;WantedBy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;multi-user.target&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Enable VNC service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;x11vnc
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start x11vnc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 9: Testing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  9.1 Test WireGuard Server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Check interface&lt;/span&gt;
ip addr show wg0

&lt;span class="c"&gt;# Check WireGuard status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg show

&lt;span class="c"&gt;# Test port listening&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;netstat &lt;span class="nt"&gt;-tulnp&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;51820
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  9.2 Test from Client
&lt;/h3&gt;

&lt;p&gt;After setting up the client, test the connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Ping server&lt;/span&gt;
ping 10.8.0.1

&lt;span class="c"&gt;# SSH through VPN&lt;/span&gt;
ssh username@10.8.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 10: Automated Setup Script
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;setup-wireguard-ubuntu.sh&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== WireGuard Auto Setup for Ubuntu ==="&lt;/span&gt;

&lt;span class="c"&gt;# Install dependencies&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;wireguard resolvconf &lt;span class="nt"&gt;-y&lt;/span&gt;

&lt;span class="c"&gt;# Generate keys&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /etc/wireguard
&lt;span class="nb"&gt;sudo umask &lt;/span&gt;077
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg genkey | &lt;span class="nb"&gt;sudo tee &lt;/span&gt;privatekey | &lt;span class="nb"&gt;sudo &lt;/span&gt;wg pubkey | &lt;span class="nb"&gt;sudo tee &lt;/span&gt;publickey

&lt;span class="nv"&gt;SERVER_PRIVATE_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;sudo cat &lt;/span&gt;privatekey&lt;span class="si"&gt;)&lt;/span&gt;
&lt;span class="nv"&gt;SERVER_PUBLIC_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;sudo cat &lt;/span&gt;publickey&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Create config&lt;/span&gt;
&lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/wireguard/wg0.conf &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
[Interface]
PrivateKey = &lt;/span&gt;&lt;span class="nv"&gt;$SERVER_PRIVATE_KEY&lt;/span&gt;&lt;span class="sh"&gt;
Address = 10.8.0.1/24
ListenPort = 51820
SaveConfig = true
DNS = 1.1.1.1, 8.8.8.8
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="c"&gt;# Enable IP forwarding&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'net.ipv4.ip_forward=1'&lt;/span&gt; | &lt;span class="nb"&gt;sudo tee&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; /etc/sysctl.conf
&lt;span class="nb"&gt;sudo &lt;/span&gt;sysctl &lt;span class="nt"&gt;-p&lt;/span&gt;

&lt;span class="c"&gt;# Setup firewall&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow 51820/udp
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw allow ssh

&lt;span class="c"&gt;# Start service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;wg-quick@wg0

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== Setup Complete! ==="&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Server Public Key: &lt;/span&gt;&lt;span class="nv"&gt;$SERVER_PUBLIC_KEY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"WireGuard interface: wg0"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Server VPN IP: 10.8.0.1"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make executable and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x setup-wireguard-ubuntu.sh
&lt;span class="nb"&gt;sudo&lt;/span&gt; ./setup-wireguard-ubuntu.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 11: Management Commands
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Useful commands:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start/Stop WireGuard&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick down wg0

&lt;span class="c"&gt;# Check status&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg show
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status wg-quick@wg0

&lt;span class="c"&gt;# View logs&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;journalctl &lt;span class="nt"&gt;-u&lt;/span&gt; wg-quick@wg0 &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Add client manually&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg &lt;span class="nb"&gt;set &lt;/span&gt;wg0 peer &lt;span class="o"&gt;[&lt;/span&gt;CLIENT_PUBLIC_KEY] allowed-ips 10.8.0.2/32

&lt;span class="c"&gt;# Remove client&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg &lt;span class="nb"&gt;set &lt;/span&gt;wg0 peer &lt;span class="o"&gt;[&lt;/span&gt;CLIENT_PUBLIC_KEY] remove
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  If you encounter issues:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Restart service&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick down wg0
&lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0

&lt;span class="c"&gt;# Check kernel module&lt;/span&gt;
lsmod | &lt;span class="nb"&gt;grep &lt;/span&gt;wireguard

&lt;span class="c"&gt;# Check firewall&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;ufw status

&lt;span class="c"&gt;# Check routing&lt;/span&gt;
ip route show

&lt;span class="c"&gt;# Check interface status&lt;/span&gt;
ip &lt;span class="nb"&gt;link &lt;/span&gt;show wg0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Common Issues and Solutions:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Interface not starting:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="c"&gt;# Check if module is loaded&lt;/span&gt;
   &lt;span class="nb"&gt;sudo &lt;/span&gt;modprobe wireguard

   &lt;span class="c"&gt;# Check for errors in config&lt;/span&gt;
   &lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick down wg0
   &lt;span class="nb"&gt;sudo &lt;/span&gt;wg-quick up wg0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Connection issues:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="c"&gt;# Check if port is open&lt;/span&gt;
   &lt;span class="nb"&gt;sudo &lt;/span&gt;ufw status

   &lt;span class="c"&gt;# Verify keys match&lt;/span&gt;
   &lt;span class="nb"&gt;sudo &lt;/span&gt;wg show
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No internet access through VPN:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="c"&gt;# Check IP forwarding&lt;/span&gt;
   &lt;span class="nb"&gt;cat&lt;/span&gt; /proc/sys/net/ipv4/ip_forward

   &lt;span class="c"&gt;# Check NAT rules&lt;/span&gt;
   &lt;span class="nb"&gt;sudo &lt;/span&gt;iptables &lt;span class="nt"&gt;-t&lt;/span&gt; nat &lt;span class="nt"&gt;-L&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this setup, your Ubuntu laptop is ready to be securely accessed remotely through WireGuard VPN connection!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>networking</category>
      <category>tutorial</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Performance Tuning PHP</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Tue, 05 Aug 2025 01:56:30 +0000</pubDate>
      <link>https://forem.com/johanputra/performance-tuning-php-4ea8</link>
      <guid>https://forem.com/johanputra/performance-tuning-php-4ea8</guid>
      <description>&lt;h2&gt;
  
  
  PHP-FPM Pool Configuration (&lt;code&gt;www.conf&lt;/code&gt;) - Performance Tuning
&lt;/h2&gt;

&lt;p&gt;This document outlines the key parameters within a PHP-FPM pool configuration, essential for tuning PHP performance and managing server resources effectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameter Explanations
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;pm = dynamic&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;This parameter defines the process manager mode. &lt;code&gt;dynamic&lt;/code&gt; mode allows PHP-FPM to automatically adjust the number of worker processes based on server load.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;static&lt;/code&gt;&lt;/strong&gt;: A fixed number of processes is used, as defined by &lt;code&gt;pm.max_children&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;dynamic&lt;/code&gt;&lt;/strong&gt;: Processes scale up or down between &lt;code&gt;min_spare_servers&lt;/code&gt; and &lt;code&gt;max_children&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ondemand&lt;/code&gt;&lt;/strong&gt;: Processes are created only when a request arrives and are terminated after a period of inactivity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;dynamic&lt;/code&gt; mode, which you are using, requires additional parameters for configuration.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;pm.max_children = 1000&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;This is the maximum number of simultaneous PHP worker processes. A high value like &lt;code&gt;1000&lt;/code&gt; poses a significant risk of &lt;strong&gt;memory exhaustion&lt;/strong&gt; (&lt;code&gt;Out of Memory&lt;/code&gt; errors) and server crashes if not appropriately calculated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calculation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To estimate the necessary RAM, multiply the number of processes by the average memory usage per process.&lt;/li&gt;
&lt;li&gt;For example, &lt;code&gt;1000 processes × 100MB/process&lt;/code&gt; would require approximately &lt;code&gt;100GB&lt;/code&gt; of RAM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recommendation:&lt;/strong&gt; This value should be carefully calculated based on your server's available RAM, leaving some overhead for the operating system and other services.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;pm.start_servers = 80&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;The number of worker processes launched when the PHP-FPM service starts. This pre-spawns workers to handle an initial high load immediately.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;pm.min_spare_servers = 40&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;The minimum number of idle worker processes kept running. Maintaining a minimum pool of spare servers reduces the time it takes to serve new requests.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;pm.max_spare_servers = 120&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;The maximum number of idle worker processes. If the number of idle processes exceeds this value, PHP-FPM will terminate them to free up resources.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;request_terminate_timeout = 300s&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;This parameter defines the maximum execution time for a single request. If a request exceeds 300 seconds (5 minutes), the process is automatically terminated. This is a critical setting for preventing hung or slow-running scripts from consuming resources indefinitely.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;request_slowlog_timeout = 5s&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;Any script that takes longer than 5 seconds to execute will be logged for analysis.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;slowlog = /var/log/php-fpm/slowlog.log&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;The file path where slow-executing scripts are logged. This log is essential for debugging application performance bottlenecks.&lt;/p&gt;




&lt;h3&gt;
  
  
  Best Practices and Recommendations
&lt;/h3&gt;

&lt;p&gt;A configuration with &lt;code&gt;pm.max_children = 1000&lt;/code&gt; is typically unsuitable for servers with less than 100GB of RAM. A more balanced and safer configuration should be based on your server's hardware specifications.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example Configuration for an 8GB RAM Server
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="py"&gt;pm&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;dynamic&lt;/span&gt;
&lt;span class="py"&gt;pm.max_children&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;50&lt;/span&gt;
&lt;span class="py"&gt;pm.start_servers&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;10&lt;/span&gt;
&lt;span class="py"&gt;pm.min_spare_servers&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;5&lt;/span&gt;
&lt;span class="py"&gt;pm.max_spare_servers&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;20&lt;/span&gt;

&lt;span class="py"&gt;request_terminate_timeout&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;300s&lt;/span&gt;
&lt;span class="py"&gt;request_slowlog_timeout&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
&lt;span class="py"&gt;slowlog&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;/var/log/php-fpm/slowlog.log&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Using 80% of available RAM reserves resources for the OS and other critical services.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>fpm</category>
      <category>php</category>
      <category>performance</category>
    </item>
    <item>
      <title>Install zsh with autosuggestion in amazon linux</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Mon, 23 Jun 2025 08:05:05 +0000</pubDate>
      <link>https://forem.com/johanputra/install-zsh-with-autosuggestion-in-amazon-linux-m7p</link>
      <guid>https://forem.com/johanputra/install-zsh-with-autosuggestion-in-amazon-linux-m7p</guid>
      <description>&lt;p&gt;To install zsh and Oh My Zsh with the suggestion plugin on Amazon Linux, follow these steps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;

&lt;span class="c"&gt;# Install zsh&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;git zsh &lt;span class="nt"&gt;-y&lt;/span&gt;
sh &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Install zsh-syntax-highlighting plugin&lt;/span&gt;
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ZSH_CUSTOM&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="p"&gt;~/.oh-my-zsh/custom&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/plugins/zsh-syntax-highlighting

&lt;span class="c"&gt;# Install zsh-autosuggestions plugin&lt;/span&gt;
git clone https://github.com/zsh-users/zsh-autosuggestions &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ZSH_CUSTOM&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="p"&gt;~/.oh-my-zsh/custom&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/plugins/zsh-autosuggestions
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"plugins=(zsh-syntax-highlighting zsh-autosuggestions)"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc

&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"source &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ZSH_CUSTOM&lt;/span&gt;&lt;span class="k"&gt;:-&lt;/span&gt;&lt;span class="p"&gt;~/.oh-my-zsh/custom&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=blue'"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"ZSH_AUTOSUGGEST_USE_ASYNC=true"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc


&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Installation of zsh and Oh My Zsh with suggestion plugin complete!"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install zsh:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum install zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install Oh My Zsh:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install the zsh-syntax-highlighting plugin (required for the suggestion plugin):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install the zsh-autosuggestions plugin (suggestion plugin):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add the plugins to your Oh My Zsh configuration file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "plugins=(zsh-syntax-highlighting zsh-autosuggestions)" &amp;gt;&amp;gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Restart your terminal or run &lt;code&gt;source ~/.zshrc&lt;/code&gt; to apply the changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: If you want to use the suggestion plugin with the default Oh My Zsh theme, you may need to add the following line to your &lt;code&gt;~/.zshrc&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, you can configure the suggestion plugin by adding the following lines to your &lt;code&gt;~/.zshrc&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=blue'
ZSH_AUTOSUGGEST_USE_ASYNC=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will highlight the suggestions in blue and use asynchronous suggestions.&lt;/p&gt;

&lt;p&gt;After installing and configuring the suggestion plugin, you can use it by typing a command and then pressing the &lt;code&gt;→&lt;/code&gt; key (or &lt;code&gt;Tab&lt;/code&gt; key) to accept the suggestion.&lt;/p&gt;

</description>
      <category>zsh</category>
      <category>linux</category>
      <category>shell</category>
    </item>
    <item>
      <title>Finding the PHP Socket File</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Mon, 23 Jun 2025 04:21:06 +0000</pubDate>
      <link>https://forem.com/johanputra/finding-the-php-socket-file-5bm4</link>
      <guid>https://forem.com/johanputra/finding-the-php-socket-file-5bm4</guid>
      <description>&lt;p&gt;When working with PHP, it's not uncommon to encounter issues with the socket file. The socket file is a crucial component that enables communication between PHP and the web server or other applications. In this article, we'll explore the ways to find the PHP socket file, even if it's not explicitly defined in the configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding the PHP Socket File&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The PHP socket file is a file that allows PHP to communicate with the web server or other applications. It's usually located in the &lt;code&gt;/var/run/php&lt;/code&gt; directory and has a name like &lt;code&gt;php7.4-fpm.sock&lt;/code&gt;. The socket file is used by PHP-FPM (PHP FastCGI Process Manager) to manage the communication between PHP and the web server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Locating the PHP Socket File&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're having trouble finding the PHP socket file, here are some steps you can follow:&lt;/p&gt;

&lt;p&gt;1 &lt;strong&gt;Using the &lt;code&gt;netstat&lt;/code&gt; Command&lt;/strong&gt;: The &lt;code&gt;netstat&lt;/code&gt; command can be used to list all the open sockets on your system. You can use the following command to find the PHP socket file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;netstat &lt;span class="nt"&gt;-lp&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;sock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will list all the open sockets, and you can look for the one that corresponds to the PHP socket file.&lt;/p&gt;

&lt;p&gt;2 &lt;strong&gt;Using the &lt;code&gt;ss&lt;/code&gt; Command&lt;/strong&gt;: The &lt;code&gt;ss&lt;/code&gt; command is similar to the &lt;code&gt;netstat&lt;/code&gt; command, but it provides more detailed information about the sockets. You can use the following command to find the PHP socket file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ss &lt;span class="nt"&gt;-l&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;sock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will list all the open sockets, and you can look for the one that corresponds to the PHP socket file.&lt;/p&gt;

&lt;p&gt;3 &lt;strong&gt;Using the &lt;code&gt;lsof&lt;/code&gt; Command&lt;/strong&gt;: The &lt;code&gt;lsof&lt;/code&gt; command can be used to list all the open files on your system. You can use the following command to find the PHP socket file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof | &lt;span class="nb"&gt;grep &lt;/span&gt;sock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will list all the open files, and you can look for the one that corresponds to the PHP socket file.&lt;/p&gt;

&lt;p&gt;4 &lt;strong&gt;Using the &lt;code&gt;find&lt;/code&gt; Command&lt;/strong&gt;: The &lt;code&gt;find&lt;/code&gt; command can be used to search for files on your system. You can use the following command to find the PHP socket file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find / &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*.sock"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will search for all files with the &lt;code&gt;.sock&lt;/code&gt; extension, and you can look for the one that corresponds to the PHP socket file.&lt;/p&gt;

&lt;p&gt;5 &lt;strong&gt;Checking the PHP-FPM Configuration&lt;/strong&gt;: You can also check the PHP-FPM configuration file to see if the socket file is defined. The configuration file is usually located in the &lt;code&gt;/etc/php/7.4/fpm&lt;/code&gt; directory. You can use the following command to find the socket file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;grep &lt;/span&gt;listen /etc/php/7.4/fpm/php-fpm.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will search for the &lt;code&gt;listen&lt;/code&gt; directive in the configuration file, which should point to the socket file.&lt;/p&gt;

&lt;p&gt;6 &lt;strong&gt;Checking the &lt;code&gt;/var/run/php&lt;/code&gt; Directory&lt;/strong&gt;: Finally, you can check the &lt;code&gt;/var/run/php&lt;/code&gt; directory to see if the socket file is located there. You can use the following command to list the files in the directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /var/run/php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will list all the files in the directory, and you can look for the one that corresponds to the PHP socket file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finding the PHP socket file can be a challenging task, but by following the steps outlined in this article, you should be able to locate it. Remember to use the &lt;code&gt;netstat&lt;/code&gt;, &lt;code&gt;ss&lt;/code&gt;, &lt;code&gt;lsof&lt;/code&gt;, and &lt;code&gt;find&lt;/code&gt; commands to search for the socket file, and check the PHP-FPM configuration file and the &lt;code&gt;/var/run/php&lt;/code&gt; directory for more information. With this knowledge, you'll be able to troubleshoot issues with the PHP socket file and get your application up and running smoothly.&lt;/p&gt;

</description>
      <category>php</category>
      <category>fastcgi</category>
      <category>nginx</category>
      <category>phpfpm</category>
    </item>
    <item>
      <title>Monitor container with Portainer</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Wed, 26 Jun 2024 10:09:29 +0000</pubDate>
      <link>https://forem.com/johanputra/monitor-container-with-portainer-41nd</link>
      <guid>https://forem.com/johanputra/monitor-container-with-portainer-41nd</guid>
      <description>&lt;p&gt;membuat volume&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume create portainer_data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;perintah docker run yang digunakan untuk membuat portainer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d \
  -p 8000:8000 \
  -p 9443:9443 \
  --name portainer \
  --restart=unless-stopped \
  --network &amp;lt;network&amp;gt; \
  -v /var/run/docker.sock:/var/run/docker.sock  \
  -v portainer_data:/data \
  portainer/portainer-ce:2.20.3-alpine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;penjelasan untuk setiap perintah docker run&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;docker run: Perintah untuk membuat dan menjalankan container baru.&lt;/li&gt;
&lt;li&gt;-d: Menjalankan container di background (mode detached).&lt;/li&gt;
&lt;li&gt;-p 8000:8000: Memetakan port 8000 pada host ke port 8000 pada container. Ini digunakan untuk akses HTTP.&lt;/li&gt;
&lt;li&gt;-p 9443:9443: Memetakan port 9443 pada host ke port 9443 pada container. Ini digunakan untuk akses HTTPS.&lt;/li&gt;
&lt;li&gt;--name portainer: Menetapkan nama container menjadi portainer.&lt;/li&gt;
&lt;li&gt;--restart=unless-stopped: Mengatur kebijakan restart container. Dengan opsi ini, container akan otomatis restart kecuali jika secara eksplisit dihentikan.&lt;/li&gt;
&lt;li&gt;-v /var/run/docker.sock:/var/run/docker.sock: Memetakan socket Docker dari host ke container. Ini memungkinkan Portainer untuk berinteraksi dengan Docker daemon pada host.&lt;/li&gt;
&lt;li&gt;-v portainer_data:/data: Membuat volume bernama portainer_data dan
memetakannya ke /data di dalam container. Ini digunakan untuk persistensi data Portainer, memastikan data tetap ada meskipun container dihapus atau diperbarui.&lt;/li&gt;
&lt;li&gt;portainer/portainer-ce:2.20.3-alpine: Menentukan image yang akan digunakan untuk container. Dalam hal ini, menggunakan versi 2.20.3 dari Portainer Community Edition yang berbasis Alpine Linux.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;nginx konfigurasi untuk menampilkan antarmuka portainer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
    server_name portainer.martabanggosong.com; 

    location / {
        proxy_pass http://localhost:9000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Langkah-langkah untuk mengaplikasikan konfigurasi ini:&lt;/p&gt;

&lt;p&gt;1 Buat file konfigurasi baru di direktori konfigurasi Nginx (biasanya /etc/nginx/sites-available/) dengan nama portainer.conf dan masukkan konfigurasi di atas.&lt;br&gt;
2 Sesuaikan server_name dengan domain Anda dan pastikan proxy_pass mengarah ke alamat tempat Portainer berjalan.&lt;br&gt;
3 Buat symlink dari file konfigurasi yang Anda buat ke direktori /etc/nginx/sites-enabled/ untuk mengaktifkannya.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ln -s /etc/nginx/sites-available/portainer.conf /etc/nginx/sites-enabled/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4 Test konfigurasi Nginx untuk memastikan tidak ada kesalahan.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nginx -t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5 Reload Nginx untuk menerapkan perubahan.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl reload nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>docker</category>
      <category>podman</category>
    </item>
    <item>
      <title>Install php in linux server</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Tue, 16 Jan 2024 07:08:08 +0000</pubDate>
      <link>https://forem.com/johanputra/install-php-in-linux-server-1cge</link>
      <guid>https://forem.com/johanputra/install-php-in-linux-server-1cge</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php8.2-fpm php8.2-mysql php8.2-curl php8.2-xml php8.2-opcache php8.2-mbstring php8.2-zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl status php8.2-fpm.service
● php8.2-fpm.service - The PHP 8.2 FastCGI Process Manager
     Loaded: loaded (/lib/systemd/system/php8.2-fpm.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-01-16 12:54:56 WIB; 1h 11min ago
       Docs: man:php-fpm8.2(8)
    Process: 1268 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.2/fpm/pool.d/www.conf 82 (code=exited, status=0/SUCCESS)
    Process: 14147 ExecReload=/bin/kill -USR2 $MAINPID (code=exited, status=0/SUCCESS)
   Main PID: 1102 (php-fpm8.2)
     Status: "Processes active: 0, idle: 2, Requests: 6, slow: 0, Traffic: 0req/sec"
      Tasks: 3 (limit: 9211)
     Memory: 62.1M
     CGroup: /system.slice/php8.2-fpm.service
             ├─ 1102 php-fpm: master process (/etc/php/8.2/fpm/php-fpm.conf)
             ├─14162 php-fpm: pool www
             └─14163 php-fpm: pool www
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>php</category>
      <category>linux</category>
      <category>ubuntu</category>
      <category>nginx</category>
    </item>
    <item>
      <title>bind mount and volume</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Wed, 01 Nov 2023 10:25:22 +0000</pubDate>
      <link>https://forem.com/johanputra/bind-mount-and-volume-4cln</link>
      <guid>https://forem.com/johanputra/bind-mount-and-volume-4cln</guid>
      <description>&lt;p&gt;Bind mounts and volumes are both used in Docker to share data between the host machine and the container. However, there are some differences between the two: Bind Mounts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    Bind mounts allow you to mount a file or directory on the host machine into a container.&lt;/li&gt;
&lt;li&gt;    Bind mounts can be read-write or read-only.&lt;/li&gt;
&lt;li&gt;    Bind mounts can be used to share data between the host machine and the container.&lt;/li&gt;
&lt;li&gt;    Bind mounts can be used to share data between containers.&lt;/li&gt;
&lt;li&gt;    Bind mounts can be used to access host level resources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Volumes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    Volumes are managed by Docker and are created and managed by Docker commands.&lt;/li&gt;
&lt;li&gt;    Volumes can be used to persist data.&lt;/li&gt;
&lt;li&gt;    Volumes can be shared between containers.&lt;/li&gt;
&lt;li&gt;    Volumes can be backed up and restored.&lt;/li&gt;
&lt;li&gt;    Volumes can be used to improve performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In summary, bind mounts are used to share data between the host machine and the container, while volumes are used to persist data and improve performance. Both bind mounts and volumes have their own use cases and can be used together to achieve the desired outcome.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Managing Configuration Files with Chezmoi</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Sun, 17 Sep 2023 07:32:10 +0000</pubDate>
      <link>https://forem.com/johanputra/penggunaan-chezmoi-untuk-dotfile-4871</link>
      <guid>https://forem.com/johanputra/penggunaan-chezmoi-untuk-dotfile-4871</guid>
      <description>&lt;h1&gt;
  
  
  Managing Configuration Files with Chezmoi
&lt;/h1&gt;

&lt;p&gt;Chezmoi is a powerful tool for managing dotfiles and personal configuration files in a consistent, reproducible, and version-controlled manner.&lt;/p&gt;

&lt;p&gt;Official documentation:&lt;br&gt;
&lt;a href="https://www.chezmoi.io/" rel="noopener noreferrer"&gt;https://www.chezmoi.io/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing Chezmoi
&lt;/h2&gt;

&lt;p&gt;You can install Chezmoi by specifying a custom installation directory. The following command installs Chezmoi into &lt;code&gt;$HOME/.local/bin&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sh &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsLS&lt;/span&gt; get.chezmoi.io&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.local/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure that &lt;code&gt;$HOME/.local/bin&lt;/code&gt; is included in your &lt;code&gt;PATH&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verifying the Installation
&lt;/h2&gt;

&lt;p&gt;To confirm that Chezmoi has been installed successfully, check the version and binary location:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chezmoi &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chezmoi version v2.40.0, commit 6a8ca1634654734bb33a036ffb9c21e6b9f4d28d, built at 2023-09-19T09:56:08Z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the binary path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which chezmoi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/xyz/.local/bin/chezmoi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding Files to Chezmoi
&lt;/h2&gt;

&lt;p&gt;To start managing configuration files, add them to Chezmoi. For example, to manage &lt;code&gt;.zshrc&lt;/code&gt; and &lt;code&gt;.vimrc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chezmoi add ~/.zshrc ~/.vimrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Chezmoi will copy these files into its source directory, which by default is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/xyz/.local/share/chezmoi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This directory represents the &lt;strong&gt;source of truth&lt;/strong&gt; for your dotfiles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pushing Chezmoi Configuration to GitHub
&lt;/h2&gt;

&lt;p&gt;Navigate to the Chezmoi source directory and initialize or configure your Git repository:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/.local/share/chezmoi
git remote set-url origin git@github.com:user/dotfiles.git
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Initial commit"&lt;/span&gt;
git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, your dotfiles are safely version-controlled in GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating Managed Files
&lt;/h2&gt;

&lt;p&gt;When you modify a managed file (for example, &lt;code&gt;.zshrc&lt;/code&gt;) directly in your home directory, you need to reflect those changes back into Chezmoi’s source directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chezmoi add ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This updates the corresponding file under &lt;code&gt;~/.local/share/chezmoi&lt;/code&gt;, after which you can commit and push the changes to Git.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;chezmoi update&lt;/code&gt; is used to pull and apply changes &lt;strong&gt;from the remote repository to your local machine&lt;/strong&gt;, not to capture local file changes into the repository.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Applying Configuration on a New Machine
&lt;/h2&gt;

&lt;p&gt;On a new system, you can apply all managed configurations with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;chezmoi init git@github.com:user/dotfiles.git
chezmoi apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will recreate your dotfiles exactly as defined in the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This article only covers the basic usage of Chezmoi, such as installation, adding files, and Git integration. Chezmoi also supports advanced features including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Templates&lt;/li&gt;
&lt;li&gt;Conditional configuration&lt;/li&gt;
&lt;li&gt;Secrets management&lt;/li&gt;
&lt;li&gt;Encrypted files&lt;/li&gt;
&lt;li&gt;Cross-platform setups&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Further exploration is recommended as your configuration management needs grow. Feel free to leave comments or suggestions, and we can continue learning and improving this setup together.&lt;/p&gt;

</description>
      <category>dotfile</category>
      <category>terminal</category>
      <category>learning</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Install Go (Golang) on a Linux</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Tue, 29 Aug 2023 08:49:09 +0000</pubDate>
      <link>https://forem.com/johanputra/install-go-golang-on-a-linux-1apo</link>
      <guid>https://forem.com/johanputra/install-go-golang-on-a-linux-1apo</guid>
      <description>&lt;p&gt;To install Go (Golang) on a Linux system, you can follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Download Go&lt;/strong&gt;: Open a terminal window and use the &lt;code&gt;wget&lt;/code&gt; command to download the Go installation package. You can find the latest version of Go on the official &lt;a href="https://golang.org/dl/" rel="noopener noreferrer"&gt;Golang download page&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, to download Go version 1.17, you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   wget https://golang.org/dl/go1.17.linux-amd64.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Extract the Archive&lt;/strong&gt;: After downloading, you need to extract the downloaded archive. Use the &lt;code&gt;tar&lt;/code&gt; command to extract it:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-xvf&lt;/span&gt; go1.17.linux-amd64.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Move Go&lt;/strong&gt;: Move the extracted Go directory to a location on your system. Traditionally, it's placed in the &lt;code&gt;/usr/local&lt;/code&gt; directory. You'll need superuser (root) privileges for this:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;sudo mv &lt;/span&gt;go /usr/local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Set Environment Variables&lt;/strong&gt;: You need to set some environment variables to let your system know where Go is installed and where your Go workspace (where you'll develop your Go programs) is located. Add the following lines to your shell profile configuration file (e.g., &lt;code&gt;~/.bashrc&lt;/code&gt;, &lt;code&gt;~/.zshrc&lt;/code&gt;, or &lt;code&gt;~/.profile&lt;/code&gt;):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;GOPATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/go
   &lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/usr/local/go/bin:&lt;span class="nv"&gt;$PATH&lt;/span&gt;:&lt;span class="nv"&gt;$GOPATH&lt;/span&gt;/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, apply the changes to your current shell session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc ~/.bashrc  &lt;span class="c"&gt;# or the appropriate configuration file&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Verify Installation&lt;/strong&gt;: You can now verify that Go is installed correctly by opening a new terminal window and typing:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   go version

go1.17 linux/amd64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the installed Go version printed in the output.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbwlvaq3lzj38oo4gkmcn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbwlvaq3lzj38oo4gkmcn.png" alt="go version" width="722" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>linux</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Perbedaan flag --q -q -qq di unzip</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Tue, 22 Aug 2023 09:40:23 +0000</pubDate>
      <link>https://forem.com/johanputra/perbedaan-flag-q-q-qq-di-unzip-23d1</link>
      <guid>https://forem.com/johanputra/perbedaan-flag-q-q-qq-di-unzip-23d1</guid>
      <description>&lt;p&gt;Flag &lt;code&gt;--q&lt;/code&gt;, &lt;code&gt;-q&lt;/code&gt;, dan &lt;code&gt;-qq&lt;/code&gt; dalam perintah &lt;code&gt;unzip&lt;/code&gt; merujuk pada level verbosity atau tampilan pesan yang ditampilkan selama proses ekstrak. Perbedaan dari masing-masing flag:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--q&lt;/code&gt; (Quiet):&lt;/strong&gt; Ini adalah flag yang dapat digunakan untuk mengurangi keluaran atau pesan selama proses ekstrak. Ketika flag &lt;code&gt;--q&lt;/code&gt; digunakan, &lt;code&gt;unzip&lt;/code&gt; hanya akan menampilkan pesan kesalahan atau peringatan yang penting. Pesan normal dan informasi ekstra tidak akan ditampilkan.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Contoh: &lt;code&gt;unzip --q file.zip&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-q&lt;/code&gt; (Quiet):&lt;/strong&gt; Ini adalah bentuk pendek dari flag &lt;code&gt;--q&lt;/code&gt;. Penggunaan dan efeknya sama seperti yang dijelaskan di atas.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Contoh: &lt;code&gt;unzip -q file.zip&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;-qq&lt;/code&gt; (Really Quiet):&lt;/strong&gt; Ini adalah bentuk yang lebih diam daripada &lt;code&gt;-q&lt;/code&gt;. Saat menggunakan flag &lt;code&gt;-qq&lt;/code&gt;, &lt;code&gt;unzip&lt;/code&gt; hanya akan menampilkan pesan kesalahan yang sangat penting dan tidak akan menampilkan pesan peringatan apa pun.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Contoh: &lt;code&gt;unzip -qq file.zip&lt;/code&gt;&lt;/p&gt;

</description>
      <category>zip</category>
      <category>linux</category>
      <category>terminal</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Contoh penggunaan rsync</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Mon, 21 Aug 2023 07:54:24 +0000</pubDate>
      <link>https://forem.com/johanputra/contoh-penggunaan-rsync-194d</link>
      <guid>https://forem.com/johanputra/contoh-penggunaan-rsync-194d</guid>
      <description>&lt;p&gt;&lt;a href="https://upload.wikimedia.org/wikipedia/en/1/11/Newrsynclogo.png" rel="noopener noreferrer"&gt;&lt;em&gt;cover image&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Menyalin File dari Lokal ke Remote Server dengan SSH
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin file &lt;code&gt;source_file.txt&lt;/code&gt; dari mesin lokal ke direktori &lt;code&gt;/home/remoteuser/destination/&lt;/code&gt; di remote server melalui koneksi SSH.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"ssh -p 22"&lt;/span&gt; source_file.txt remoteuser@remote.example.com:/home/remoteuser/destination/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. Menyalin Folder Lokal ke Remote Server dengan SSH
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin seluruh isi folder &lt;code&gt;local_folder/&lt;/code&gt; dari mesin lokal ke direktori &lt;code&gt;/home/remoteuser/destination/&lt;/code&gt; di remote server melalui koneksi SSH.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"ssh -p 22"&lt;/span&gt; local_folder/ remoteuser@remote.example.com:/home/remoteuser/destination/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Menyalin File dari Remote Server ke Lokal dengan SSH
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin file &lt;code&gt;remote_file.txt&lt;/code&gt; dari direktori &lt;code&gt;/home/remoteuser/source/&lt;/code&gt; di remote server ke direktori lokal &lt;code&gt;/path/to/local/destination/&lt;/code&gt; melalui koneksi SSH.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"ssh -p 22"&lt;/span&gt; remoteuser@remote.example.com:/home/remoteuser/source/remote_file.txt /path/to/local/destination/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4. Menyalin File melalui RSH
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin file &lt;code&gt;source_file.txt&lt;/code&gt; dari mesin lokal ke direktori &lt;code&gt;/home/remoteuser/destination/&lt;/code&gt; di remote server melalui RSH (Remote Shell).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;--rsh&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rsh source_file.txt remoteuser@remote.example.com:/home/remoteuser/destination/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  5. Menyalin File dengan Filter Kustom
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin file-file yang memiliki ekstensi &lt;code&gt;.jpg&lt;/code&gt; dari &lt;code&gt;source_folder/&lt;/code&gt; ke &lt;code&gt;destination_folder/&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;--include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"*.jpg"&lt;/span&gt; &lt;span class="nt"&gt;--exclude&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt; source_folder/ destination_folder/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  6. Menyalin dengan Opsi Dry Run
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Melakukan simulasi tanpa benar-benar menyalin file, hanya menampilkan apa yang akan terjadi.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;--dry-run&lt;/span&gt; source_folder/ destination_folder/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  7. Menyalin dengan Hapus File di Tujuan
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin seluruh isi folder &lt;code&gt;local_folder/&lt;/code&gt; dari mesin lokal ke &lt;code&gt;remote_folder/&lt;/code&gt; di remote server, dan menghapus file di tujuan yang tidak ada di sumber.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;--delete&lt;/span&gt; local_folder/ remote_folder/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  8. Menyalin dengan Exclude dari File
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin file-file dari &lt;code&gt;source_folder/&lt;/code&gt; ke &lt;code&gt;destination_folder/&lt;/code&gt;, tetapi mengabaikan file yang ada dalam &lt;code&gt;exclude_list.txt&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;--exclude-from&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"exclude_list.txt"&lt;/span&gt; source_folder/ destination_folder/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  9. Menyalin dengan Opsi Compression
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin file &lt;code&gt;source_file.txt&lt;/code&gt; dari mesin lokal ke direktori &lt;code&gt;/home/remoteuser/destination/&lt;/code&gt; di remote server dengan kompresi selama transfer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"ssh -p 22"&lt;/span&gt; &lt;span class="nt"&gt;--compress&lt;/span&gt; source_file.txt remoteuser@remote.example.com:/home/remoteuser/destination/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  10. Menyalin dengan SSH dan Ekspresi Reguler
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Deskripsi:&lt;/strong&gt; Menyalin file-file yang memiliki ekstensi &lt;code&gt;.txt&lt;/code&gt; dari &lt;code&gt;source_folder/&lt;/code&gt; ke &lt;code&gt;destination_folder/&lt;/code&gt; di remote server dengan koneksi SSH.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rsync &lt;span class="nt"&gt;-avz&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"ssh -p 22"&lt;/span&gt; source_folder/ remoteuser@remote.example.com:/home/remoteuser/destination/ &lt;span class="nt"&gt;--include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"*.txt"&lt;/span&gt; &lt;span class="nt"&gt;--exclude&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






</description>
      <category>rsync</category>
      <category>linux</category>
      <category>terminal</category>
    </item>
    <item>
      <title>Contoh penggunaan `sync`</title>
      <dc:creator>johanputra</dc:creator>
      <pubDate>Sat, 19 Aug 2023 13:11:37 +0000</pubDate>
      <link>https://forem.com/johanputra/contoh-penggunaan-sync-1l54</link>
      <guid>https://forem.com/johanputra/contoh-penggunaan-sync-1l54</guid>
      <description>&lt;p&gt;Pada sistem operasi Linux, perintah &lt;code&gt;sync&lt;/code&gt; digunakan untuk memastikan bahwa data dalam buffer sistem ditulis ke perangkat penyimpanan fisik seperti disk. Ini memastikan bahwa data yang ada dalam buffer benar-benar tertulis ke media penyimpanan sebelum operasi penting dilakukan. Berikut adalah beberapa contoh penggunaan perintah &lt;code&gt;sync&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sebelum Mematikan atau Me-restart Sistem:&lt;/strong&gt;
Sebelum mematikan atau me-restart sistem, disarankan untuk menggunakan &lt;code&gt;sync&lt;/code&gt; untuk memastikan semua data yang ada dalam buffer ditulis ke disk. Ini akan membantu mencegah kehilangan data yang belum disimpan.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sebelum Mencabut Media Penyimpanan Eksternal:&lt;/strong&gt;
Jika Anda memiliki perangkat penyimpanan eksternal seperti USB drive yang terhubung ke sistem, gunakan &lt;code&gt;sync&lt;/code&gt; sebelum mencabutnya. Ini akan memastikan bahwa semua data yang ada dalam buffer ditulis ke perangkat sebelum dicabut.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Setelah Menjalankan Perintah Pengelolaan Disk:&lt;/strong&gt;
Setelah menjalankan perintah untuk mengelola partisi atau sistem berkas (seperti &lt;code&gt;fdisk&lt;/code&gt;, &lt;code&gt;parted&lt;/code&gt;, atau &lt;code&gt;mkfs&lt;/code&gt;), gunakan &lt;code&gt;sync&lt;/code&gt; untuk memastikan bahwa perubahan yang Anda buat telah diterapkan pada media penyimpanan.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   parted /dev/sdX mklabel gpt
   &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sebelum Penggunaan &lt;code&gt;dd&lt;/code&gt; untuk Menyalin Data:&lt;/strong&gt;
Jika Anda menggunakan perintah &lt;code&gt;dd&lt;/code&gt; untuk menyalin data dari atau ke perangkat penyimpanan, gunakan &lt;code&gt;sync&lt;/code&gt; setelah selesai untuk memastikan bahwa semua data telah ditulis sepenuhnya.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;dd &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sda &lt;span class="nv"&gt;of&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sdb
   &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sebelum Melihat Informasi Disk:&lt;/strong&gt;
Jika Anda ingin melihat informasi terbaru tentang disk dan partisi menggunakan perintah seperti &lt;code&gt;lsblk&lt;/code&gt; atau &lt;code&gt;fdisk&lt;/code&gt;, pastikan untuk menggunakan &lt;code&gt;sync&lt;/code&gt; terlebih dahulu untuk memastikan data terbaru ditampilkan.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;sync
   &lt;/span&gt;lsblk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Penting untuk diingat bahwa &lt;code&gt;sync&lt;/code&gt; adalah perintah yang cepat dan tidak menghasilkan output. Ini hanya memastikan bahwa data dalam buffer ditulis ke perangkat penyimpanan. Pastikan untuk menggunakan &lt;code&gt;sync&lt;/code&gt; dalam situasi yang tepat untuk memastikan integritas data Anda.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>sync</category>
      <category>terminal</category>
    </item>
  </channel>
</rss>
