<?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>DEV Community: brandon_wallace</title>
    <description>The latest articles on DEV Community by brandon_wallace (@brandonwallace).</description>
    <link>https://dev.to/brandonwallace</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%2F403922%2Ffae1bd63-d3d1-41c7-a3b8-e92e9fa4df02.png</url>
      <title>DEV Community: brandon_wallace</title>
      <link>https://dev.to/brandonwallace</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/brandonwallace"/>
    <language>en</language>
    <item>
      <title>Make Your Tmux Status Line 100% Better With Bash</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Mon, 12 Dec 2022 03:35:28 +0000</pubDate>
      <link>https://dev.to/brandonwallace/make-your-tmux-status-line-100-better-with-bash-mgf</link>
      <guid>https://dev.to/brandonwallace/make-your-tmux-status-line-100-better-with-bash-mgf</guid>
      <description>&lt;p&gt;Did you know that you can easily use Bash to display information on the Tmux status line? Because of that the possibilities of what you can do are almost endless. You can display all sorts of useful information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hostname&lt;/li&gt;
&lt;li&gt;IP address&lt;/li&gt;
&lt;li&gt;Netmask&lt;/li&gt;
&lt;li&gt;Gateway&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;CPU temperature&lt;/li&gt;
&lt;li&gt;System load&lt;/li&gt;
&lt;li&gt;Battery meter&lt;/li&gt;
&lt;li&gt;VPN status&lt;/li&gt;
&lt;li&gt;Time&lt;/li&gt;
&lt;li&gt;Date&lt;/li&gt;
&lt;li&gt;Weather report&lt;/li&gt;
&lt;li&gt;Git status&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article I will show you an easy way to add information to your Tmux status line. &lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;lm-sensors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is the default status line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F2zajzorcwaw8miyqbz7d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F2zajzorcwaw8miyqbz7d.png" alt="status-line-original.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the status line enhanced to show more information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fppvkiyadg2ksb2hjket9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fppvkiyadg2ksb2hjket9.png" alt="tmux-status-line-enhanced.png"&gt;&lt;/a&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;# Debian/Ubuntu based distributions&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;tmux


&lt;span class="c"&gt;# Redhat/Fedora based distributions&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;tmux


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check your Tmux version. Currently I am using version 3.3a.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;tmux &lt;span class="nt"&gt;-V&lt;/span&gt;

&lt;span class="c"&gt;# Output&lt;/span&gt;
tmux 3.3a


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you do not have a &lt;code&gt;.tmux.conf&lt;/code&gt; create one in your home directory. &lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; .tmux.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I will start out with a basic &lt;code&gt;.tmux.conf&lt;/code&gt; configuration. Edit &lt;code&gt;.tmux.conf&lt;/code&gt; and add the following lines. &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;# .tmux.conf&lt;/span&gt;

&lt;span class="nb"&gt;bind &lt;/span&gt;r source-file ~/.tmux.conf &lt;span class="se"&gt;\;&lt;/span&gt; display-message &lt;span class="s2"&gt;"RELOADING CONFIGURATION FILE…"&lt;/span&gt;

&lt;span class="c"&gt;# STATUS LINE&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status on
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-interval 1
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-justify centre &lt;span class="c"&gt;# Careful! It is spelled "centre" not "center".&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-style &lt;span class="nb"&gt;fg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;white,bg&lt;span class="o"&gt;=&lt;/span&gt;black

&lt;span class="c"&gt;# Highlight the current window.&lt;/span&gt;
setw &lt;span class="nt"&gt;-g&lt;/span&gt; window-status-current-style &lt;span class="nb"&gt;fg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;white,bg&lt;span class="o"&gt;=&lt;/span&gt;red,bright

&lt;span class="c"&gt;# LEFT STATUS&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left-length 100
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left-style default
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;" "&lt;/span&gt;

&lt;span class="c"&gt;# RIGHT STATUS&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right-length 100
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right-style default
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right &lt;span class="s2"&gt;" "&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Status Line Left Side
&lt;/h2&gt;

&lt;p&gt;Tmux has same built in variables that you can use to display information such as &lt;code&gt;#h&lt;/code&gt; to display the hostname. View the man page for more information.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


$ man tmux



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add &lt;code&gt;#h&lt;/code&gt; in between the double quotes&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


set -g status-left "#h"



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You need to reload Tmux to see the changes. To reload Tmux you can type &lt;code&gt;exit&lt;/code&gt; then launch Tmux again or you can reload Tmux by press the &lt;code&gt;CTRL+b&lt;/code&gt; then &lt;code&gt;r&lt;/code&gt;.&lt;br&gt;
After reloading Tmux you will see the hostname of your computer on the status line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F4en4kvkdqk9v85jlh3lu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F4en4kvkdqk9v85jlh3lu.png" alt="tmux-status-line-hostname-bw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding the IP address and netmask to Status Line
&lt;/h2&gt;

&lt;p&gt;All we need to do to customize the status line is to add Bash one-liners. To add Bash commands to the command line you only need to place each command inside a hash mark and parenthesis &lt;code&gt;#( &amp;lt;my-command&amp;gt; )&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;I use this Bash command to get the IP address of the &lt;code&gt;enp4s0&lt;/code&gt; Ethernet interface. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


$ ip addr | grep -e 'state UP' -A 2 | awk '/inet /{printf $2}'

# Output

192.168.0.101/26



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I can add the command to the Tmux status line by placing it in between the parenthesis like this.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


set -g status-left "#h #(ip addr | grep -e 'state UP' -A 2 | awk '/inet /{printf $2}')"



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.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%2F11x185f7wrno3y3c20yw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F11x185f7wrno3y3c20yw.png" alt="tmux-status-line-ip-netmask-bw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding the CPU Temperature to Status Line
&lt;/h2&gt;

&lt;p&gt;Next I want to add the CPU temperature. To make that work you must use &lt;code&gt;lm-sensors&lt;/code&gt;. Install &lt;code&gt;lm-sensors&lt;/code&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;# Debian/Ubuntu based distributions&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;lm-sensors


&lt;span class="c"&gt;# Redhat/Fedora based distributions&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;lm_sensors



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Enable lm-sensors with this command and follow the prompts.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;sensors-detect


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run the &lt;code&gt;sensors&lt;/code&gt; command to see the output. From the output you will need to figure out which line displays information about the CPU. The line you need might be labeled &lt;code&gt;Tccd1&lt;/code&gt; or &lt;code&gt;CPU&lt;/code&gt;. Add the &lt;code&gt;-f&lt;/code&gt; argument to the sensors command to see the temperature in Fahrenheit.&lt;/p&gt;

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


&lt;span class="nv"&gt;$ &lt;/span&gt;sensors &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Partial Output &lt;/span&gt;

intel-isa-0000
Adapter: ISA adapter
fan1:           0 RPM
CPU:          +96.8°F  
GPU:              N/A  
temp3:        +96.8°F  
temp4:        +32.0°F  
temp5:        +96.8°F  
temp6:        +96.8°F  
temp7:        +96.8°F  
temp8:            N/A  

intel-pci-0400
Adapter: PCI adapter
vddgfx:      794.00 mV 
vddnb:       604.00 mV 
edge:         +95.0°F  
PPT:           3.16 W  

BAT0-acpi-0
Adapter: ACPI interface
in0:          17.27 V  
&lt;span class="o"&gt;[&lt;/span&gt;....]



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add this code &lt;code&gt;#(sensors -f | awk '/CPU/{printf $2}')&lt;/code&gt; to the end of the left status line. This command uses awk to find the row with the text &lt;code&gt;CPU&lt;/code&gt; and print the second column.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#h #(ip addr show enp4s0 | awk '/inet /{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #(sensors -f | awk '/CPU/{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}')"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fwhl3malxiqo5i3j4ouhz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fwhl3malxiqo5i3j4ouhz.png" alt="tmux-status-line-cpu-temp-bw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Memory to the Status Line
&lt;/h2&gt;

&lt;p&gt;Next, I want to view the amount of memory used, the total memory, and calculate the percentage of memory in use. To do that I use the &lt;code&gt;free&lt;/code&gt; command.&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;# Amount of memory used / total amount of memory&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;free &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="nt"&gt;-h&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/Mem/{printf $3"/"$2}'&lt;/span&gt;

&lt;span class="c"&gt;# Output&lt;/span&gt;

3.3Gi/62Gi

&lt;span class="c"&gt;# Calculate percentage of memory used&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;free &lt;span class="nt"&gt;-m&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/Mem/{printf "%.2f%", 100*$3/$2}'&lt;/span&gt;

&lt;span class="c"&gt;# Output&lt;/span&gt;

2.1%



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Careful here! To get the memory command to display properly in the Tmux status line requires that certain characters be escaped.&lt;br&gt;
Here I am using the backward slash &lt;code&gt;\&lt;/code&gt; to escape the double quote &lt;code&gt;\"&lt;/code&gt;, the period &lt;code&gt;\.&lt;/code&gt;, the percent sign &lt;code&gt;\%&lt;/code&gt;, and the forward slash &lt;code&gt;\/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Before escaping characters:&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;#(free -m -h | awk '/Mem/{printf $3"/"$2}') #(free -m | awk '/Mem{printf "%.2f%", 100*$2/$3}')"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After escaping characters:&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;#(free -m -h | awk '/Mem/{printf $3\"\/\"$2}') #(free -m | awk '/Mem{printf \"\%\.2f\%\", 100*$2/$3}')"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The status left should now look like this.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#h #(ip addr | grep -e 'state UP' -A 2 | awk '/inet /{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #(sensors | awk '/CPU/{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #(free -m -h | awk '/Mem/{printf &lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="se"&gt;\"\/\"&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #(free -m | awk '/Mem{printf &lt;/span&gt;&lt;span class="se"&gt;\"\%\.&lt;/span&gt;&lt;span class="s2"&gt;2f&lt;/span&gt;&lt;span class="se"&gt;\%\"&lt;/span&gt;&lt;span class="s2"&gt;, 100*&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="s2"&gt;}')"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fuj843i1k80yg68guvhxb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fuj843i1k80yg68guvhxb.png" alt="tmux-status-line-memory-bw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding the Battery Level to Status Line
&lt;/h2&gt;

&lt;p&gt;I want to see the battery level and see if it is charging on not. To do that I can check the &lt;code&gt;/sys&lt;/code&gt; file system for the battery information. &lt;/p&gt;

&lt;p&gt;If your terminal supports &lt;a href="https://unicode-table.com/en/" rel="noopener noreferrer"&gt;unicode characters&lt;/a&gt; you can add an unicode characters to the status bar.&lt;/p&gt;

&lt;p&gt;I will test to see if the power cable is plugged in and show a lighting bolt icon if it is. I will show the percentage of battery remaining next to the lightning bolt.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;$(cat /sys/class/power_supply/AC/online)&lt;/code&gt; is equal to &lt;code&gt;1&lt;/code&gt; the lightning bolt will display. &lt;/p&gt;

&lt;p&gt;Add these lines to the end of the left status line. &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;#([ $(cat /sys/class/power_supply/AC/online) == 1 ] &amp;amp;&amp;amp; printf %s'🗲') &lt;/span&gt;

&lt;span class="c"&gt;#( $(cat /sys/class/power_supply/BAT0/capacity)\% )&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The left status line should look something like this.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#h #(ip addr | grep -e 'state UP' -A 2 | awk '/inet /{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #(sensors | awk '/CPU/{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #(free -m -h | awk '/Mem/{printf &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="se"&gt;\"\/\"\$&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="se"&gt;\}&lt;/span&gt;&lt;span class="s2"&gt;') #(free -m | awk '/Mem{printf 100*&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; %&lt;span class="s2"&gt;"}') #([ &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /sys/class/power_supply/AC/online&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; == 1 ] &amp;amp;&amp;amp; printf %s'🗲') #(cat /sys/class/power_supply/BAT0/capacity)&lt;/span&gt;&lt;span class="se"&gt;\%&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fjquz5wrixulhsz0yh51l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fjquz5wrixulhsz0yh51l.png" alt="tmux-status-line-battery-bw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding the VPN to Status Line
&lt;/h2&gt;

&lt;p&gt;I want to check if the VPN is up and see the IP address assigned to it. Depending on the VPN you use you might have to check the tun0 or ppp0 interface.&lt;/p&gt;

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


ip a | egrep &lt;span class="s1"&gt;'ppp0|tun0'&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; 2 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf $2}'&lt;/span&gt;

&lt;span class="c"&gt;# Output&lt;/span&gt;

10.20.3.45



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add this to the end of the left status line.&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;#([ ! -z $(ip a | egrep 'ppp0|tun0' -A 2 | awk '/inet /{printf $2}') ] &amp;amp;&amp;amp; echo $(ip a | egrep 'ppp0|tun0' -A 2 | awk '/inet /{printf \"VPN \"$2}'))&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;My status line now looks like this.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#h #(ip addr | grep -e 'state UP' -A 2 | awk '/inet /{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #(sensors | awk '/CPU/{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #(free -m -h | awk '/Mem/{printf &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="se"&gt;\"\/\"\$&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="se"&gt;\}&lt;/span&gt;&lt;span class="s2"&gt;') #(free -m | awk '/Mem{printf 100*&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; %&lt;span class="s2"&gt;"}') #([ &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /sys/class/power_supply/AC/online&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; == 1 ] &amp;amp;&amp;amp; printf %s'🗲') #(cat /sys/class/power_supply/BAT0/capacity)&lt;/span&gt;&lt;span class="se"&gt;\%&lt;/span&gt;&lt;span class="s2"&gt; #([ ! -z &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ip a | egrep &lt;span class="s1"&gt;'ppp0|tun0'&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; 2 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf $2}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; ] &amp;amp;&amp;amp; echo &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ip a | egrep &lt;span class="s1"&gt;'ppp0|tun0'&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; 2 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf \"VPN \"$2}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;)"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.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%2F5997hlduf2b8edsqv0nr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F5997hlduf2b8edsqv0nr.png" alt="tmux-status-line-enhanced-bw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Status Bar Right Side
&lt;/h1&gt;

&lt;p&gt;Now let’s configure the right side.&lt;/p&gt;

&lt;p&gt;I will get the load average using the &lt;code&gt;uptime&lt;/code&gt; command.&lt;/p&gt;

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


&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;uptime&lt;/span&gt;

&lt;span class="c"&gt;# Output&lt;/span&gt;

02:39:38 up 12:18,  1 user,  load average: 0.20, 0.11, 0.10



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The number of columns in the output can change so depending on the time. To get around that problem I use $(NF) to get the last column and &lt;code&gt;tr&lt;/code&gt; to remove the colon characters.&lt;/p&gt;

&lt;p&gt;Add this to the right status line option with escaped characters in between the double quotes.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right &lt;span class="s2"&gt;"#(uptime | awk '{printf &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;(NF-2)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\"\$&lt;/span&gt;&lt;span class="s2"&gt;(NF-1)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\"\$&lt;/span&gt;&lt;span class="s2"&gt;(NF)}' | tr -d ',')"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The last thing I will add is the date, time, and timezone using variables to status-right. Tmux uses strftime formatting to display variables. Given that, I can view the date and time using a custom format. Example: &lt;code&gt;%F&lt;/code&gt; represents &lt;code&gt;YYYY-mm-dd&lt;/code&gt;  &lt;code&gt;%T&lt;/code&gt; represents &lt;code&gt;HH:MM:SS&lt;/code&gt; . See the man page for more information &lt;code&gt;man strftime&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add that to the end of the right status line.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right &lt;span class="s2"&gt;"#(uptime | awk '{printf &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;(NF-2)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\"\$&lt;/span&gt;&lt;span class="s2"&gt;(NF-1)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\"\$&lt;/span&gt;&lt;span class="s2"&gt;(NF)}' | tr -d ',') %F %T %Z"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Adding a Bash Script
&lt;/h1&gt;

&lt;p&gt;If you needed to configure more complicated code than what could fit on one line you can make a separate Bash file and add it like this.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right &lt;span class="s2"&gt;"#( example.sh )"&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;example.sh

&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# example.sh&lt;/span&gt;

&lt;span class="c"&gt;# Get the IP address dynamically&lt;/span&gt;
&lt;span class="k"&gt;function &lt;/span&gt;get_ip_address&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;mapfile&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; iface_arr &amp;lt; &amp;lt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /sys/class/net/&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;iface &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$iface_arr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do 
        if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /sys/class/net/&lt;span class="nv"&gt;$iface&lt;/span&gt;/operstate&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"up"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
            &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"    %s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;iface&lt;/span&gt;&lt;span class="p"&gt;^^&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ip addr show &lt;span class="nv"&gt;$iface&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf $2}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
        &lt;span class="k"&gt;fi
    done&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

get_ip_address



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Adding Color
&lt;/h1&gt;

&lt;p&gt;Run this code in your terminal to see what colors you have available.&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="k"&gt;for &lt;/span&gt;num &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;0..255&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do  
    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s&lt;/span&gt;&lt;span class="se"&gt;\0&lt;/span&gt;&lt;span class="s2"&gt;33[38;5;&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;num&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;mcolour&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;num&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\0&lt;/span&gt;&lt;span class="s2"&gt;33[0m &lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;expr&lt;/span&gt; &lt;span class="k"&gt;$((&lt;/span&gt;num+1&lt;span class="k"&gt;))&lt;/span&gt; % 8&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="nt"&gt;-eq&lt;/span&gt; 0 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;&lt;span class="nb"&gt;printf&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;"&lt;/span&gt;
    &lt;span class="k"&gt;fi
done&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fhfw42xz603peoa8pp00a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fhfw42xz603peoa8pp00a.png" alt="tmux-colour-chart.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you can add color to your status line. Add foreground colors by setting a &lt;code&gt;#[fg=&amp;lt;colourN&amp;gt;]&lt;/code&gt; or &lt;code&gt;#[bg=&amp;lt;colourN&amp;gt;]&lt;/code&gt; variable to the color of your choice.&lt;br&gt;
&lt;code&gt;fg=&lt;/code&gt; is for the foreground color &lt;code&gt;bg=&lt;/code&gt; is to set the background color in between square brackets. Use &lt;code&gt;#[default]&lt;/code&gt; to back to the default colors.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#[fg=colour220] #h #[fg=colour47] #(ip addr | grep -e 'state UP' -A 2 | awk '/inet /{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #[colour27] #(sensors -f | awk '/CPU/{printf &lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}') #[default]"&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FWpygXGwZ%2Ftmux-status-line-color.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FWpygXGwZ%2Ftmux-status-line-color.png" alt="tmux-status-line-color.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The status lines can get quite long. If you do not like long lines use the backslash to break it up.&lt;/p&gt;


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

&lt;p&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#[fg=colour220]#h&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  [fg=colour196] #(ip addr | grep -e 'state UP' -A 2 | awk '/inet /{printf &lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour39] #(sensors | awk '/CPU/{printf &lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour40] #(free -m -h | awk '/Mem/{printf &lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="se"&gt;\"\/\"\$&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="se"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour128] #(free -m | awk '/Mem{printf 100*&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; %&lt;span class="s2"&gt;"}')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour202] #([ &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /sys/class/power_supply/AC/online&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; == 1 ] &amp;amp;&amp;amp; printf %s'🗲') #(cat /sys/class/power_supply/BAT0/capacity)&lt;/span&gt;&lt;span class="se"&gt;\%&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour7] #([ ! -z &lt;span class="si"&gt;$(&lt;/span&gt;ip a | egrep &lt;span class="s1"&gt;'ppp0|tun0'&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; 2 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf $2}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; ] &amp;amp;&amp;amp; echo &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ip a | egrep &lt;span class="s1"&gt;'ppp0|tun0'&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; 2 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf \"VPN \"$2}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [default]"
&lt;/h1&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Complete Status Line Configuration&lt;br&gt;
&lt;/h1&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;p&gt;&lt;span class="c"&gt;# .tmux.conf&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="nb"&gt;bind &lt;/span&gt;r source-file ~/.tmux.conf &lt;span class="se"&gt;\;&lt;/span&gt; display-message &lt;span class="s2"&gt;"RELOADING CONFIGURATION FILE…"&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;# STATUS LINE&lt;/span&gt;&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status on&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-interval 1&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-justify centre &lt;span class="c"&gt;# Careful! It is spelled "centre" not "center".&lt;/span&gt;&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-style &lt;span class="nb"&gt;fg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;white,bg&lt;span class="o"&gt;=&lt;/span&gt;black&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;# Highlight the current window.&lt;/span&gt;&lt;br&gt;
setw &lt;span class="nt"&gt;-g&lt;/span&gt; window-status-current-style &lt;span class="nb"&gt;fg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;white,bg&lt;span class="o"&gt;=&lt;/span&gt;red,bright&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;# LEFT STATUS&lt;/span&gt;&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left-length 100&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left-style default&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#[fg=colour220]#h&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  [fg=colour196] #(ip addr | grep -e 'state UP' -A 2 | awk '/inet /{printf &lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour39] #(sensors | awk '/CPU/{printf &lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;}')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour40] #(free -m -h | awk '/Mem/{printf &lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;3&lt;/span&gt;&lt;span class="se"&gt;\"\/\"\$&lt;/span&gt;&lt;span class="s2"&gt;2&lt;/span&gt;&lt;span class="se"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour128] #(free -m | awk '/Mem{printf 100*&lt;span class="nv"&gt;$2&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; %&lt;span class="s2"&gt;"}')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour202] #([ &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /sys/class/power_supply/AC/online&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; == 1 ] &amp;amp;&amp;amp; printf %s'🗲') #(cat /sys/class/power_supply/BAT0/capacity)&lt;/span&gt;&lt;span class="se"&gt;\%&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour7] #([ ! -z &lt;span class="si"&gt;$(&lt;/span&gt;ip a | egrep &lt;span class="s1"&gt;'ppp0|tun0'&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; 2 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf $2}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; ] &amp;amp;&amp;amp; echo &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ip a | egrep &lt;span class="s1"&gt;'ppp0|tun0'&lt;/span&gt; &lt;span class="nt"&gt;-A&lt;/span&gt; 2 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf \"VPN \"$2}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [default]"
&lt;/h1&gt;

&lt;p&gt;&lt;span class="c"&gt;# RIGHT STATUS&lt;/span&gt;&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right-length 100&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right-style default&lt;br&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right &lt;span class="s2"&gt;"#[fg=colour39] #(uptime | awk '{printf &lt;/span&gt;&lt;span class="se"&gt;\$&lt;/span&gt;&lt;span class="s2"&gt;(NF-2)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\"\$&lt;/span&gt;&lt;span class="s2"&gt;(NF-1)&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\"\$&lt;/span&gt;&lt;span class="s2"&gt;(NF)}' | tr -d ',')&lt;/span&gt;&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  [fg=colour40] %F&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour128] %T&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [fg=colour202] %Z&lt;span class="se"&gt;&amp;lt;/span&amp;gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;
  
  
  [default]"
&lt;/h1&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;You can now easily have a Bash display useful information on the Tmux status line. I hope you learned something new and enjoyed reading this article.&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://dev.to/brandonwallace"&gt;Dev.to&lt;/a&gt; and &lt;a href="https://github.com/brandon-wallace" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to leave comments, questions, and suggestions.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Easy Automatic Code Deployment With Git</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Mon, 08 Nov 2021 17:09:13 +0000</pubDate>
      <link>https://dev.to/brandonwallace/easy-automatic-code-deployment-with-git-igp</link>
      <guid>https://dev.to/brandonwallace/easy-automatic-code-deployment-with-git-igp</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;I will show you how to deploy code to a live server easily with Git.&lt;/p&gt;

&lt;p&gt;Let's say you have already &lt;a href="https://dev.to/brandonwallace/deploy-flask-the-easy-way-with-gunicorn-and-nginx-jgc"&gt;deployed your project&lt;/a&gt; to a live server. A few days later you receive valuable feedback on your project from another developer. You decide to make some improvements to the project. You work in your local Git repository to make the changes. You test everything to make sure it is working the way you intended it to work. Then you commit the changes in your code to your local Git repository. Then you push those changes to Github.&lt;/p&gt;

&lt;p&gt;How do you go about getting those improvements to the live server? Would you log into the server and meticulously edit the file manually?&lt;/p&gt;

&lt;p&gt;There is an easy way to deploy code to a live server - use Git. All you need it is the ability to SSH to the server.&lt;/p&gt;

&lt;p&gt;Here is the syntax for the git push command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ git push &amp;lt;repository&amp;gt; &amp;lt;branch_name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example:&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="nv"&gt;$ &lt;/span&gt;git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;origin&lt;/code&gt; is first repository that is set up and usually represents the repository connected to the Github website. &lt;/p&gt;

&lt;p&gt;To get code to a live server, I will create a second repository on the live server to push code to. I will call the second repository "prod" to represent the repository on the live production server. &lt;/p&gt;

&lt;p&gt;After pushing code to the "origin" repository I will be able to push to "prod" any code ready for production. &lt;/p&gt;

&lt;p&gt;When I am ready to push code to the production server I run this command.&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="nv"&gt;$ &lt;/span&gt;git push prod main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  On the server
&lt;/h2&gt;

&lt;p&gt;We need two directories on the server, one for the application which holds the production code, and one directory for the Git bare repository.&lt;/p&gt;

&lt;p&gt;Directory for production code:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/var/www/my_project/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Git bare repository:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/var/repos/my_project.git/&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Set up a repository on the server.
&lt;/h3&gt;

&lt;p&gt;The first step to set this up is to create a bare repository on the web server where you will run the application.&lt;/p&gt;

&lt;p&gt;SSH to your server. My server has the user &lt;code&gt;brandon&lt;/code&gt; and the IP address &lt;code&gt;123.45.67.89&lt;/code&gt;. So I use this command.&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="nv"&gt;$ &lt;/span&gt;ssh brandon@123.45.67.89
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the directory as a Git bare repository with a &lt;code&gt;.git&lt;/code&gt; at the end of the name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mkdir -p -v /var/repos/my_project.git/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the permissions on the directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo chown $USER:$USER /var/repos/my_project.git/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Move into the &lt;code&gt;my_project.git/&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /var/repos/my_project.git/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the git init --bare command inside the /var/repos/my_project.git/ directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git init --bare
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The directory structure should look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ tree --dirsfirst -F
.
├── branches/
├── hooks/
│   ├── applypatch-msg.sample*
│   ├── commit-msg.sample*
│   ├── fsmonitor-watchman.sample*
│   ├── post-update.sample*
│   ├── pre-applypatch.sample*
│   ├── pre-commit.sample*
│   ├── pre-merge-commit.sample*
│   ├── prepare-commit-msg.sample*
│   ├── pre-push.sample*
│   ├── pre-rebase.sample*
│   ├── pre-receive.sample*
│   ├── push-to-checkout.sample*
│   └── update.sample*
├── info/
│   └── exclude
├── objects/
│   ├── info/
│   └── pack/
├── refs/
│   ├── heads/
│   └── tags/
├── config
├── description
└── HEAD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating a hook to perform an action.
&lt;/h3&gt;

&lt;p&gt;A hook will allow you to run a script when a particular action occurs. There are hooks that run on the client and hooks that run on the server. I will set up the server-side hook &lt;code&gt;post-receive&lt;/code&gt; that will run once a git push has finished executing. &lt;/p&gt;

&lt;p&gt;Create a file called &lt;code&gt;post-receive&lt;/code&gt; in the hooks directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ touch hooks/post-receive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use any text editor to edit the post-receive file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ vim hooks/post-receive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following content, change the paths to reflect your set up.&lt;br&gt;
&lt;/p&gt;

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

git --work-tree=/var/www/my_project/ --git-dir=/var/repos/my_project.git checkout -f main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The post-receive script is not executable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls -lF hooks/post-receive 

-rw------- 1 brandon brandon 0 Nov  2 21:19 hooks/post-receive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make the script executable by running the &lt;code&gt;chmod&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ chmod +x hooks/post-receive

$ ls -lF hooks/post-receive 

-rwx------ 1 brandon brandon 0 Nov  2 21:19 hooks/post-receive*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  On my laptop
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Connect your local repository to the server repository.
&lt;/h3&gt;

&lt;p&gt;On the client machine where my local repository is located I will connect that repository to the one I created on the live server.&lt;/p&gt;

&lt;p&gt;Create a local repository with the same name as the directory on the server minus the &lt;code&gt;.git&lt;/code&gt; extension.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir my_project/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Move into the directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd my_project/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set up git in the project directory with a few basic files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git init

$ touch .gitignore readme.md LICENSE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add content to the readme.md file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ echo '# My Auto Deploy Project' &amp;gt;&amp;gt; readme.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With any text editor add a simple index.html file to the project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ vim index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following content to the index.html file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

  &amp;lt;head&amp;gt;

    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width,initial-scale=1" /&amp;gt;
    &amp;lt;meta name="description" content="My auto deploy project."&amp;gt;
    &amp;lt;link rel="stylesheet" href="style.css"&amp;gt;
    &amp;lt;title&amp;gt;Hello World!&amp;lt;/title&amp;gt;

  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;

    &amp;lt;h1&amp;gt;Hello World!&amp;lt;/h1&amp;gt;

  &amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add all the files to Git and commit the changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git add --all

$ git commit -m "First commit"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new repository on Github without the readme.md, .gitignore, or LICENSE. We have already created those files for the Github repository. Name the Github repository the same as the local repository. My local repository is called &lt;code&gt;my_project&lt;/code&gt; so I use the same name to create the Github repository. See screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FTwFkrsDr%2Fcreate-gh-repo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FTwFkrsDr%2Fcreate-gh-repo.png" alt="create-gh-repo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Connect the local repository to Github. Make sure the branch is called &lt;code&gt;main&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git remote add origin git@github.com:brandon-wallace/my_project.git

$ git branch -M main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set &lt;code&gt;origin&lt;/code&gt; as the default repository to push to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git push -u origin main

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 550 bytes | 550.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:brandon-wallace/my_project.git
 * [new branch]      main -&amp;gt; main
Branch 'main' set up to track remote branch 'main' from 'origin'.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have successfully connected the local repository to Github. Now I will connect the local repository to the live production server. My server has the IP address &lt;code&gt;123.45.67.89&lt;/code&gt; and SSH on port &lt;code&gt;22&lt;/code&gt; so I run this command with the full path to the &lt;code&gt;my_project.git&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;Syntax:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ git remote add &amp;lt;remote_repository&amp;gt; ssh://&amp;lt;username&amp;gt;@&amp;lt;server_ip&amp;gt;:&amp;lt;port&amp;gt;/path/to/&amp;lt;project&amp;gt;.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is the command I run.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git remote add prod ssh://brandon@123.45.67.89:22/var/repos/my_project.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I want to push code to the production server. I run this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git push prod main

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 550 bytes | 550.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Switched to branch 'main'
To 123.45.67.89:/var/www/my_project_repo/my_project.git
 * [new branch]      main -&amp;gt; main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;View the remotes. This shows that there are two remote repositories available, &lt;code&gt;prod&lt;/code&gt; and &lt;code&gt;origin&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git remote -v

prod    ssh://brandon@123.45.67.89:22/var/repos/my_project.git (fetch)
prod    ssh://brandon@123.45.67.89:22/var/repos/my_project.git (push)
origin  https://github.com/brandon-wallace/my_project.git (fetch)
origin  https://github.com/brandon-wallace/my_project.git (push)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I will make some changes to the project and push those to the production server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ touch style.css
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add some content to the CSS file with any text editor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ vim sytle.css

# Example content

html {
    font-size: 100%;
}

body {
    background: #FFFFFF;
    font-family: sans-serif;
    font-weight: 400;
    line-height: 1.75;
    color: #000000;
}

h1 {
    margin-top: 0;
    font-size: 3.052rem;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the new CSS file. Commit the changes to the repository.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git add style.css

$ git commit -m "Add CSS file"

# Output

[main 8881680] Add CSS file
 1 files changed, 27 insertions(+), 3 deletions(-)
 create mode 100644 style.css
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Right now, on the server I can see four files in &lt;code&gt;my_project/&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ /var/www/my_project/ $ ls -l
total 12
-rw-r--r-- 1 brandon brandon  319 Nov  7 10:25 index.html
-rw-r--r-- 1 brandon brandon    0 Nov  7 10:25 LICENSE
drwxr-xr-x 8 brandon brandon 4096 Nov  7 10:25 my_project.git
-rw-r--r-- 1 brandon brandon   25 Nov  7 10:25 readme.md

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push the changes to the production server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git push prod main

Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 623 bytes | 623.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Already on 'main'
To 123.45.67.89:/var/repos/my_project.git
   083f700..8881680  main -&amp;gt; main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now on the server I can see the &lt;code&gt;style.css&lt;/code&gt; I just pushed to the &lt;code&gt;prod&lt;/code&gt; repository running on the live server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/var/www/my_project $ ls -l
total 16
-rw-r--r-- 1 brandon brandon  362 Nov  7 10:56 index.html
-rw-r--r-- 1 brandon brandon    0 Nov  7 10:25 LICENSE
drwxr-xr-x 8 brandon brandon 4096 Nov  7 10:56 my_project.git
-rw-r--r-- 1 brandon brandon   25 Nov  7 10:25 readme.md
-rw-r--r-- 1 brandon brandon  365 Nov  7 10:56 style.css
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;First, check carefully for spelling errors is highly recommended.&lt;/p&gt;

&lt;p&gt;If you get &lt;code&gt;-bash: git: command not found&lt;/code&gt; error install &lt;code&gt;git&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt update

$ sudo apt install git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get the error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh: Could not resolve hostname github.com: Temporary failure in name resolution
fatal: Could not read from remote repository...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need to set up SSH keys on Github.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I hope you learn something new by reading this article. Using Git you can easily push changes to a project to a live production server. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fbrandon-wallace" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fbrandon-wallace" alt="Github"&gt;&lt;/a&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fbrandonwallace" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fbrandonwallace" alt="DEV.to"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to leave feedback, comments, or suggestions.&lt;/p&gt;

</description>
      <category>git</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How To Install Debian 11 Bullseye Expert Mode Minimal Install</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Tue, 24 Aug 2021 15:10:43 +0000</pubDate>
      <link>https://dev.to/brandonwallace/how-to-install-debian-11-bullseye-expert-mode-minimal-install-10pd</link>
      <guid>https://dev.to/brandonwallace/how-to-install-debian-11-bullseye-expert-mode-minimal-install-10pd</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;In this article, I will show you how to do a minimal installation of Debian 11 Bullseye in "Expert Install" mode.&lt;/p&gt;

&lt;p&gt;The Debian installer is very flexible. You can easily use the installation media to install Debian as a server or a desktop/laptop. I will go over a minimal installation step by step and include an option to install a desktop environment of your choice. Doing an "Expert Install" will provide you with a few advanced options which allow for better customization of the operating system.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Debian?
&lt;/h1&gt;

&lt;h3&gt;
  
  
  These are some of the reasons why people install Debian.
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Very stable and secure&lt;/li&gt;
&lt;li&gt;Has wide hardware support&lt;/li&gt;
&lt;li&gt;Is a community project of volunteers around the world&lt;/li&gt;
&lt;li&gt;Has a flexible installer that allows for customization&lt;/li&gt;
&lt;li&gt;Upgrades smoothly from one release to the next release&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Here are the requirements for Debian 11 Bullseye.
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Requirements&lt;/th&gt;
&lt;th&gt;Minimum&lt;/th&gt;
&lt;th&gt;Recommended&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RAM:&lt;/td&gt;
&lt;td&gt;512MB&lt;/td&gt;
&lt;td&gt;2GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Processor (CPU):&lt;/td&gt;
&lt;td&gt;1GHz&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hard Drive:&lt;/td&gt;
&lt;td&gt;10GB&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A minimal installation is great for a server set up. The benefit of setting up a server with a command line interface you will not use a lot of resources. &lt;/p&gt;

&lt;p&gt;Here is a server that contains &lt;strong&gt;2 gigabytes&lt;/strong&gt; of RAM. You see this server is using is only using &lt;strong&gt;61 megabytes&lt;/strong&gt; of RAM without a graphical user interface!&lt;/p&gt;

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

brandon@debian &lt;span class="nv"&gt;$ &lt;/span&gt;free &lt;span class="nt"&gt;-m&lt;/span&gt;
              total        used        free
Mem:           1982          61        1920
Swap:           975           0         975


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After installing the full Xfce desktop the RAM usage increased to &lt;strong&gt;311 megabytes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FnzG53f3n%2F74.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FnzG53f3n%2F74.png" alt="74.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use almost any computer for this. If you have some old hardware laying around such as a&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Desktop&lt;/li&gt;
&lt;li&gt;Laptop&lt;/li&gt;
&lt;li&gt;A Mac computer&lt;/li&gt;
&lt;li&gt;Used server hardware&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What can you do with a Linux server? Here are some examples.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/brandonwallace/set-up-a-git-server-the-easy-way-jke"&gt;Private Git server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Web server&lt;/li&gt;
&lt;li&gt;File server with NFS or Samba&lt;/li&gt;
&lt;li&gt;Media server&lt;/li&gt;
&lt;li&gt;Database server&lt;/li&gt;
&lt;li&gt;DNS server&lt;/li&gt;
&lt;li&gt;NTP server&lt;/li&gt;
&lt;li&gt;Email server&lt;/li&gt;
&lt;li&gt;Ad blocker&lt;/li&gt;
&lt;li&gt;Set up RAID (Redundant Array of Independent Disks)&lt;/li&gt;
&lt;li&gt;Explore the GNU/Linux operating system&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;p&gt;Download the amd64 Debian 11 Bullseye firmware-11.5.0-amd64-netinst.iso file from the Debian.org website. Pick the architecture supported by your computer. For example, if your computer is really old it might not support 64-bit (amd64). In that case, you will need the 32-bit ISO (i386) file.&lt;/p&gt;

&lt;p&gt;If you need non-free firmware to have drivers to set up for hardware such as WiFi use this ISO file to install Debian.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cdimage.debian.org/cdimage/unofficial/non-free/cd-including-firmware/current/amd64/iso-cd/" rel="noopener noreferrer"&gt;firmware-11.5.0-amd64-netinst.iso&lt;/a&gt; &lt;br&gt;
(&lt;strong&gt;Recommended&lt;/strong&gt; - includes non-free firmware)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.debian.org/distrib/" rel="noopener noreferrer"&gt;debian-11.5.0-amd64-netinst.iso&lt;/a&gt; &lt;br&gt;
(non-free firmware NOT included)&lt;/p&gt;

&lt;p&gt;Install the ISO file to a USB flash drive using one of these tools.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rufus.ie/en/" rel="noopener noreferrer"&gt;Rufus&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.balena.io/etcher/" rel="noopener noreferrer"&gt;Etcher&lt;/a&gt;&lt;br&gt;
&lt;a href="https://unetbootin.github.io/" rel="noopener noreferrer"&gt;Unetbootin&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/" rel="noopener noreferrer"&gt;Pendrive Linux&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If have Linux installed already you can run the &lt;code&gt;dd&lt;/code&gt; command to install the ISO to the USB flash drive.&lt;br&gt;
&lt;strong&gt;WARNING!!&lt;/strong&gt; If you use &lt;code&gt;dd&lt;/code&gt; make sure you write to the correct /dev/sdX drive. &lt;/p&gt;

&lt;p&gt;I list my drives in the computer like this.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;fdisk &lt;span class="nt"&gt;-l&lt;/span&gt; 2&amp;gt; /dev/null | egrep &lt;span class="s1"&gt;'Disk /dev/'&lt;/span&gt;

&lt;span class="c"&gt;# Output&lt;/span&gt;

Disk /dev/sdb: 254.8 GiB
Disk /dev/sda: 120.9 GiB 
Disk /dev/sdc: 15.9 GiB  &amp;lt;&lt;span class="o"&gt;==&lt;/span&gt; My USB flash drive



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;On my computer the flash drive is /dev/sdc so I run this command.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo dd &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;firmware-11.5.0-amd64-netinst.iso &lt;span class="nv"&gt;of&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sdc &lt;span class="nv"&gt;bs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4M &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;progress&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;sync&lt;/span&gt;

&lt;span class="c"&gt;# Or&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo dd &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;debian-11.5.0-amd64-netinst.iso &lt;span class="nv"&gt;of&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/dev/sdc &lt;span class="nv"&gt;bs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4M &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;progress&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;sync&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Find out how to boot off of the USB flash drive. Every manufacture has a different key to press to get to the boot menu. On my computer I press the &lt;code&gt;F12&lt;/code&gt; key to select the boot menu.&lt;/p&gt;

&lt;p&gt;Once you boot off of the USB flash drive the installation menu will come up.&lt;br&gt;
Select &lt;strong&gt;"Advanced options"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FT1KxZszB%2F1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FT1KxZszB%2F1.png" alt="1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select &lt;strong&gt;"Expert Install"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fg2FpTNNB%2F2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fg2FpTNNB%2F2.png" alt="2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose a language.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FSQHjmLgc%2F3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FSQHjmLgc%2F3.png" alt="3.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am choosing English because that is one of the languages I speak.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FW1v3kNL3%2F4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FW1v3kNL3%2F4.png" alt="4.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select your location to set the correct time zone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FsXqfDy43%2F5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FsXqfDy43%2F5.png" alt="5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The locale sets character encoding, date and time formatting, currency, default paper size, etc. The default setting should be fine. For US English the default is &lt;strong&gt;"en_US.UTF-8"&lt;/strong&gt;. No need to change this setting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fmgjb17yX%2F6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fmgjb17yX%2F6.png" alt="6.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You have the option to add additional locales here if you need them. I will use the default &lt;strong&gt;"en_US.UTF-8"&lt;/strong&gt; set on the previous page. Press "Continue".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F4NbGjpqf%2F7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F4NbGjpqf%2F7.png" alt="7.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can select the keyboard layout of your preference such as Dvorak. I will stick with the default &lt;strong&gt;"American English"&lt;/strong&gt; here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbY1f2Qzx%2F8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbY1f2Qzx%2F8.png" alt="8.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FxdBBXdhp%2F9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FxdBBXdhp%2F9.png" alt="9.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Time to detect the installation media which is the USB flash drive that you booted off earlier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FkMQL5qcw%2F10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FkMQL5qcw%2F10.png" alt="10.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Press "Continue".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FnrpRm9k2%2F11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FnrpRm9k2%2F11.png" alt="11.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Press "Continue".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbrmT2CdY%2F12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbrmT2CdY%2F12.png" alt="12.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Installer components get loaded from the USB installation media. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKzFrpSMv%2F13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKzFrpSMv%2F13.png" alt="13.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Optional specialized components can be selected here if you need them. By default nothing is selected. Press "Continue".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FG3XJKfhd%2F14.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FG3XJKfhd%2F14.png" alt="14.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Network hardware will be detected here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FmrWQhfVN%2F15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FmrWQhfVN%2F15.png" alt="15.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Configure the network connection.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FK8BM6pFK%2F16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FK8BM6pFK%2F16.png" alt="16.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Select "Yes"&lt;/strong&gt; to set the IP address using DHCP (Dynamic Host Control Protocol). This is recommended for a desktop/laptop. If you select "Yes", skip the "For a static IP" section. The IP address will be configured via DHCP and you will move on to setting the hostname.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Select "No"&lt;/strong&gt; to set a static IP address. A static IP address is recommended for a server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F6qRNzZJv%2F17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F6qRNzZJv%2F17.png" alt="17.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For a static IP&lt;/strong&gt; I set my IP address to &lt;code&gt;192.168.12.34&lt;/code&gt; since I know that will work on my network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FR0F5yyx9%2F18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FR0F5yyx9%2F18.png" alt="18.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For a static IP&lt;/strong&gt; I set the netmask to /24 which is &lt;code&gt;255.255.255.0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FX7cRJ4V4%2F19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FX7cRJ4V4%2F19.png" alt="19.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For a static IP&lt;/strong&gt; I set the gateway to &lt;code&gt;192.168.12.1&lt;/code&gt; because that is the gateway of my network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Ft44M46SN%2F20.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Ft44M46SN%2F20.png" alt="20.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For a static IP&lt;/strong&gt; I set three public DNS (Domain name servers) using a space as a delimiter.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;1.1.1.1&lt;/code&gt; &amp;lt;== Cloudflare DNS&lt;br&gt;
&lt;code&gt;208.67.222.222&lt;/code&gt; &amp;lt;== OpenDNS&lt;br&gt;
&lt;code&gt;8.8.8.8&lt;/code&gt; &amp;lt;== Google DNS&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F6pPY6mGB%2F21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F6pPY6mGB%2F21.png" alt="21.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For a static IP&lt;/strong&gt; Verify the networking information is correct. Click &lt;strong&gt;"Yes"&lt;/strong&gt; to accept the changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F7hqNQvjn%2F22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F7hqNQvjn%2F22.png" alt="22.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wait 3 seconds for the network link to be detected. Press "Continue".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FqMMLsTsk%2F23.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FqMMLsTsk%2F23.png" alt="23.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set the &lt;strong&gt;hostname&lt;/strong&gt; for the computer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FdVhjfjNp%2F24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FdVhjfjNp%2F24.png" alt="24.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set a &lt;strong&gt;domain name&lt;/strong&gt; for the system. It is better to make something up here. For more information see &lt;a href="https://datatracker.ietf.org/doc/html/rfc6762#appendix-G" rel="noopener noreferrer"&gt;RFC6762&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FwMtBz3Kq%2F25.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FwMtBz3Kq%2F25.png" alt="25.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set up users and passwords for the system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FwB0xsDgx%2F26.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FwB0xsDgx%2F26.png" alt="26.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enable shadow passwords. Select &lt;strong&gt;"Yes"&lt;/strong&gt; here. This is for security. Shadow passwords will allow the hashed password to be stored in /etc/shadow, which is only readable by root.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FHWJ5dk98%2F27.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FHWJ5dk98%2F27.png" alt="27.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For added security, select &lt;strong&gt;"No"&lt;/strong&gt; for "Allow login as root". Users will be able to type sudo to run root commands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FfW6dLQ82%2F28.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FfW6dLQ82%2F28.png" alt="28.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Type your full name here. Applications that display your &lt;strong&gt;full name&lt;/strong&gt; will use this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKvBM3pVZ%2F29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKvBM3pVZ%2F29.png" alt="29.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Type the user name which you will use to log into the computer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FzGNRCSZT%2F30.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FzGNRCSZT%2F30.png" alt="30.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set a strong password here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FSN6nx22R%2F31.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FSN6nx22R%2F31.png" alt="31.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Re-type the password you selected to make sure it is correct.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FBv6bpmhP%2F32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FBv6bpmhP%2F32.png" alt="32.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set the system clock.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FFRkR57X9%2F33.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FFRkR57X9%2F33.png" alt="33.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you wish to use NTP (Network Time Protocol) select &lt;strong&gt;"Yes"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fnzf8rzQV%2F34.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fnzf8rzQV%2F34.png" alt="34.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select a public NTP server close to where you live for the best outcome. I live in the United States so I set my NTP server to &lt;strong&gt;"0.us.pool.ntp.org"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FkMcrM7M9%2F35.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FkMcrM7M9%2F35.png" alt="35.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set the time zone you live in. I selected &lt;strong&gt;"Eastern"&lt;/strong&gt; since I live in the Eastern time zone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FMKTLWRrb%2F36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FMKTLWRrb%2F36.png" alt="36.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The installer will detect the disks connected to the system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FgkZvq2wb%2F37.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FgkZvq2wb%2F37.png" alt="37.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Partitioning the disks will allow us to divide the hard disk into sections. I select &lt;strong&gt;"Guided - use entire disk"&lt;/strong&gt; here to install on my empty 500GB hard drive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FQtKp4867%2F39.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FQtKp4867%2F39.png" alt="39.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FYq6xBStf%2F38.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FYq6xBStf%2F38.png" alt="38.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It displays I have one 500GB drive installed in the system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FPfgkFSqv%2F40.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FPfgkFSqv%2F40.png" alt="40.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the partitioning scheme you wish to use here. I recommend separating /home, /var, and /tmp partitions to for the following reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Separate data that needs backing up such as /home to make things easier.&lt;/li&gt;
&lt;li&gt;Isolate parts of the file system to increase security.&lt;/li&gt;
&lt;li&gt;Restrict the growth of a file system. If /var is filled it will not fill the whole disk.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbJGw1dm7%2F41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbJGw1dm7%2F41.png" alt="41.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the guided partitions are created select &lt;strong&gt;"Finish partitioning and write changes to disk"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F15yZQfpy%2F42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F15yZQfpy%2F42.png" alt="42.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The changes will be displayed to make sure that is how you want it. Select &lt;strong&gt;"Yes"&lt;/strong&gt; to write the changes to disk.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FrFg2FMJx%2F43.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FrFg2FMJx%2F43.png" alt="43.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install the packages for the base system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fbv7KFJyc%2F44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fbv7KFJyc%2F44.png" alt="44.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select a kernel to install in the system. &lt;code&gt;linux-image-amd64&lt;/code&gt; is the kernel generic package.&lt;br&gt;
&lt;code&gt;linux-image-5.10.0-8-amd64&lt;/code&gt; will just specify the exact version.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fnzq68Jrs%2F45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fnzq68Jrs%2F45.png" alt="45.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select &lt;strong&gt;"generic: include all available drivers"&lt;/strong&gt; to make sure you install the drivers you need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F2ywM674r%2F46.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F2ywM674r%2F46.png" alt="46.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Configure the package manager.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FBQSRzR06%2F47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FBQSRzR06%2F47.png" alt="47.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This option allows you to scan for extra installation media such as a DVD. We only have the USB we are using to install the operating system. Select "No" to scan extra installation media. Extra programs can be installed from a network mirror.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FvZDkY9Dw%2F48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FvZDkY9Dw%2F48.png" alt="48.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select "Yes" to use a network mirror. This will connect us to a online repository to access more software than what is on the installation USB.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F50WRSRgf%2F49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F50WRSRgf%2F49.png" alt="49.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select "http".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FD02pt4RD%2F50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FD02pt4RD%2F50.png" alt="50.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pick a network mirror that is closest to you for the fastest download.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FsxwHyDr2%2F51.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FsxwHyDr2%2F51.png" alt="51.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FsXvg5Kjf%2F52.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FsXvg5Kjf%2F52.png" alt="52.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Leave HTTP proxy information blank and select "Continue" unless you know you are using a proxy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FmDzTPDjt%2F53.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FmDzTPDjt%2F53.png" alt="53.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select use "non-free" software. Recommended for a desktop/laptop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F7hSDNWp4%2F54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F7hSDNWp4%2F54.png" alt="54.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source repositiories in APT will allow you to download the source code for packages. You can select "No" here. This can be enabled easily in /etc/apt/sources.list later if you want.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FZqgSzmmZ%2F55.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FZqgSzmmZ%2F55.png" alt="55.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is recommended to install security updates. Click "Continue".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FLsJcTW1W%2F56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FLsJcTW1W%2F56.png" alt="56.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select and install software.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F90YK056D%2F57.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F90YK056D%2F57.png" alt="57.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is your choice to have security updates installed automatically using the unattended-upgrades package. The default setting is to not run automatic security updates.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FfT51hs7F%2F58.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FfT51hs7F%2F58.png" alt="58.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can join the package survey if you wish here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fjdqkc9Vh%2F59.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fjdqkc9Vh%2F59.png" alt="59.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For a minimal Debian install I have deselected everything here except for "standard system utilities". This will provide you with a lean system that is not resource hungry. Remember other packages can be installed later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FQNmfFbBK%2F60.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FQNmfFbBK%2F60.png" alt="60.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install GRUB to the boot loader of the hard disk.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FZqPr1bpv%2F61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FZqPr1bpv%2F61.png" alt="61.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select "Yes" to install GRUB to the primary drive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FxCtL16s0%2F62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FxCtL16s0%2F62.png" alt="62.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have one drive in the computer, /dev/sda. I will select that option instead of entering it manually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKvLrnDj5%2F63.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKvLrnDj5%2F63.png" alt="63.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select "Yes" to force GRUB installation to the EFI removable media path to a fallback location just in case the EFI firmware does not meet the EFI specification.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FsXq7WMR8%2F64.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FsXq7WMR8%2F64.png" alt="64.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click "Enter" to finish the installation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FSN0cNYdY%2F65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FSN0cNYdY%2F65.png" alt="65.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click "Yes" to set the system clock to UTC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F0NNwHYkF%2F66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F0NNwHYkF%2F66.png" alt="66.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you wanted to set up a server, once you get to this point reboot the computer and your Debian installation is finished. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FSxgX8n6r%2F67.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FSxgX8n6r%2F67.png" alt="67.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you only wanted a minimal server you are done with the installation process. Click "Continue" to reboot. Remember to remove the USB flash drive installation media. Upon reboot you will be presented with this splash screen. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FRV9qD7Gd%2F68.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FRV9qD7Gd%2F68.png" alt="68.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  How to add a desktop environment
&lt;/h1&gt;

&lt;p&gt;If you wanted a graphical user interface sign in and install the desktop of your choice. You have many desktop options such as Xfce, Gnome, KDE, Mate, LXDE. See &lt;code&gt;task-xfce-desktop&lt;/code&gt; &lt;code&gt;task-gnome-desktop&lt;/code&gt; &lt;code&gt;task-kde-desktop&lt;/code&gt; etc.&lt;/p&gt;

&lt;p&gt;To install the Xfce desktop run these commands.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;task-xfce-desktop 

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl reboot



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After logging in you will be presented with the Xfce desktop.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F2ypQL1Q6%2F71.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F2ypQL1Q6%2F71.png" alt="71.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;I have shown you how to expert install of Debian 11 Bullseye step by step.&lt;br&gt;
You will be now able to use Debian's flexible installer to install a minimal server or a desktop/laptop.&lt;/p&gt;

&lt;p&gt;Thank you for reading my article.&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://dev.to/brandonwallace"&gt;Dev.to&lt;/a&gt; and &lt;a href="https://github.com/brandon-wallace" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Please feel free to leave comments, questions, and suggestions.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>opensource</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How To Use Vim Mode On The Command Line In Bash</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Fri, 11 Jun 2021 03:02:33 +0000</pubDate>
      <link>https://dev.to/brandonwallace/how-to-use-vim-mode-on-the-command-line-in-bash-fnn</link>
      <guid>https://dev.to/brandonwallace/how-to-use-vim-mode-on-the-command-line-in-bash-fnn</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Learn how to use Vi mode on the command line in Bash.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vim lovers rejoice.
&lt;/h2&gt;

&lt;p&gt;Did you know you can use Vim mode on the command line?&lt;/p&gt;

&lt;p&gt;After I found out you could enable Vim mode in bash &lt;br&gt;
&lt;code&gt;set -o vi&lt;/code&gt; is always the first line I add to by .bashrc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fv6txz59cza14rctno1p7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fv6txz59cza14rctno1p7.jpg" alt="set-vi-mode.jpg" width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article I will go over &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Movement &lt;/li&gt;
&lt;li&gt;Editing&lt;/li&gt;
&lt;li&gt;Searching&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By default, the Bash command line uses Emacs style keyboard shortcuts, such as CTRL+A to go to the beginning of the line and CTRL+E to go to the End of the line. &lt;/p&gt;

&lt;p&gt;Here is a small table that shows a comparison of the Emacs style keyboard shortcuts and the Vim equivalent on the command line.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Emacs&lt;/th&gt;
&lt;th&gt;Vim&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ctrl+A&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;Move cursor to beginning of line.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ctrl+E&lt;/td&gt;
&lt;td&gt;$&lt;/td&gt;
&lt;td&gt;Move cursor to end of line.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Alt+B&lt;/td&gt;
&lt;td&gt;b&lt;/td&gt;
&lt;td&gt;Move cursor back one word.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Alt+F&lt;/td&gt;
&lt;td&gt;w&lt;/td&gt;
&lt;td&gt;Move cursor right one word.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ctrl+B&lt;/td&gt;
&lt;td&gt;h&lt;/td&gt;
&lt;td&gt;Move cursor back one character.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ctrl+F&lt;/td&gt;
&lt;td&gt;l&lt;/td&gt;
&lt;td&gt;Move cursor right one character.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ctrl+P&lt;/td&gt;
&lt;td&gt;k&lt;/td&gt;
&lt;td&gt;Move up in Bash command history.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ctrl+R&lt;/td&gt;
&lt;td&gt;j&lt;/td&gt;
&lt;td&gt;Move down in Bash command history.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Add this line to the bottom of your &lt;code&gt;.bashrc&lt;/code&gt; file.&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;set&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; vi


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Source your &lt;code&gt;.bashrc&lt;/code&gt; file to make the changes take effect.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;After adding that line and sourcing the &lt;code&gt;.bashrc&lt;/code&gt; file, you now have Vim commands available on the Bash command line.&lt;/p&gt;

&lt;p&gt;You can perform a variety of commands Vim users are used to on the command line. &lt;/p&gt;

&lt;p&gt;If you are a Vim user already you know about command mode and insert mode. By default, in the Bash command line you are in insert mode.&lt;/p&gt;

&lt;p&gt;You must press &lt;code&gt;ESC&lt;/code&gt; to enter command mode.&lt;/p&gt;

&lt;p&gt;By the way, I am currently using Bash version 5.2.9.&lt;/p&gt;


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

&lt;p&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;bash &lt;span class="nt"&gt;--version&lt;/span&gt; | &lt;span class="nb"&gt;head&lt;/span&gt; &lt;span class="nt"&gt;-1&lt;/span&gt;&lt;br&gt;
GNU bash, version 5.2.9&lt;span class="o"&gt;(&lt;/span&gt;1&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nt"&gt;-release&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;x86_64-pc-linux-gnu&lt;span class="o"&gt;)&lt;/span&gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Movement&lt;br&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  This is how you move around.
&lt;/h3&gt;

&lt;p&gt;Out of the four Vim  movement keys &lt;code&gt;h j k l&lt;/code&gt; only &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;l&lt;/code&gt; work to move the cursor left and right.&lt;/p&gt;

&lt;p&gt;First press the &lt;code&gt;ESC&lt;/code&gt; key to make sure you are in command mode.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$&lt;/code&gt; Move the cursor to the end of the line.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0&lt;/code&gt; Move the cursor to the beginning of the line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fi4gc4dclf3lpm34xovet.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fi4gc4dclf3lpm34xovet.gif" alt="move-to-end-of-line.gif" width="675" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;W&lt;/code&gt; Move to the next word using space character as the delimiter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FPqdspBf1%2Fmove-to-next-word.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FPqdspBf1%2Fmove-to-next-word.gif" alt="move-to-next-word.gif" width="675" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;w&lt;/code&gt; Move to the next word or special character.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;B&lt;/code&gt; Move back one word using space character as the delimiter.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fc4T5krdt%2Fmove-back-one-word.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fc4T5krdt%2Fmove-back-one-word.gif" alt="move-back-one-word.gif" width="675" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;b&lt;/code&gt; Move back one word or special character.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;^&lt;/code&gt; Move to the first non-blank character at the beginning of the line.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;f&amp;lt;character&amp;gt;&lt;/code&gt; Find occurrence of the next character. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Examples&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;ft&lt;/code&gt; finds the next occurrence of the letter &lt;code&gt;t&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FdDMLqhtw%2Ffind-letter-t.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FdDMLqhtw%2Ffind-letter-t.gif" alt="find-letter-t.gif" width="675" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;f"&lt;/code&gt; finds the next occurrence of the double quote character &lt;code&gt;"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;;&lt;/code&gt; Press semi-colon to move to the next occurrence of the character.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;F&amp;lt;character&amp;gt;&lt;/code&gt; Performs a backward search for a character.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Examples&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;Ft&lt;/code&gt; finds the next occurrence of the letter &lt;code&gt;t&lt;/code&gt; backward search.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fd1kCwPmR%2Ffind-letter-t-backwards.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2Fd1kCwPmR%2Ffind-letter-t-backwards.gif" alt="find-letter-t-backwards.gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;F"&lt;/code&gt; finds the next occurrence of the double quote character &lt;code&gt;"&lt;/code&gt; backward search.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;;&lt;/code&gt; Press semi-colon to move to the next occurrence of the character.&lt;/p&gt;

&lt;h1&gt;
  
  
  Editing
&lt;/h1&gt;

&lt;h3&gt;
  
  
  This is how you edit text.
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;x&lt;/code&gt; Delete a single character under cursor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;X&lt;/code&gt; Delete the previous character.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FFFykhZXL%2Fdelete-previous-character.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FFFykhZXL%2Fdelete-previous-character.gif" alt="delete-previous-character.gif" width="675" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;I&lt;/code&gt; Enter insert mode with the cursor at the start of the line.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;A&lt;/code&gt; Enter insert mode at the end of the line to append text.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F02GYHvyh%2Fappend-to-end-of-line.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F02GYHvyh%2Fappend-to-end-of-line.gif" alt="append-to-end-of-line.gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cc&lt;/code&gt; Change the whole line. The whole line is deleted and puts you in insert mode.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;C&lt;/code&gt; Change text from the cursor to the end of the line.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ea&lt;/code&gt; Move cursor to the end of the word and enter insert mode to append text.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;y&lt;/code&gt; Yank (copy) word under cursor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Y&lt;/code&gt; Yank (copy) from the cursor to the end of the line.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;p&lt;/code&gt; or &lt;code&gt;P&lt;/code&gt; Paste the text you copied.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;r&lt;/code&gt; Replace the single character under the cursor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;R&lt;/code&gt; Replace the characters under the cursor as you type. &lt;br&gt;
This is like pressing the insert key on the keyboard while in a document editing program such as Libreoffice or Microsoft Word.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FPq0hGmFV%2Freplace-text.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FPq0hGmFV%2Freplace-text.gif" alt="replace-text.gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.&lt;/code&gt; Repeat the last command by pressing the period character. This is one of the most useful commands in Vim.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;u&lt;/code&gt; Undo last command. You can press this key multiple times to go back in time.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;~&lt;/code&gt; Toggle the case of the letter under the cursor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dd&lt;/code&gt; or &lt;code&gt;D&lt;/code&gt; To delete the whole line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKjCJxDMj%2Fdelete-whole-line.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKjCJxDMj%2Fdelete-whole-line.gif" alt="delete-whole-line.gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dw&lt;/code&gt; Delete current word under cursor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;d3w&lt;/code&gt; Delete three words.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;c2w&lt;/code&gt; Change two words. This deletes two words and puts you in insert mode.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;y2w&lt;/code&gt; Yank (copy) two words.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;xp&lt;/code&gt; Transpose letters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKzmf8WV1%2Ftranspose-letters.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FKzmf8WV1%2Ftranspose-letters.gif" alt="transpose-letters.gif" width="675" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Searching
&lt;/h1&gt;

&lt;h3&gt;
  
  
  This is how you search for a previous run command.
&lt;/h3&gt;

&lt;p&gt;You can search for commands by pressing forward slash &lt;code&gt;/&lt;/code&gt; and typing a part of a command you ran.&lt;br&gt;
It will find the last command you ran with the matching string.&lt;/p&gt;

&lt;p&gt;I want to search for the last gunicorn command so I type &lt;code&gt;/gunicorn&lt;/code&gt; and press ENTER.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FVLLYC9pp%2Fvim-search.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FVLLYC9pp%2Fvim-search.gif" alt="vim-search.gif" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;If you enjoy using the Vim text editor you will be happy to know that you can also use a few Vim commands on the command line.&lt;/p&gt;

&lt;p&gt;View my &lt;a href="https://github.com/brandon-wallace/vimrc" rel="noopener noreferrer"&gt;.vimrc&lt;/a&gt; file.&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://github.com/brandon-wallace" rel="noopener noreferrer"&gt;Github&lt;/a&gt; and &lt;a href="https://dev.to/brandonwallace"&gt;DEV.to&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>vim</category>
      <category>bash</category>
      <category>linux</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Top Firefox Extensions For Developers 🔥🚀</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Sun, 07 Mar 2021 13:54:07 +0000</pubDate>
      <link>https://dev.to/brandonwallace/top-firefox-extensions-for-developers-3l5j</link>
      <guid>https://dev.to/brandonwallace/top-firefox-extensions-for-developers-3l5j</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;div class="ltag__link__content"&gt;
    &lt;div class="missing"&gt;
      &lt;h2&gt;Article No Longer Available&lt;/h2&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Here are some great Firefox extensions for developers which will make you more productive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FW3Qk2JPM%2Fwappalyzer-img.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FW3Qk2JPM%2Fwappalyzer-img.png" alt="wappalyzer-img.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1 - &lt;a href="https://www.wappalyzer.com/" rel="noopener noreferrer"&gt;Wappalyzer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wappalyzer will identify technologies used on websites.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FFHW1rJy7%2Fstylus-img.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FFHW1rJy7%2Fstylus-img.png" alt="stylus-img.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2 - &lt;a href="https://add0n.com/stylus.html" rel="noopener noreferrer"&gt;Stylus&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use Stylus to redesign, edit, create, and manage a website's CSS.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FY0zqJ422%2Fjsonview.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FY0zqJ422%2Fjsonview.png" alt="jsonview.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3 - &lt;a href="https://jsonview.com/" rel="noopener noreferrer"&gt;JSON View&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;View JSON document in the browser formatted and highlighted.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbwDfnDXG%2Fhtml-validator.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbwDfnDXG%2Fhtml-validator.png" alt="html-validator.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4 - &lt;a href="http://users.skynet.be/mgueury/mozilla/" rel="noopener noreferrer"&gt;HTML Validator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Validate HTML on a webpage.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F9fy3x6QC%2Fmeasure-it.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F9fy3x6QC%2Fmeasure-it.png" alt="measure-it.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5 - &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/measure-it/" rel="noopener noreferrer"&gt;Measure-it&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Measure elements on the webpage.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FpTBwvKjS%2Frest-client.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FpTBwvKjS%2Frest-client.png" alt="rest-client.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6 - &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/restclient/?utm_source=addons.mozilla.org&amp;amp;utm_medium=referral&amp;amp;utm_content=search" rel="noopener noreferrer"&gt;REST Client&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make custom HTTP request for testing purposes.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FC5P9BYmH%2Fcolorzilla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FC5P9BYmH%2Fcolorzilla.png" alt="colorzilla.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7 - &lt;a href="https://www.colorzilla.com/" rel="noopener noreferrer"&gt;ColorZilla&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Many features related to selecting colors.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FHsnqGckS%2Fselenium-ide.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FHsnqGckS%2Fselenium-ide.png" alt="selenium-ide.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;8 - &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/?utm_source=addons.mozilla.org&amp;amp;utm_medium=referral&amp;amp;utm_content=search" rel="noopener noreferrer"&gt;Selenium IDE&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Extension that allows you to record, edit, and debug tests.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FNGJnxskR%2Fweb-developer.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FNGJnxskR%2Fweb-developer.png" alt="web-developer.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;9 - &lt;a href="https://chrispederick.com/work/web-developer/" rel="noopener noreferrer"&gt;Web Developer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add various web developer tools to your browser.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FTw2krFyk%2Fwhatfont.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FTw2krFyk%2Fwhatfont.png" alt="whatfont.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;10 - &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/zjm-whatfont/?utm_source=addons.mozilla.org&amp;amp;utm_medium=referral&amp;amp;utm_content=search" rel="noopener noreferrer"&gt;WhatFont&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Inspect fonts contained on a page.&lt;/p&gt;

&lt;p&gt;Comment on your favorite extension!&lt;/p&gt;




&lt;p&gt;Linked article: Go check out this awesome list of &lt;a href="https://dev.to/devlorenzo/top-google-chrome-extensions-for-devs-2mkf"&gt;Chrome extensions&lt;/a&gt; by &lt;a href="https://dev.to/devlorenzo"&gt;DevLorenzo&lt;/a&gt; 🚀&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;div class="ltag__link__content"&gt;
    &lt;div class="missing"&gt;
      &lt;h2&gt;Article No Longer Available&lt;/h2&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;





&lt;p&gt;Cover image by &lt;a href="https://pixabay.com/users/geralt-9301/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=773217" rel="noopener noreferrer"&gt;Gerd Altmann&lt;/a&gt; on &lt;a href="https://pixabay.com/?utm_source=link-attribution&amp;amp;utm_medium=referral&amp;amp;utm_campaign=image&amp;amp;utm_content=773217" rel="noopener noreferrer"&gt;Pixabay&lt;/a&gt;&lt;/p&gt;




</description>
    </item>
    <item>
      <title>Show Off Your Mechanical Keyboard</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Mon, 01 Mar 2021 03:26:44 +0000</pubDate>
      <link>https://dev.to/brandonwallace/show-off-your-mechanical-keyboard-556l</link>
      <guid>https://dev.to/brandonwallace/show-off-your-mechanical-keyboard-556l</guid>
      <description>&lt;p&gt;Mechanical keyboards have become extremely popular during the last few years.&lt;br&gt;
Many people find the experience of typing on a mechanical keyboard highly enjoyable compared to that of typing on the common membrane keyboard.&lt;br&gt;
Mechanical keyboards come in all shapes, sizes, and colors and some of the mechanical keyboards are customizable. Some people are even building their own mechanical keyboards. I have seen people that have gone to great lengths to customize their keyboards with stunning results.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FZ52HpZ4n%2Ftyping-cat2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FZ52HpZ4n%2Ftyping-cat2.gif" alt="typing-cat2.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even cats are fans of mechanical keyboards.&lt;/p&gt;




&lt;h1&gt;
  
  
  My mechanical keyboard
&lt;/h1&gt;

&lt;p&gt;Here is an image my mechanical keyboard. When I was searching for a mechanical keyboard my only requirements were blank keys and to have the escape key be red. Blank keys really assist a person in becoming a touch typist (with the blank keys actually I have no issues typing passwords.)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FCKnvQ5mb%2Fmy-blank-keyboard-1500x880.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FCKnvQ5mb%2Fmy-blank-keyboard-1500x880.jpg" alt="my-blank-keyboard-1500x880.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Specifications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Size: 100% Full size 104 keys (445 x 142 x 30mm)&lt;/li&gt;
&lt;li&gt;Switches: Cherry MX Brown switches&lt;/li&gt;
&lt;li&gt;Cable: Braided non-removable USB cable&lt;/li&gt;
&lt;li&gt;Weight: 1088g (2.4lbs)&lt;/li&gt;
&lt;li&gt;Backlighting: none&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Tell us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How has your experience been typing on a mechanical keyboard?&lt;/li&gt;
&lt;li&gt;What kind of switches do you have?&lt;/li&gt;
&lt;li&gt;What keyboard layout do you use?&lt;/li&gt;
&lt;li&gt;What size keyboard do you prefer?&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>productivity</category>
      <category>keyboard</category>
      <category>watercooler</category>
    </item>
    <item>
      <title>Make Your Tmux Status Bar 100% Better With Bash</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Sat, 20 Feb 2021 23:02:33 +0000</pubDate>
      <link>https://dev.to/brandonwallace/make-your-tmux-status-bar-100-better-with-bash-2fne</link>
      <guid>https://dev.to/brandonwallace/make-your-tmux-status-bar-100-better-with-bash-2fne</guid>
      <description>&lt;p&gt;This article has been re-written &lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/brandonwallace/make-your-tmux-status-line-100-better-with-bash-mgf"&gt;Make Your Status Line 100% Better With Bash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did you know that you can easily have a Bash script display information on the Tmux status bar? Because of that the possibilities are almost endless. You can display all sorts of valuable information such as:&lt;/p&gt;

&lt;p&gt;Included in this article:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hostname&lt;/li&gt;
&lt;li&gt;IP address&lt;/li&gt;
&lt;li&gt;Netmask&lt;/li&gt;
&lt;li&gt;Memory usage&lt;/li&gt;
&lt;li&gt;Memory total&lt;/li&gt;
&lt;li&gt;CPU temperature&lt;/li&gt;
&lt;li&gt;System load&lt;/li&gt;
&lt;li&gt;Battery meter&lt;/li&gt;
&lt;li&gt;VPN status&lt;/li&gt;
&lt;li&gt;Time&lt;/li&gt;
&lt;li&gt;Date&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not included in article:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Weather report&lt;/li&gt;
&lt;li&gt;Gateway&lt;/li&gt;
&lt;li&gt;Git status&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will show you how to create a modular Bash script to display useful information in the status bar. There are a lot of plug-ins you could install for Tmux but engineering things yourself is a lot of fun. I will create a separate function for each status bar item to make the script modular, that way we will only call the functions that we need.&lt;/p&gt;

&lt;p&gt;Here is the default status bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F9Q9fM9YJ%2Ftmux-default-status-bar.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F9Q9fM9YJ%2Ftmux-default-status-bar.png" alt="tmux-default-status-bar.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the status bar customized.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F0QPGZPN1%2Ftmux-status-bar-improved.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2F0QPGZPN1%2Ftmux-status-bar-improved.png" alt="tmux-status-bar-improved.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirments
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;lm-sensors&lt;/li&gt;
&lt;li&gt;bc&lt;/li&gt;
&lt;li&gt;acpi&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check your Tmux version. I am using version 3.1.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;tmux &lt;span class="nt"&gt;-V&lt;/span&gt;

&lt;span class="c"&gt;# Output&lt;/span&gt;
tmux 3.1c


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you do not have a .tmux.conf create one in your home directory. &lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; .tmux.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the .tmux.conf make sure you have the following lines.&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;# Status bar&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status on
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-interval 1
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-justify centre &lt;span class="c"&gt;# Careful! It is spelled centre not center.&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-style &lt;span class="nb"&gt;fg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;white,bg&lt;span class="o"&gt;=&lt;/span&gt;black

&lt;span class="c"&gt;# Highlight the current window.&lt;/span&gt;
setw &lt;span class="nt"&gt;-g&lt;/span&gt; window-status-current-style &lt;span class="nb"&gt;fg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;white,bg&lt;span class="o"&gt;=&lt;/span&gt;red,bright

&lt;span class="c"&gt;# Status Bar Left side&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left-length 50
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left-style default
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#h #( ~/.tmux/left_status.sh )"&lt;/span&gt;

&lt;span class="c"&gt;# Status Bar Right side&lt;/span&gt;
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right-length 40
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right-style default
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-right &lt;span class="s2"&gt;"#( ~/.tmux/right_status.sh )"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Make a hidden folder in your home directory to save your Bash scripts. &lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; .tmux


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Make two Bash scripts, one for the left side, one for the right.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; ~/.tmux/right_status.sh
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; ~/.tmux/left_status.sh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The scripts are currently not executable ( rw-r--r-- ).&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-lF&lt;/span&gt; ~/.tmux/&lt;span class="k"&gt;*&lt;/span&gt;.sh
&lt;span class="nt"&gt;-rw-r--r--&lt;/span&gt; 1 bw bw    0 Feb 19 18:44 /home/bw/.tmux/right_status.sh
&lt;span class="nt"&gt;-rw-r--r--&lt;/span&gt; 1 bw bw    0 Feb 19 18:44 /home/bw/.tmux/left_status.sh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Make the scripts executable so they will run the chmod command.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x ~/.tmux/right_status.sh
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x ~/.tmux/left_status.sh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The scripts are now executable ( rwxr-xr-x ).&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-lF&lt;/span&gt; ~/.tmux/&lt;span class="k"&gt;*&lt;/span&gt;.sh
&lt;span class="nt"&gt;-rwxr-xr-x&lt;/span&gt; 1 bw bw    0 Feb 19 18:44 /home/bw/.tmux/right_status.sh&lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="nt"&gt;-rwxr-xr-x&lt;/span&gt; 1 bw bw    0 Feb 19 18:44 /home/bw/.tmux/left_status.sh&lt;span class="k"&gt;*&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Status Bar Left Side
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FmrfZvrMJ%2Ftmux-status-left-side.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FmrfZvrMJ%2Ftmux-status-left-side.png" alt="tmux-status-left-side.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First edit the left_status.sh script. Add the following content. The ip_address function displays the IP address and netmask.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ vim ~/.tmux/left_status.sh&lt;/code&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="k"&gt;function &lt;/span&gt;ip_address&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;# Loop through the interfaces and check for the interface that is up.&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;file &lt;span class="k"&gt;in&lt;/span&gt; /sys/class/net/&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do

        &lt;/span&gt;&lt;span class="nv"&gt;iface&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nb"&gt;read &lt;/span&gt;status &amp;lt; &lt;span class="nv"&gt;$file&lt;/span&gt;/operstate&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$status&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"up"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip addr show &lt;span class="nv"&gt;$iface&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf $2" "}'&lt;/span&gt;

    &lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Underneath the IP address function add the CPU function. You must install lm-sensors for this to work. Run these two commands.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;lm-sensors

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;sensors-detect


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run the sensors command to see the output.&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;# Celcius&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;sensors

&lt;span class="c"&gt;# Output&lt;/span&gt;
acpitz-acpi-0
Adapter: ACPI interface
temp1:        +27.8°C  &lt;span class="o"&gt;(&lt;/span&gt;crit &lt;span class="o"&gt;=&lt;/span&gt; +105.0°C&lt;span class="o"&gt;)&lt;/span&gt;
temp2:        +29.8°C  &lt;span class="o"&gt;(&lt;/span&gt;crit &lt;span class="o"&gt;=&lt;/span&gt; +105.0°C&lt;span class="o"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;# Fahrenheit&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;sensors &lt;span class="nt"&gt;-f&lt;/span&gt;

&lt;span class="c"&gt;# Output&lt;/span&gt;
acpitz-acpi-0
Adapter: ACPI interface
temp1:        +82.0°F  &lt;span class="o"&gt;(&lt;/span&gt;crit &lt;span class="o"&gt;=&lt;/span&gt; +221.0°F&lt;span class="o"&gt;)&lt;/span&gt;
temp2:        +85.6°F  &lt;span class="o"&gt;(&lt;/span&gt;crit &lt;span class="o"&gt;=&lt;/span&gt; +221.0°F&lt;span class="o"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add the cpu_temperature function below the ip_address function.&lt;/p&gt;

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

&lt;span class="k"&gt;function &lt;/span&gt;cpu_temperature&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;# Display the temperature of CPU core 0 and core 1.&lt;/span&gt;
    sensors &lt;span class="nt"&gt;-f&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/Core 0/{printf $3" "}/Core 1/{printf $3" "}'&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To see the memory usage we will add a memory_usage function. We need the bc command to calculate the percentage of memory used. &lt;/p&gt;

&lt;p&gt;Install bc command.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;bc


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add the memory_usage function to the script.&lt;/p&gt;

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

&lt;span class="k"&gt;function &lt;/span&gt;memory_usage&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;which bc&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;

        &lt;span class="c"&gt;# Display used, total, and percentage of memory using the free command.&lt;/span&gt;
        &lt;span class="nb"&gt;read &lt;/span&gt;used total &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;free &lt;span class="nt"&gt;-m&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/Mem/{printf $2" "$3}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
        &lt;span class="c"&gt;# Calculate the percentage of memory used with bc.&lt;/span&gt;
        &lt;span class="nv"&gt;percent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;bc &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"100 * &lt;/span&gt;&lt;span class="nv"&gt;$total&lt;/span&gt;&lt;span class="s2"&gt; / &lt;/span&gt;&lt;span class="nv"&gt;$used&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
        &lt;span class="c"&gt;# Feed the variables into awk and print the values with formating.&lt;/span&gt;
        &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;u&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$used&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$total&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$percent&lt;/span&gt; &lt;span class="s1"&gt;'BEGIN {printf "%sMi/%sMi %.1f% ", t, u, p}'&lt;/span&gt;

    &lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The next function will display if the VPN is up by checking for the tun0 interface.&lt;/p&gt;

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

&lt;span class="k"&gt;function &lt;/span&gt;vpn_connection&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;# Check for tun0 interface.&lt;/span&gt;
    &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; /sys/class/net/tun0 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s "&lt;/span&gt; &lt;span class="s1"&gt;'VPN*'&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To complete the left_status.sh script we will use a main function to call the other functions.&lt;/p&gt;

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

&lt;span class="k"&gt;function &lt;/span&gt;main&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;# Comment out any function you do not need. &lt;/span&gt;
    ip_address
    cpu_temperature
    memory_usage
    vpn_connection

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Calling the main function which will call the other functions.&lt;/span&gt;
main


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Status Bar Right Side
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FqMNkgKxW%2Ftmux-status-right-side.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FqMNkgKxW%2Ftmux-status-right-side.png" alt="tmux-status-right-side.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s configure the right side.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ vim ~/.tmux/right_status.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The battery meter function displays the level of the battery and changes color depending on the battery level. &lt;br&gt;
We need the acpi program for this. &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;acpi


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run acpi to see the output.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;acpi

&lt;span class="c"&gt;# Output&lt;/span&gt;
Battery 0: Unknown, 96%


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If your terminal supports &lt;a href="https://unicode-table.com/en/emoji/" rel="noopener noreferrer"&gt;emojis&lt;/a&gt; you can add an emoji to the status bar.&lt;/p&gt;

&lt;p&gt;I will add the lighting bolt emoji to show when the battery is charging.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FvBXvJnnS%2Femoji-icon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FvBXvJnnS%2Femoji-icon.png" alt="emoji-icon.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add the battery_meter function to the Bash script. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ vim ~/.tmux/right_status.sh&lt;/code&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="k"&gt;function &lt;/span&gt;battery_meter&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;which acpi&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;

        &lt;span class="c"&gt;# Set the default color to the local variable fgdefault.&lt;/span&gt;
        &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;fgdefault&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#[default]'&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; /sys/class/power_supply/AC/online&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; 1 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then

            &lt;/span&gt;&lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'🗲'&lt;/span&gt;
            &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;charging&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'+'&lt;/span&gt; 

        &lt;span class="k"&gt;else

            &lt;/span&gt;&lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;
            &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;charging&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'-'&lt;/span&gt;

        &lt;span class="k"&gt;fi&lt;/span&gt;

        &lt;span class="c"&gt;# Check for existence of a battery.&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; /sys/class/power_supply/BAT0 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then

            &lt;/span&gt;&lt;span class="nv"&gt;batt0&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;acpi &lt;span class="nt"&gt;-b&lt;/span&gt; 2&amp;gt; /dev/null | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/Battery 0/{print $4}'&lt;/span&gt; | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt;, &lt;span class="nt"&gt;-f1&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nv"&gt;$batt0&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;

                &lt;span class="c"&gt;# From 100% to 75% display color grey.&lt;/span&gt;
                100%|9[0-9]%|8[0-9]%|7[5-9]%&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;fgcolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#[fg=brightgrey]'&lt;/span&gt; 
                    &lt;span class="p"&gt;;;&lt;/span&gt;

                &lt;span class="c"&gt;# From 74% to 50% display color green.&lt;/span&gt;
                7[0-4]%|6[0-9]%|5[0-9]%&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;fgcolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#[fg=brightgreen]'&lt;/span&gt; 
                    &lt;span class="p"&gt;;;&lt;/span&gt;

                &lt;span class="c"&gt;# From 49% to 25% display color yellow.&lt;/span&gt;
                4[0-9]%|3[0-9]%|2[5-9]%&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;fgcolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#[fg=brightyellow]'&lt;/span&gt; 
                    &lt;span class="p"&gt;;;&lt;/span&gt;

                &lt;span class="c"&gt;# From 24% to 0% display color red.&lt;/span&gt;
                2[0-4]%|1[0-9]%|[0-9]%&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;fgcolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#[fg=brightred]'&lt;/span&gt;
                    &lt;span class="p"&gt;;;&lt;/span&gt;
            &lt;span class="k"&gt;esac&lt;/span&gt;

            &lt;span class="c"&gt;# Display the percentage of charge the battery has.&lt;/span&gt;
            &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s "&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;fgcolor&lt;/span&gt;&lt;span class="k"&gt;}${&lt;/span&gt;&lt;span class="nv"&gt;icon&lt;/span&gt;&lt;span class="k"&gt;}${&lt;/span&gt;&lt;span class="nv"&gt;charging&lt;/span&gt;&lt;span class="k"&gt;}${&lt;/span&gt;&lt;span class="nv"&gt;batt0&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;%&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;fgdefault&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

        &lt;span class="k"&gt;fi
    fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The next function will add to the script is to get the load average using the uptime command.&lt;/p&gt;

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

&lt;span class="k"&gt;function &lt;/span&gt;load_average&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s "&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;uptime&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;: &lt;span class="s1"&gt;'{printf $NF}'&lt;/span&gt; | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To see the time, date, and timezone add the date_time function to the Bash script.&lt;/p&gt;

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

&lt;span class="k"&gt;function &lt;/span&gt;date_time&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s "&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;date&lt;/span&gt; +&lt;span class="s1"&gt;'%Y-%m-%d %H:%M:%S %Z'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The last function is the main function which calls the other functions.&lt;/p&gt;

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

&lt;span class="k"&gt;function &lt;/span&gt;main&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    battery_meter
    load_average
    date_time

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Calling the main function which will call the other functions.&lt;/span&gt;
main


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Complete Scripts
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;$ cat ~/.tmux/left_status.sh&lt;/code&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="k"&gt;function &lt;/span&gt;ip_address&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;# Loop through the interfaces and check for the interface that is up.&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;file &lt;span class="k"&gt;in&lt;/span&gt; /sys/class/net/&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do

        &lt;/span&gt;&lt;span class="nv"&gt;iface&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nb"&gt;read &lt;/span&gt;status &amp;lt; &lt;span class="nv"&gt;$file&lt;/span&gt;/operstate&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$status&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"up"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip addr show &lt;span class="nv"&gt;$iface&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/inet /{printf $2" "}'&lt;/span&gt;

    &lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;function &lt;/span&gt;cpu_temperature&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;# Display the temperature of CPU core 0 and core 1.&lt;/span&gt;
    sensors &lt;span class="nt"&gt;-f&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/Core 0/{printf $3" "}/Core 1/{printf $3" "}'&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;function &lt;/span&gt;memory_usage&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;which bc&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;

        &lt;span class="c"&gt;# Display used, total, and percentage of memory using the free command.&lt;/span&gt;
        &lt;span class="nb"&gt;read &lt;/span&gt;used total &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;free &lt;span class="nt"&gt;-m&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'/Mem/{printf $2" "$3}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
        &lt;span class="c"&gt;# Calculate the percentage of memory used with bc.&lt;/span&gt;
        &lt;span class="nv"&gt;percent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;bc &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s2"&gt;"100 * &lt;/span&gt;&lt;span class="nv"&gt;$total&lt;/span&gt;&lt;span class="s2"&gt; / &lt;/span&gt;&lt;span class="nv"&gt;$used&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
        &lt;span class="c"&gt;# Feed the variables into awk and print the values with formating.&lt;/span&gt;
        &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;u&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$used&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$total&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="nv"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$percent&lt;/span&gt; &lt;span class="s1"&gt;'BEGIN {printf "%sMi/%sMi %.1f% ", t, u, p}'&lt;/span&gt;

    &lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;function &lt;/span&gt;vpn_connection&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;# Check for tun0 interface.&lt;/span&gt;
    &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; /sys/class/net/tun0 &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"%s "&lt;/span&gt; &lt;span class="s1"&gt;'VPN*'&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;function &lt;/span&gt;main&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="c"&gt;# Comment out any function you do not need. &lt;/span&gt;
    ip_address
    cpu_temperature
    memory_usage
    vpn_connection

&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Calling the main function which will call the other functions.&lt;/span&gt;
main


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;$ cat ~/.tmux/right_status.sh&lt;/code&gt;&lt;/p&gt;


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

&lt;p&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="k"&gt;function &lt;/span&gt;battery_meter&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;span class="k"&amp;gt;if&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;[&amp;lt;/span&amp;gt; &amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt;&amp;lt;span class="si"&amp;gt;$(&amp;lt;/span&amp;gt;which acpi&amp;lt;span class="si"&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;]&amp;lt;/span&amp;gt;&amp;lt;span class="p"&amp;gt;;&amp;lt;/span&amp;gt; &amp;lt;span class="k"&amp;gt;then&amp;lt;/span&amp;gt;

    &amp;lt;span class="c"&amp;gt;# Set the default color to the local variable fgdefault.&amp;lt;/span&amp;gt;
    &amp;lt;span class="nb"&amp;gt;local &amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;fgdefault&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;'#[default]'&amp;lt;/span&amp;gt;

    &amp;lt;span class="k"&amp;gt;if&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;[&amp;lt;/span&amp;gt; &amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt;&amp;lt;span class="si"&amp;gt;$(&amp;lt;/span&amp;gt;&amp;lt;span class="nb"&amp;gt;cat&amp;lt;/span&amp;gt; /sys/class/power_supply/AC/online&amp;lt;span class="si"&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;==&amp;lt;/span&amp;gt; 1 &amp;lt;span class="o"&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class="p"&amp;gt;;&amp;lt;/span&amp;gt; &amp;lt;span class="k"&amp;gt;then

        &amp;lt;/span&amp;gt;&amp;lt;span class="nb"&amp;gt;local &amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;icon&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;'🗲'&amp;lt;/span&amp;gt;
        &amp;lt;span class="nb"&amp;gt;local &amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;charging&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;'+'&amp;lt;/span&amp;gt; 

    &amp;lt;span class="k"&amp;gt;else

        &amp;lt;/span&amp;gt;&amp;lt;span class="nb"&amp;gt;local &amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;icon&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;''&amp;lt;/span&amp;gt;
        &amp;lt;span class="nb"&amp;gt;local &amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;charging&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;'-'&amp;lt;/span&amp;gt;
    &amp;lt;span class="k"&amp;gt;fi&amp;lt;/span&amp;gt;

    &amp;lt;span class="c"&amp;gt;# Check for existence of a battery.&amp;lt;/span&amp;gt;
    &amp;lt;span class="k"&amp;gt;if&amp;lt;/span&amp;gt; &amp;lt;span class="o"&amp;gt;[&amp;lt;/span&amp;gt; &amp;lt;span class="nt"&amp;gt;-x&amp;lt;/span&amp;gt; /sys/class/power_supply/BAT0 &amp;lt;span class="o"&amp;gt;]&amp;lt;/span&amp;gt; &amp;lt;span class="p"&amp;gt;;&amp;lt;/span&amp;gt; &amp;lt;span class="k"&amp;gt;then

        &amp;lt;/span&amp;gt;&amp;lt;span class="nb"&amp;gt;local &amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;batt0&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="si"&amp;gt;$(&amp;lt;/span&amp;gt;acpi &amp;lt;span class="nt"&amp;gt;-b&amp;lt;/span&amp;gt; 2&amp;amp;gt; /dev/null | &amp;lt;span class="nb"&amp;gt;awk&amp;lt;/span&amp;gt; &amp;lt;span class="s1"&amp;gt;'/Battery 0/{print $4}'&amp;lt;/span&amp;gt; | &amp;lt;span class="nb"&amp;gt;cut&amp;lt;/span&amp;gt; &amp;lt;span class="nt"&amp;gt;-d&amp;lt;/span&amp;gt;, &amp;lt;span class="nt"&amp;gt;-f1&amp;lt;/span&amp;gt;&amp;lt;span class="si"&amp;gt;)&amp;lt;/span&amp;gt;

        &amp;lt;span class="k"&amp;gt;case&amp;lt;/span&amp;gt; &amp;lt;span class="nv"&amp;gt;$batt0&amp;lt;/span&amp;gt; &amp;lt;span class="k"&amp;gt;in&amp;lt;/span&amp;gt;

            &amp;lt;span class="c"&amp;gt;# From 100% to 75% display color grey.&amp;lt;/span&amp;gt;
            100%|9[0-9]%|8[0-9]%|7[5-9]%&amp;lt;span class="p"&amp;gt;)&amp;lt;/span&amp;gt; &amp;lt;span class="nv"&amp;gt;fgcolor&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;'#[fg=brightgrey]'&amp;lt;/span&amp;gt; 
                &amp;lt;span class="p"&amp;gt;;;&amp;lt;/span&amp;gt;

            &amp;lt;span class="c"&amp;gt;# From 74% to 50% display color green.&amp;lt;/span&amp;gt;
            7[0-4]%|6[0-9]%|5[0-9]%&amp;lt;span class="p"&amp;gt;)&amp;lt;/span&amp;gt; &amp;lt;span class="nv"&amp;gt;fgcolor&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;'#[fg=brightgreen]'&amp;lt;/span&amp;gt; 
                &amp;lt;span class="p"&amp;gt;;;&amp;lt;/span&amp;gt;

            &amp;lt;span class="c"&amp;gt;# From 49% to 25% display color yellow.&amp;lt;/span&amp;gt;
            4[0-9]%|3[0-9]%|2[5-9]%&amp;lt;span class="p"&amp;gt;)&amp;lt;/span&amp;gt; &amp;lt;span class="nv"&amp;gt;fgcolor&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;'#[fg=brightyellow]'&amp;lt;/span&amp;gt; 
                &amp;lt;span class="p"&amp;gt;;;&amp;lt;/span&amp;gt;

            &amp;lt;span class="c"&amp;gt;# From 24% to 0% display color red.&amp;lt;/span&amp;gt;
            2[0-4]%|1[0-9]%|[0-9]%&amp;lt;span class="p"&amp;gt;)&amp;lt;/span&amp;gt; &amp;lt;span class="nv"&amp;gt;fgcolor&amp;lt;/span&amp;gt;&amp;lt;span class="o"&amp;gt;=&amp;lt;/span&amp;gt;&amp;lt;span class="s1"&amp;gt;'#[fg=brightred]'&amp;lt;/span&amp;gt;
                &amp;lt;span class="p"&amp;gt;;;&amp;lt;/span&amp;gt;
        &amp;lt;span class="k"&amp;gt;esac&amp;lt;/span&amp;gt;

        &amp;lt;span class="c"&amp;gt;# Display the percentage of charge the battery has.&amp;lt;/span&amp;gt;
        &amp;lt;span class="nb"&amp;gt;printf&amp;lt;/span&amp;gt; &amp;lt;span class="s2"&amp;gt;"%s "&amp;lt;/span&amp;gt; &amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt;&amp;lt;span class="k"&amp;gt;${&amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;fgcolor&amp;lt;/span&amp;gt;&amp;lt;span class="k"&amp;gt;}${&amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;charging&amp;lt;/span&amp;gt;&amp;lt;span class="k"&amp;gt;}${&amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;batt0&amp;lt;/span&amp;gt;&amp;lt;span class="k"&amp;gt;}&amp;lt;/span&amp;gt;&amp;lt;span class="s2"&amp;gt;%&amp;lt;/span&amp;gt;&amp;lt;span class="k"&amp;gt;${&amp;lt;/span&amp;gt;&amp;lt;span class="nv"&amp;gt;fgdefault&amp;lt;/span&amp;gt;&amp;lt;span class="k"&amp;gt;}&amp;lt;/span&amp;gt;&amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt;

    &amp;lt;span class="k"&amp;gt;fi
fi&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;span class="o"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="k"&gt;function &lt;/span&gt;load_average&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;span class="nb"&amp;gt;printf&amp;lt;/span&amp;gt; &amp;lt;span class="s2"&amp;gt;"%s "&amp;lt;/span&amp;gt; &amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt;&amp;lt;span class="si"&amp;gt;$(&amp;lt;/span&amp;gt;&amp;lt;span class="nb"&amp;gt;uptime&amp;lt;/span&amp;gt; | &amp;lt;span class="nb"&amp;gt;awk&amp;lt;/span&amp;gt; &amp;lt;span class="nt"&amp;gt;-F&amp;lt;/span&amp;gt;: &amp;lt;span class="s1"&amp;gt;'{printf $NF}'&amp;lt;/span&amp;gt; | &amp;lt;span class="nb"&amp;gt;tr&amp;lt;/span&amp;gt; &amp;lt;span class="nt"&amp;gt;-d&amp;lt;/span&amp;gt; &amp;lt;span class="s1"&amp;gt;','&amp;lt;/span&amp;gt;&amp;lt;span class="si"&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;span class="o"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="k"&gt;function &lt;/span&gt;date_time&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;span class="nb"&amp;gt;printf&amp;lt;/span&amp;gt; &amp;lt;span class="s2"&amp;gt;"%s"&amp;lt;/span&amp;gt; &amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt;&amp;lt;span class="si"&amp;gt;$(&amp;lt;/span&amp;gt;&amp;lt;span class="nb"&amp;gt;date&amp;lt;/span&amp;gt; +&amp;lt;span class="s1"&amp;gt;'%Y-%m-%d %H:%M:%S %Z'&amp;lt;/span&amp;gt;&amp;lt;span class="si"&amp;gt;)&amp;lt;/span&amp;gt;&amp;lt;span class="s2"&amp;gt;"&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;span class="o"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="k"&gt;function &lt;/span&gt;main&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;battery_meter
load_average
date_time
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&lt;span class="o"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="c"&gt;# Calling the main function which will call the other functions.&lt;/span&gt;&lt;br&gt;
main&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;You can now easily have a Bash script display useful information on the Tmux status bar. I hope you enjoyed reading this article.&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://dev.to/brandonwallace"&gt;Dev.to&lt;/a&gt; and &lt;a href="https://github.com/brandon-wallace" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to leave comment, questions, and suggestions.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>One-To-Many Database Relationships Complete How To</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Thu, 18 Feb 2021 22:33:59 +0000</pubDate>
      <link>https://dev.to/brandonwallace/one-to-many-relationships-complete-how-to-2nbi</link>
      <guid>https://dev.to/brandonwallace/one-to-many-relationships-complete-how-to-2nbi</guid>
      <description>&lt;h1&gt;
  
  
  INTRODUCTION
&lt;/h1&gt;

&lt;p&gt;In this article I will show you how to set up a one-to-many database relationship, how you would know when you would need to use one, as well as some example queries.&lt;/p&gt;

&lt;p&gt;We will use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.9+&lt;/li&gt;
&lt;li&gt;PostgreSQL (database)&lt;/li&gt;
&lt;li&gt;Flask (framework)&lt;/li&gt;
&lt;li&gt;Flask-SQLAlchemy (object-relation mapper)&lt;/li&gt;
&lt;li&gt;Pipenv (virtual environment)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once your C.R.U.D. ( Create Read Update Delete ) applications start getting more complex, you will find that you need to link tables together within the database. In databases it is very common task to create relationships between tables. A one-to-many relationship is a method that will allow you to link a parent to a child table in a database. A one-to-many relationship is created by adding a foreign key to the child table.&lt;br&gt;
&lt;a href="https://media.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%2Fimj9a49vic2cs4uimond.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fimj9a49vic2cs4uimond.png" alt="one-to-many-erd-generic.png" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h6&gt;
  
  
  Diagram created on &lt;a href="https://www.diagrams.net" rel="noopener noreferrer"&gt;diagrams.net&lt;/a&gt;
&lt;/h6&gt;
&lt;h6&gt;
  
  
  PK = primary key
&lt;/h6&gt;
&lt;h6&gt;
  
  
  FK = foreign key
&lt;/h6&gt;
&lt;h1&gt;
  
  
  WHEN WOULD I USE A ONE-TO-MANY RELATIONSHIP?
&lt;/h1&gt;

&lt;p&gt;Let me present to you a real-world scenario, let’s say you have an online store and you need to keep track of your customers and the orders they make. In your database you would create a table for customers and separate table for the orders. How would you know which order belongs to which customer? The way to do that is to set up a one-to-many relationship. This will allow you to take one customer and query all the information connected to the orders the customer made.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fmljrtprjnnh4h4ddo2ee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fmljrtprjnnh4h4ddo2ee.png" alt="one-to-many-erd.png" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will show you an easy way to know when you need to set up a one-to-many database relationship as opposed to a one-to-one or a many-to-many database relationship. Going back to the example of the online store, you have two tables, a customer table and an order table. You  would ask yourself two questions about the tables.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example 1:
&lt;/h2&gt;

&lt;p&gt;Q: Does a &lt;strong&gt;customer&lt;/strong&gt; have &lt;em&gt;many&lt;/em&gt; &lt;strong&gt;orders&lt;/strong&gt;?&lt;br&gt;
A: Yes, a customer can have many orders.&lt;/p&gt;

&lt;p&gt;Q: Does an &lt;strong&gt;order&lt;/strong&gt; have &lt;em&gt;many&lt;/em&gt; &lt;strong&gt;customers&lt;/strong&gt;?&lt;br&gt;
A: No, only one person can create an order.&lt;/p&gt;

&lt;p&gt;We have one customer and many orders but it does not work the other way around. One order does not have many customers. We can clearly see that example 1 is a great candidate for a one-to-many database relationship. &lt;/p&gt;

&lt;p&gt;Let’s look at another example.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example 2:
&lt;/h2&gt;

&lt;p&gt;In another imaginary database we have a table for students and a table for classes. So we form the questions like this.&lt;/p&gt;

&lt;p&gt;Q: Does a &lt;strong&gt;student&lt;/strong&gt; have &lt;em&gt;many&lt;/em&gt; &lt;strong&gt;classes&lt;/strong&gt;?&lt;br&gt;
A: Yes, a student can have many classes.&lt;/p&gt;

&lt;p&gt;Q: Does a &lt;strong&gt;class&lt;/strong&gt; have &lt;em&gt;many&lt;/em&gt; &lt;strong&gt;students&lt;/strong&gt;?&lt;br&gt;
A: Yes, a class can have many students.&lt;/p&gt;

&lt;p&gt;Here we have many students and many classes because of that, example 2 is not suitable for a one-to-many relationship.&lt;/p&gt;
&lt;h1&gt;
  
  
  How To Set Up The Project
&lt;/h1&gt;

&lt;p&gt;Install PostgreSQL and Pip. We use Pip to install Pipenv.&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;postgresql libpq-dev python3-pip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enable and start PostgreSQL.&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;postgresql

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start postgresql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check to see if PostgreSQL is running.&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded &lt;span class="o"&gt;(&lt;/span&gt;/lib/systemd/system/postgresql.service&lt;span class="p"&gt;;&lt;/span&gt; enabled&lt;span class="p"&gt;;&lt;/span&gt; vendor preset: enabled&lt;span class="o"&gt;)&lt;/span&gt;
   Active: active &lt;span class="o"&gt;(&lt;/span&gt;exited&lt;span class="o"&gt;)&lt;/span&gt; since Mon 2021-02-01 10:09:46 EST&lt;span class="p"&gt;;&lt;/span&gt; 2h 56min ago
   Process: 920 &lt;span class="nv"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/bin/true &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;exited, &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0/SUCCESS&lt;span class="o"&gt;)&lt;/span&gt;
   Main PID: 920 &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;exited, &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0/SUCCESS&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Log in as the postgres user and then the interactive PostgreSQL terminal 'psql'.&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;su – postgres

postgres@laptop:~&lt;span class="nv"&gt;$ &lt;/span&gt;psql

&lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;#&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the PostgreSQL version.&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="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# SELECT version();&lt;/span&gt;
                                                     version                                                      
&lt;span class="nt"&gt;------------------------------------------------------------------&lt;/span&gt;
 PostgreSQL 14.1 &lt;span class="o"&gt;(&lt;/span&gt;Debian 14.1-1.pgdg110+1&lt;span class="o"&gt;)&lt;/span&gt; on x86_64-pc-linux-gnu &lt;span class="o"&gt;[&lt;/span&gt;...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set the postgres user’s password. Please use something stronger than 123456.&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="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# ALTER USER postgres WITH PASSWORD '123456'; &lt;/span&gt;
ALTER ROLE       
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a database called mystoredb.&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="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# CREATE DATABASE mystoredb;&lt;/span&gt;
CREATE DATABASE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List the databases. You will see mystoredb on the list.&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="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# \l&lt;/span&gt;
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
&lt;span class="nt"&gt;-----------&lt;/span&gt;+----------+----------+-------------+-------------+-----------------------
 mystoredb | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | &lt;span class="o"&gt;=&lt;/span&gt;c/postgres          +
&lt;span class="o"&gt;[&lt;/span&gt;...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit psql interactive terminal and logout as the postgres user.&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="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# \q&lt;/span&gt;

postgres@laptop:~&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a directory for your project.&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my_project/

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my_project/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install pipenv using pip3.&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="nv"&gt;$ &lt;/span&gt;pip3 &lt;span class="nb"&gt;install &lt;/span&gt;pipenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the Python virtual environment.&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="nv"&gt;$ &lt;/span&gt;pipenv shell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install the required libraries.&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="nv"&gt;$ &lt;/span&gt;pipenv &lt;span class="nb"&gt;install &lt;/span&gt;flask flask-sqlalchemy psycopg2-binary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a simple example of a one-to-many relationship with Flask-SQLAlchemy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;primary_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;comment_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;relationship&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Comment&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cascade&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;all, delete&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;backref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;author&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="n"&gt;lazy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Comment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;primary_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;post_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ForeignKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;post.id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;db.relationship()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This function looks at the child table and pulls up multiple instances of the child table. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;backref&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Backref creates a kind of invisible column within the child table.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lazy&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Lazy defines when the data will be pulled from the database.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lazy=select&lt;/code&gt;&lt;br&gt;
or &lt;br&gt;
&lt;code&gt;lazy=True&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is the default setting. SQLAlchemy will load the all data necessary at once.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;db.ForiegnKey()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This function specifies the parent class (written in lowercase) and relates items back to the parent table. &lt;/p&gt;

&lt;p&gt;Create file called application.py and add the following content. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ vim application.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# application.py
&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_sqlalchemy&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SQLAlchemy&lt;/span&gt;


&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;DEBUG&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SQLALCHEMY_TRACK_MODIFICATIONS&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SQLALCHEMY_DATABASE_URI&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;postgresql://postgres:123456@127.0.0.1:5432/mystoredb&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

&lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SQLAlchemy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;Customer table&lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;

    &lt;span class="n"&gt;__tablename__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;customer&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;primary_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;customer_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;customer_email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;nullable&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;order_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;relationship&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Order&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cascade&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;all, delete&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;backref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;customer&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lazy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_email&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;customer_name&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;customer_email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;customer_email&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__repr__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;Customer: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;Order table&lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;

    &lt;span class="n"&gt;__tablename__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;order&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;primary_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;order_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Use datetime to generate a random 6 digit number from milliseconds.
&lt;/span&gt;    &lt;span class="n"&gt;order_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;customer_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Column&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Integer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ForeignKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;customer.id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__repr__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;OrderID: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;debug&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  *NOTE:
&lt;/h1&gt;

&lt;p&gt;The syntax for the SQLALCHEMY_DATABASE_URI variable is&lt;/p&gt;

&lt;p&gt;&lt;code&gt;'postgresql://&amp;lt;db_username&amp;gt;:&amp;lt;password&amp;gt;@&amp;lt;ip_address&amp;gt;:&amp;lt;port&amp;gt;/&amp;lt;database_name&amp;gt;'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example of what I am using in this tutorial:&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="s1"&gt;'postgresql://postgres:123456@127.0.0.1:5432/mystoredb'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the values of the database URI to reflect your set up.&lt;/p&gt;

&lt;p&gt;Start a Python interpreter shell on the command line.&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="nv"&gt;$ &lt;/span&gt;python3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import the database + models and create the tables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add a few people to the customer table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;brandon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Brandon&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;brandon@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;maria&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Maria&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;maria@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ahmed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Ahmed&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ahmed@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cheuk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Cheuk&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;cheuk@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;nikolaus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Nikolaus&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_email&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;nikolaus@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add all people to the database session.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_all&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;brandon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maria&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ahmed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cheuk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nikolaus&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit all changes to the database to save the users.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create orders and link them with customers in the database like this. Remember 'customer' is the backref value in the parent table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;brandon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;brandon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;brandon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ahmed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order5&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ahmed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order6&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cheuk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order7&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cheuk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order8&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;maria&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;order9&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;nikolaus&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add all orders to the session.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_all&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;order1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order9&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit all changes to the database to save the orders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  How To Perform Queries
&lt;/h1&gt;

&lt;p&gt;At this point we can query the database.&lt;/p&gt;

&lt;p&gt;Pull up all the customer records in the database and loop through the results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;person&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Name: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Email: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_email&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: 1 Name: Brandon Email: brandon@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: 2 Name: Maria Email: maria@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: 3 Name: Ahmed Email: ahmed@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: 4 Name: Cheuk Email: cheuk@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: 5 Name: Nikolaus Email: nikolaus@example.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Extract the name like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;customer&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;customers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_name&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Brandon&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Maria&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Ahmed&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Cheuk&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Nikolaus&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get the total order count for Brandon.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;brandon_order_count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Total orders for Brandon: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;brandon_order_count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;Total&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;Brandon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get the order numbers for Brandon.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;brandon_all_orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;brandon_all_orders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Order number: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_number&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Order number: 680018&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Order number: 193492&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Order number: 662450&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get the orders from Brandon sorted by most recent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;latest_orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;order_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;desc&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;latest_orders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%Y-%m-%d %H:%M&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2022-04-03 18:09&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2022-02-02 20:22&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2022-01-01 10:59&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get the orders from Brandon sorted by oldest first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;oldest_orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;order_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;desc&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;oldest_orders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%Y-%m-%d %H:%M&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2022-01-01 10:59&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2022-02-02 20:22&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2022-04-03 18:09&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get orders filtering by a before a specific date.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;from_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2022&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;befor_feb_22&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;from_date&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;before_feb_22&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Date: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; OrderNum: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_number&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; CustID: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: 2 Date: 2022-01-01 10:29:43.380762 OrderNum: 27227 CustID: 1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: 1 Date: 2022-02-02 10:29:43.380762 OrderNum: 27227 CustID: 1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get orders filtering by a after a specific date.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;after_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2022&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;month&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;after_feb_22&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;after_date&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;after_feb_22&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Date: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; OrderNum: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_number&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; CustID: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ID: 3 Date: 2022-04-03 10:29:43.380762 OrderNum: 27227 CustID: 1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get the date and time Cheuk placed the orders.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cheuk_all_orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cheuk_all_orders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;     &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Order date: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order_date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;%Y-%m-%d %H&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Order date: 2022-02-07 19:52&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Order date: 2022-02-07 21:38&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  How To Troubleshoot If You Have Issues
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Check carefully for syntax errors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you ran db.create_all() with errors in the application.py file you might have to delete the database and recreate it.&lt;br&gt;
&lt;/p&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;su – postgres

&lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# DROP DATABASE mystoredb;&lt;/span&gt;
DROP DATABASE

&lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c"&gt;# CREATE DATABASE mystoredb;&lt;/span&gt;
CREATE DATABASE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run db.create_all() again to create the tables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;python3&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Order&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_all&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Feel free to leave comments, questions, and suggestions.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>database</category>
      <category>sql</category>
      <category>python</category>
    </item>
    <item>
      <title>Set Up A GIT Server The Easy Way!</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Sun, 07 Feb 2021 02:35:19 +0000</pubDate>
      <link>https://dev.to/brandonwallace/set-up-a-git-server-the-easy-way-jke</link>
      <guid>https://dev.to/brandonwallace/set-up-a-git-server-the-easy-way-jke</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;In this tutorial I will show you step-by-step how to set up a local Git server. This is an easy and fun project that is great for a home server, a low-powered single board computer such as a Beaglebone Black or Raspberry Pi, or even a Virtual Private Server. All you need is Git installed on the server and an SSH key on the client computer.&lt;/p&gt;

&lt;p&gt;The benefit to this is that are you will have your own private git server you control, where you can push, pull, and clone repositories from.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FzvD6pnTQ%2Fclient-server.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FzvD6pnTQ%2Fclient-server.png" alt="client-server.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s begin…&lt;/p&gt;

&lt;h1&gt;
  
  
  On the server
&lt;/h1&gt;

&lt;p&gt;First thing is to log into the server and install Git.&lt;/p&gt;

&lt;p&gt;For an .deb based system run.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For an .rpm based system run.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nb"&gt;install &lt;/span&gt;git

OR

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;dnf &lt;span class="nb"&gt;install &lt;/span&gt;git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The next step is to create a git user.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;useradd &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="nt"&gt;-U&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; /bin/bash git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;-r&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;creates a system user&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-m&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;creates a home directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-U&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;create a group name the same as the username.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-s /path/to/shell&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Set the default shell for the user.&lt;/p&gt;

&lt;p&gt;You should see the git user's home directory created under /home.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-lF&lt;/span&gt; /home/
total 8
drwxr-xr-x  2 git git 4096 Jan 29 20:09 git/



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Set a password for the git user.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;passwd git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Switch accounts to become the git user.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;su - git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Create a .ssh directory in the git user’s home folder.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; /home/git/.ssh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You will see that the default permissions are 0755 (drwxr-xr-x).&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /home/git/.ssh
drwxr-xr-x 2 git git 4096 Jan 29 20:25 /home/git/.ssh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We need to set the permissions on the .ssh directory to 0700 so that SSH will function correctly. We will set the directory permission to 0700 (drwx------) with this command.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo chmod &lt;/span&gt;0700 /home/git/.ssh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Verifying the permissions are set correctly by running “ls -ld”.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /home/git/.ssh
drwx------ 2 git git 4096 Jan 29 20:25 /home/git/.ssh


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let create our first repository on the server. By convention we append .git to the end of the directory name. This reminds us that the directory is a repository and not a regular directory.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;git init &lt;span class="nt"&gt;--bare&lt;/span&gt; my_project.git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Nice! Let’s work on the client computer.&lt;/p&gt;

&lt;h1&gt;
  
  
  On the client computer
&lt;/h1&gt;

&lt;p&gt;At this time we will create SSH keys with this command.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa &lt;span class="nt"&gt;-b&lt;/span&gt; 4096 &lt;span class="nt"&gt;-C&lt;/span&gt; “my_email” &lt;span class="nt"&gt;-f&lt;/span&gt; ~/.ssh/id_rsa


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;-t &amp;lt;type&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Type of key (rsa or dsa). Use rsa.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-b &amp;lt;bits&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Specifies the number of bits in the key to create. Use 4096.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-C “comment”&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add a comment.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-f /path/to/key&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Specify the path to the rsa file. It is common to name it &lt;code&gt;id_rsa&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Upon running the command you will see output similar to what is below. Set a password when prompted.&lt;/p&gt;

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

Generating public/private rsa key pair.
Enter passphrase &lt;span class="o"&gt;(&lt;/span&gt;empty &lt;span class="k"&gt;for &lt;/span&gt;no passphrase&lt;span class="o"&gt;)&lt;/span&gt;: &lt;span class="k"&gt;************&lt;/span&gt;
Enter same passphrase again: &lt;span class="k"&gt;************&lt;/span&gt;
Your identification has been saved &lt;span class="k"&gt;in&lt;/span&gt; .ssh/id_rsa.
Your public key has been saved &lt;span class="k"&gt;in&lt;/span&gt; .ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Yg5D1kaIN9M6ln3sJlHzEggLoKpDYFkhXFR1ZOwP/sI my_email
The key&lt;span class="s1"&gt;'s randomart image is:
+---[RSA 4096]----+
|oo+*+=ooo+       |
|..=.=+o *.       |
|oo .+*oo.+       |
|+  o=.o +o.      |
|.. .o.o+S.o      |
|o    =..o. .     |
|o     .o. .      |
| .       E .     |
|          .      |
+----[SHA256]-----+


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You will see that two files have been created. &lt;code&gt;id_rsa&lt;/code&gt; is the private key, &lt;code&gt;id_rsa.pub&lt;/code&gt; is the public key. The permissions should be set to 0600 (-rw-------).&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-la&lt;/span&gt; .ssh/
total 36
drwx------  2 bw bw 4096 Jan 29 20:43 &lt;span class="nb"&gt;.&lt;/span&gt;
drwxr-xr-x 54 bw bw 4096 Jan 29 13:17 ..
&lt;span class="nt"&gt;-rw-------&lt;/span&gt;  1 bw bw 3414 Jan 29 20:43 id_rsa
&lt;span class="nt"&gt;-rw-------&lt;/span&gt;  1 bw bw  733 Jan 29 20:43 id_rsa.pub


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The public key needs to be copied over to the git server. To do that use the &lt;code&gt;ssh-copy-id&lt;/code&gt; command. Since my server’s IP address is &lt;code&gt;192.168.12.34&lt;/code&gt; I run the command like this to copy the public key over to the server. Change the IP address to the IP address of your server.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-copy-id &lt;span class="nt"&gt;-i&lt;/span&gt; ~/.ssh/id_rsa.pub git@192.168.12.34


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;-i /path/to/public_key_file&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Specify the path to the public key.&lt;/p&gt;

&lt;p&gt;After copying the public key over to the server test logging into the server via SSH. Change the IP address to the IP address of your server.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;ssh git@192.168.12.34
git@192.168.12.34s password:

Last login: Fri Jan 29 20:35:46 2021 from 192.168.12.100
git@192.168.12.34:~ &lt;span class="err"&gt;$&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Type exit to disconnect from the server.&lt;/p&gt;

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

git@192.168.12.34:~ &lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;exit&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now we are ready to connect to the repository that we made earlier on the server. Create a directory of the same name as the repository minus the .git extension. On the server we have a directory called my_project.git so on the client computer you create a directory called my_project/.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my_project/

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my_project/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add a few of the standard git files.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;readme.md .gitignore LICENSE


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add some content to the readme.md.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; ‘# My First Project!’ &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; readme.md


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add all the files to the git staging area so they can be committed.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;git add &lt;span class="nt"&gt;--all&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Commit the files to git. The &lt;code&gt;-m&lt;/code&gt; flag allows you to create a short commit message without opening an editor.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; “First commit”


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We need to specify the git server we will be using.&lt;br&gt;
This command will specify a remote git server repository where commits will be stored. The syntax is&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ git remote add &amp;lt;remote_name&amp;gt; git@&amp;lt;server_ip&amp;gt;:&amp;lt;git_repo&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt; can be whatever label you want. The default &lt;code&gt;&amp;lt;remote_name&amp;gt;&lt;/code&gt; you will often see is usually &lt;code&gt;origin&lt;/code&gt;. I set my “remote_name” to “local” since I have a local server. Change the IP address to the IP address of your server.&lt;/p&gt;

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

&lt;span class="o"&gt;(&lt;/span&gt;master&lt;span class="o"&gt;)&lt;/span&gt;my_project &lt;span class="nv"&gt;$ &lt;/span&gt;git remote add &lt;span class="nb"&gt;local  &lt;/span&gt;git@192.168.12.34:my_project.git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Push the first commit to the server.&lt;/p&gt;

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

&lt;span class="o"&gt;(&lt;/span&gt;master&lt;span class="o"&gt;)&lt;/span&gt;my_project &lt;span class="nv"&gt;$ &lt;/span&gt;git push &lt;span class="nb"&gt;local &lt;/span&gt;master


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check your remote servers like this. Right now only one repository is&lt;br&gt;&lt;br&gt;
set up which is called ‘local’.&lt;/p&gt;

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

&lt;span class="o"&gt;(&lt;/span&gt;master&lt;span class="o"&gt;)&lt;/span&gt;my_project &lt;span class="nv"&gt;$ &lt;/span&gt;git remote &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;span class="nb"&gt;local   &lt;/span&gt;git@192.168.12.34:my_project.git &lt;span class="o"&gt;(&lt;/span&gt;fetch&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;local   &lt;/span&gt;git@192.168.12.34:my_project.git &lt;span class="o"&gt;(&lt;/span&gt;push&lt;span class="o"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Remember that I said we were going to do this the easy way?&lt;br&gt;
Since we have finished the initial set up on the server we can create a new repository from the client computer using SSH. No need to log into the server to create the repository. Here is the workflow for creating a new repository on your Git server.&lt;/p&gt;

&lt;p&gt;To run a command on a remote server just append the command you wish to run after the SSH command. This will allow you to run the “git init --bare ” command to create a new repository without logging into the server. Run this command changing the IP address to your server’s IP address.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;ssh git@192.168.12.34 “git init &lt;span class="nt"&gt;--bare&lt;/span&gt; my_second_project.git”


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check that the directory was created on the server.&lt;/p&gt;

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

~ &lt;span class="nv"&gt;$ &lt;/span&gt;ssh git@192.168.12.34 &lt;span class="s2"&gt;"ls -lF"&lt;/span&gt;
total 8
drwxr-xr-x 7 git git 4096 Feb  5 17:47 my_project.git/
drwxr-xr-x 7 git git 4096 Feb  6 21:48 my_second_project.git/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;On the client computer create a directory with the same name as the git repository you created on the server minus the .git extension.&lt;/p&gt;

&lt;p&gt;On the server we already have a my_second_project.git directory, so create the my_second_project/ directory on the client computer.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my_second_project/

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my_second_project/

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;readme.md .gitignore LICENSE


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add some content to the readme.md.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; ‘# My Second Project!’ &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; readme.md

&lt;span class="nv"&gt;$ &lt;/span&gt;git add &lt;span class="nt"&gt;--all&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; “First commit”

&lt;span class="nv"&gt;$ &lt;/span&gt;git remote add &lt;span class="nb"&gt;local &lt;/span&gt;git@192.168.12.34:my_second_project.git

&lt;span class="nv"&gt;$ &lt;/span&gt;git push &lt;span class="nb"&gt;local &lt;/span&gt;master
git@192.168.12.34&lt;span class="s1"&gt;'s password: ************
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 306 bytes | 306.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To 192.168.12.34:my_project.git
 * [new branch]      master -&amp;gt; master
Branch '&lt;/span&gt;master&lt;span class="s1"&gt;' set up to track remote branch '&lt;/span&gt;master&lt;span class="s1"&gt;' from '&lt;/span&gt;&lt;span class="nb"&gt;local&lt;/span&gt;&lt;span class="s1"&gt;'.


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;All done.&lt;/p&gt;

&lt;p&gt;Just to review, to create a new local repository you simply run the following commands.&lt;/p&gt;

&lt;p&gt;Full example:&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;ssh git@192.168.12.34 “git init &lt;span class="nt"&gt;--bare&lt;/span&gt; nodejs_app.git”
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;nodejs_app/
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;nodejs_app/
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;readme.md .gitignore LICENSE
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; ‘# My Nodejs App’ &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; readme.md
&lt;span class="nv"&gt;$ &lt;/span&gt;git init
&lt;span class="nv"&gt;$ &lt;/span&gt;git add &lt;span class="nt"&gt;--all&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; “First commit”
&lt;span class="nv"&gt;$ &lt;/span&gt;git remote add &lt;span class="nb"&gt;local &lt;/span&gt;git@192.168.12.34:nodejs_app.git
&lt;span class="nv"&gt;$ &lt;/span&gt;git push &lt;span class="nb"&gt;local &lt;/span&gt;master


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  *NOTE:
&lt;/h1&gt;

&lt;p&gt;If you wish to you could easily add a second connection to Github if you want to have that same repository online by running the ‘git remote add' command.&lt;br&gt;
First create a new repository on Github with the same name (my_project) without any files such as the readme.md, .gitignore, or LICENSE because we already created them.&lt;/p&gt;

&lt;p&gt;Second run the git remote add command. Here is an example:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="o"&gt;(&lt;/span&gt;master&lt;span class="o"&gt;)&lt;/span&gt;my_project &lt;span class="nv"&gt;$ &lt;/span&gt;git remote add origin git@github.com/brandon-wallace:my_project.git


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Look at the remote repositories available now.&lt;/p&gt;

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

&lt;span class="o"&gt;(&lt;/span&gt;master&lt;span class="o"&gt;)&lt;/span&gt;my_project &lt;span class="nv"&gt;$ &lt;/span&gt;git remote &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;span class="nb"&gt;local   &lt;/span&gt;git@192.168.12.34:my_project.git &lt;span class="o"&gt;(&lt;/span&gt;fetch&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;local   &lt;/span&gt;git@192.168.12.34:my_project.git &lt;span class="o"&gt;(&lt;/span&gt;push&lt;span class="o"&gt;)&lt;/span&gt;
origin    git@github.com/brandon-wallace:my_project.git &lt;span class="o"&gt;(&lt;/span&gt;fetch&lt;span class="o"&gt;)&lt;/span&gt;
origin    git@github.com/brandon-wallace:my_project.git &lt;span class="o"&gt;(&lt;/span&gt;push&lt;span class="o"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now it shows that I have two git servers I can use, one is called &lt;code&gt;local&lt;/code&gt; (my server) the other &lt;code&gt;origin&lt;/code&gt; (Github).&lt;/p&gt;

&lt;h1&gt;
  
  
  BONUS TIP!
&lt;/h1&gt;

&lt;p&gt;After logging into your computer you can use ssh-agent to store the rsa key password so that you do not have to keep typing your SSH private key password every time you do a push to a repository. To store the SSH password run.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-add /home/brandon/.ssh/id_rsa
Enter passphrase &lt;span class="k"&gt;for&lt;/span&gt; /home/bw/.ssh/id_rsa: &lt;span class="k"&gt;***********&lt;/span&gt;
Identity added: /home/bw/.ssh/id_rsa &lt;span class="o"&gt;(&lt;/span&gt;comment&lt;span class="o"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;See that the environment variable is exists.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;env&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;SSH

&lt;span class="nv"&gt;SSH_AUTH_SOCK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/tmp/ssh-08AsdfQWRTYE/agent.69007
&lt;span class="nv"&gt;SSH_AGENT_PID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;69007


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now all your git push commands will not require you typing the password.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;git push origin master
Enumerating objects: 6, &lt;span class="k"&gt;done&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Counting objects: 100% &lt;span class="o"&gt;(&lt;/span&gt;6/6&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="k"&gt;done&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Delta compression using up to 2 threads
Compressing objects: 100% &lt;span class="o"&gt;(&lt;/span&gt;4/4&lt;span class="o"&gt;)&lt;/span&gt;, &lt;span class="k"&gt;done&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Writing objects: 100% &lt;span class="o"&gt;(&lt;/span&gt;4/4&lt;span class="o"&gt;)&lt;/span&gt;, 518 bytes | 518.00 KiB/s, &lt;span class="k"&gt;done&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
Total 4 &lt;span class="o"&gt;(&lt;/span&gt;delta 2&lt;span class="o"&gt;)&lt;/span&gt;, reused 0 &lt;span class="o"&gt;(&lt;/span&gt;delta 0&lt;span class="o"&gt;)&lt;/span&gt;
To 192.168.12.34:my_project.git
   d06bb48..beee582  master -&amp;gt; master


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Feel free to leave comments, questions, and suggestions.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>git</category>
      <category>linux</category>
    </item>
    <item>
      <title>Deploy Flask The Easy Way With Gunicorn and Nginx!</title>
      <dc:creator>brandon_wallace</dc:creator>
      <pubDate>Fri, 29 Jan 2021 04:57:12 +0000</pubDate>
      <link>https://dev.to/brandonwallace/deploy-flask-the-easy-way-with-gunicorn-and-nginx-jgc</link>
      <guid>https://dev.to/brandonwallace/deploy-flask-the-easy-way-with-gunicorn-and-nginx-jgc</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;After creating a Flask application you probably want people to see it. This tutorial will show you how to deploy your Flask application on a Linux server Nginx with Gunicorn. &lt;/p&gt;

&lt;h1&gt;
  
  
  Requirements
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;A Server (&lt;a href="https://www.debian.org/" rel="noopener noreferrer"&gt;Debian&lt;/a&gt; is used in this tutorial)&lt;/li&gt;
&lt;li&gt;Nginx&lt;/li&gt;
&lt;li&gt;Gunicorn&lt;/li&gt;
&lt;li&gt;Pipenv&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first step in the process is to install pip and pipenv. We will use pipenv to set up the virtual environment. &lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;python3-pip pipenv


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check that pipenv installed correctly by checking the version.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;pipenv &lt;span class="nt"&gt;--version&lt;/span&gt;
pipenv, version 2022.12.19


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Create project directory to hold your project. &lt;code&gt;/var/www/&lt;/code&gt; is a good location.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /var/www/myproject


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The default permissions for the directory are set to root.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /var/www/myproject
drwxr-xr-x 2 root root 4096 Feb 20 12:37 /var/www/myproject/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Change the permissions for the user and group to your username and the group &lt;code&gt;www-data&lt;/code&gt;.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; &lt;span class="nv"&gt;$USER&lt;/span&gt;:www-data /var/www/myproject


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check the to see that the permissions changed to username &lt;code&gt;brandon&lt;/code&gt; and group name &lt;code&gt;www-data&lt;/code&gt;.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-ld&lt;/span&gt; /var/www/myproject
drwxr-xr-x 2 brandon www-data 4096 Jan 27 12:37 /var/www/myproject/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;CD into the /var/www/myproject directory.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/www/myproject


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file to hold the environmental variables.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; .env


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Edit the &lt;code&gt;.env&lt;/code&gt; file to add the &lt;code&gt;FLASK_APP&lt;/code&gt; and &lt;code&gt;FLASK_ENV&lt;/code&gt; environmental variables. With any editor add these two lines:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ vim .env&lt;/code&gt;&lt;/p&gt;

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

&lt;span class="nv"&gt;FLASK_APP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;wsgi.py
&lt;span class="nv"&gt;FLASK_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Start the virtual environment. Pipenv will load the variables in the &lt;code&gt;.env&lt;/code&gt; file automatically.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;pipenv shell

Loading .env environment variables...
Loading .env environment variables...
Creating a virtualenv &lt;span class="k"&gt;for &lt;/span&gt;this project...
Pipfile: /var/www/myproject/Pipfile
Using /usr/bin/python3 &lt;span class="o"&gt;(&lt;/span&gt;3.11.2&lt;span class="o"&gt;)&lt;/span&gt; to create virtualenv...
⠇ Creating virtual environment...created virtual environment &lt;span class="o"&gt;[&lt;/span&gt;...]
✔ Successfully created virtual environment!
Virtualenv location: /home/brandon/.local/share/virtualenvs/myproject-jyD3CuVy
Creating a Pipfile &lt;span class="k"&gt;for &lt;/span&gt;this project...
Launching subshell &lt;span class="k"&gt;in &lt;/span&gt;virtual environment...


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Use pipenv to install the dependencies.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;pipenv &lt;span class="nb"&gt;install &lt;/span&gt;flask gunicorn

Loading .env environment variables...
Installing flask...
Installing gunicorn...
Pipfile.lock not found, creating...
&lt;span class="o"&gt;[&lt;/span&gt;...]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To set up a minimal Flask application create two files &lt;code&gt;application.py&lt;/code&gt; and &lt;code&gt;wsgi.py&lt;/code&gt;. The main Flask application will be stored in &lt;code&gt;application.py&lt;/code&gt;. &lt;br&gt;
&lt;code&gt;wsgi.py&lt;/code&gt; will be used to get the application running.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;application.py wsgi.py


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Edit &lt;code&gt;application.py&lt;/code&gt; file. Add the code for a minimal Flask application with one route for the index page.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ vim application.py&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;index&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="sh"&gt;'''&lt;/span&gt;&lt;span class="s"&gt;Index page route&lt;/span&gt;&lt;span class="sh"&gt;'''&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;h1&amp;gt;Application Deployed!&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Edit the wsgi.py file. Add this code wsgi.py to get the application running.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ vim wsgi.py&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;debug&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let’s test run the Flask application!&lt;br&gt;
Make the Flask application listen on all server interfaces by specifying the address ‘0.0.0.0’.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;flask run &lt;span class="nt"&gt;--host&lt;/span&gt; &lt;span class="s1"&gt;'0.0.0.0'&lt;/span&gt;

 &lt;span class="k"&gt;*&lt;/span&gt; Tip: There are .env or .flaskenv files present. Do &lt;span class="s2"&gt;"pip install python-dotenv"&lt;/span&gt; to use them.
 &lt;span class="k"&gt;*&lt;/span&gt; Serving Flask app &lt;span class="s1"&gt;'wsgi.py'&lt;/span&gt;
 &lt;span class="k"&gt;*&lt;/span&gt; Debug mode: off
WARNING: This is a development server. Do not use it &lt;span class="k"&gt;in &lt;/span&gt;a production deployment. Use a production WSGI server instead.
 &lt;span class="k"&gt;*&lt;/span&gt; Running on all addresses &lt;span class="o"&gt;(&lt;/span&gt;0.0.0.0&lt;span class="o"&gt;)&lt;/span&gt;
 &lt;span class="k"&gt;*&lt;/span&gt; Running on http://127.0.0.1:5000
 &lt;span class="k"&gt;*&lt;/span&gt; Running on http://192.168.12.34:5000
Press CTRL+C to quit


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now you can access the application from &lt;em&gt;another&lt;/em&gt; computer using a browser, navigate to the server's IP address on port &lt;code&gt;5000&lt;/code&gt;. Make sure port &lt;code&gt;5000&lt;/code&gt; is not blocked by a firewall so that you will be able to access your Flask application. &lt;/p&gt;

&lt;p&gt;Since my server's IP address is &lt;code&gt;192.168.12.34&lt;/code&gt; I access the Flask application from my laptop with a browser using this address:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://192.168.12.34:5000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should see this in the browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FzXnrDzYQ%2Fflask-app1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FzXnrDzYQ%2Fflask-app1.png" alt="flask-app1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Press &lt;code&gt;CTRL+C&lt;/code&gt; to stop the Flask development server. &lt;/p&gt;

&lt;p&gt;It is time to set up Gunicorn!&lt;/p&gt;

&lt;p&gt;If you were able to run the Flask development server successfully use this command to test run the application using Gunicorn.&lt;/p&gt;

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

&lt;span class="o"&gt;(&lt;/span&gt;myproject&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$ &lt;/span&gt;gunicorn &lt;span class="nt"&gt;--workers&lt;/span&gt; 4 &lt;span class="nt"&gt;--bind&lt;/span&gt; 0.0.0.0:5000 wsgi:app


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;--workers N&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Set the --workers to two times the number of cores in your server. Adjust the number later if you have any issues. Do not exceed 12.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--bind 0.0.0.0:5000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will listen on all server networking interfaces on port 5000.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wsgi:app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wsgi&lt;/code&gt; is the file name without the &lt;code&gt;.py&lt;/code&gt; extension. &lt;code&gt;app&lt;/code&gt; is the instance of the Flask application within the file. You should see the similar output below.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;gunicorn &lt;span class="nt"&gt;--workers&lt;/span&gt; 4 &lt;span class="nt"&gt;--bind&lt;/span&gt; 0.0.0.0:5000 wsgi:app

&lt;span class="o"&gt;[&lt;/span&gt;2024-02-20 20:57:21 &lt;span class="nt"&gt;-0500&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;4936] &lt;span class="o"&gt;[&lt;/span&gt;INFO] Starting gunicorn 21.2.0
&lt;span class="o"&gt;[&lt;/span&gt;2024-02-20 20:57:21 &lt;span class="nt"&gt;-0500&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;4936] &lt;span class="o"&gt;[&lt;/span&gt;INFO] Listening at: http://0.0.0.0:5000 &lt;span class="o"&gt;(&lt;/span&gt;4936&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;2024-02-20 20:57:21 &lt;span class="nt"&gt;-0500&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;4936] &lt;span class="o"&gt;[&lt;/span&gt;INFO] Using worker: &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;2024-02-20 20:57:21 &lt;span class="nt"&gt;-0500&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;4937] &lt;span class="o"&gt;[&lt;/span&gt;INFO] Booting worker with pid: 4937
&lt;span class="o"&gt;[&lt;/span&gt;...]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Press &lt;code&gt;CTRL+C&lt;/code&gt; to stop the Gunicorn server.&lt;/p&gt;

&lt;p&gt;While you are in the virtual environment check the path of &lt;code&gt;gunicorn&lt;/code&gt;. Take note of this path. You will need to know the path to gunicorn to configure the systemd service file. My path is &lt;code&gt;/var/www/myproject/.venv/bin/gunicorn&lt;/code&gt; your path might be &lt;code&gt;/home/$USER/.local/share/virtualenvs/myproject-544gQc4M/.venv/bin/gunicorn&lt;/code&gt;. The path depends if you have &lt;code&gt;PIPENV_VENV_IN_PROJECT=true&lt;/code&gt; set in your &lt;code&gt;.bashrc&lt;/code&gt; file or not. If the variable is set to &lt;code&gt;true&lt;/code&gt; pipenv will use the &lt;code&gt;.venv&lt;/code&gt; in your project directory.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ which gunicorn

/var/www/myproject/.venv/bin/gunicorn


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now that you have a basic Flask application running with Gunicorn we can set up Nginx.&lt;/p&gt;

&lt;h1&gt;
  
  
  Install Nginx
&lt;/h1&gt;

&lt;p&gt;Run these commands to install and start the Nginx webserver.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nginx

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;nginx

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check to see if Nginx is running by running this command.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status nginx

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded &lt;span class="o"&gt;(&lt;/span&gt;/lib/systemd/system/nginx.service&lt;span class="p"&gt;;&lt;/span&gt; enabled&lt;span class="p"&gt;;&lt;/span&gt; preset: enabled&lt;span class="o"&gt;)&lt;/span&gt;
     Active: active &lt;span class="o"&gt;(&lt;/span&gt;running&lt;span class="o"&gt;)&lt;/span&gt; since Tue 2024-02-20 21:03:17 EST&lt;span class="p"&gt;;&lt;/span&gt; 16min ago
       Docs: man:nginx&lt;span class="o"&gt;(&lt;/span&gt;8&lt;span class="o"&gt;)&lt;/span&gt;
   Main PID: 5163 &lt;span class="o"&gt;(&lt;/span&gt;nginx&lt;span class="o"&gt;)&lt;/span&gt; 
   &lt;span class="o"&gt;[&lt;/span&gt;...]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now we create the systemd file that runs Gunicorn as a service. Add the following code but change all paths and user names so that they correspond to your set up. Pay careful attention to the &lt;code&gt;Environment=&lt;/code&gt; and &lt;code&gt;ExecStart=&lt;/code&gt; variables. The &lt;code&gt;Environment=&lt;/code&gt; variable should lead to the &lt;code&gt;bin&lt;/code&gt; directory inside your virtual environment. The &lt;code&gt;ExecStart=&lt;/code&gt; path should lead where gunicorn is installed in the virtual environment.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo vim /etc/systemd/system/myproject.service


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;[Unit]&lt;br&gt;
Description=&lt;code&gt;myproject&lt;/code&gt;.service - A Flask application run with Gunicorn.&lt;br&gt;
After=network.target&lt;/p&gt;

&lt;p&gt;[Service]&lt;br&gt;
User=&lt;code&gt;brandon&lt;/code&gt;&lt;br&gt;
Group=www-data&lt;br&gt;
Environment="PATH=&lt;code&gt;/var/www/myproject/.venv/bin"&lt;/code&gt;&lt;br&gt;
WorkingDirectory=/var/www/&lt;code&gt;myproject&lt;/code&gt;/&lt;br&gt;
ExecStart=&lt;code&gt;/var/www/myproject/.venv/bin/gunicorn&lt;/code&gt; --workers 3 \ &lt;br&gt;
--bind unix:/var/www/&lt;code&gt;myproject/myproject&lt;/code&gt;.sock wsgi:app&lt;/p&gt;

&lt;p&gt;[Install]&lt;br&gt;
WantedBy=multi-user.target&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;User&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sets the user who has permission to the project directory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Group&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sets the group who has permission to the project directory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Environment&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sets the path to the &lt;code&gt;bin&lt;/code&gt; directory inside the virtual environment.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WorkingDirectory&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sets the base directory where the code for the project is.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ExecStart&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sets the path to the &lt;code&gt;gunicorn&lt;/code&gt; executable inside the virtual environment along with the gunicorn command line options.&lt;/p&gt;

&lt;p&gt;Now I enable and start the myproject systemd service.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable &lt;/span&gt;myproject

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start myproject


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next we need to create the server block/virtual host in Nginx. Create a file in &lt;code&gt;/etc/nginx/sites-available/&lt;/code&gt; with any editor. Add the following content. Change the name &lt;code&gt;myproject&lt;/code&gt;.conf to the name of your project.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vim /etc/nginx/sites-available/myproject.conf


&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;

server &lt;span class="o"&gt;{&lt;/span&gt;
        listen 80&lt;span class="p"&gt;;&lt;/span&gt;
        server_name myproject www.myproject&lt;span class="p"&gt;;&lt;/span&gt;

        access_log /var/log/nginx/myproject.access.log&lt;span class="p"&gt;;&lt;/span&gt;
        error_log /var/log/nginx/myproject.error.log&lt;span class="p"&gt;;&lt;/span&gt;

        location / &lt;span class="o"&gt;{&lt;/span&gt;
                include proxy_params&lt;span class="p"&gt;;&lt;/span&gt;
                proxy_pass http://unix:/var/www/myproject/myproject.sock&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;server_name&lt;/code&gt; is where the domain name goes. That is what you will use to access the web application.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;access_log&lt;/code&gt; and &lt;code&gt;error_logs&lt;/code&gt; specify the path to the access  and error logs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;location&lt;/code&gt; block is where Nginx reverses proxy back to the Flask application.&lt;/p&gt;

&lt;p&gt;Enable the website by creating a link to the sites-enabled directory.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo ln&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; /etc/nginx/sites-available/myproject.conf /etc/nginx/sites-enabled/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Make sure the link has been created in sites-enabled directory.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; /etc/nginx/sites-enabled/ | &lt;span class="nb"&gt;grep &lt;/span&gt;myproject

lrwxrwxrwx 1 root root 41 Feb 20 17:37 myproject.conf -&amp;gt; /etc/nginx/sites-available/myproject.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check the nginx configuration for errors then restart the service.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;nginx &lt;span class="nt"&gt;-t&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart nginx

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl status nginx


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The Flask application is no longer accessible via the IP address since it is now being served by Gunicorn and Nginx. To access the Flask application you would need to use the name you set in the Nginx server block for the directive &lt;code&gt;server_name&lt;/code&gt; in the Nginx configuration. To access the web page can edit the host file on your desktop/laptop to point the domain to the IP address of your server.&lt;/p&gt;

&lt;p&gt;Edit the host file to add point the domain name to the server.&lt;br&gt;
Since my server's IP address is &lt;code&gt;192.168.12.34&lt;/code&gt; I would add this line to the host file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;192.168.12.34       myproject    www.myproject&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Host file location for Linux:&lt;br&gt;
&lt;code&gt;/etc/hosts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Host file location for Windows:&lt;br&gt;
&lt;code&gt;C:\Windows\System32\drivers\etc\hosts&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now I can access the Flask application with a browser via the name.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://myproject&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://www.myproject&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should seen something similar below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbwhDFB3X%2Fflask-app2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.postimg.cc%2FbwhDFB3X%2Fflask-app2.png" alt="flask-app2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Troubleshooting
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Here are some troubleshooting steps...
&lt;/h2&gt;

&lt;p&gt;For when things do not go right there are a few things you can do to troubleshoot.&lt;/p&gt;

&lt;p&gt;It is very important to check carefully for any spelling errors in all the files you edited.&lt;/p&gt;

&lt;p&gt;Check systemd.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ sudo systemctl status myproject.service&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ sudo journalctl -xe&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Restart the Gunicorn systemd service.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart myproject.service
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl daemon-reload


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Add logging to Gunicorn by changing the &lt;code&gt;ExecStart&lt;/code&gt; line. Add &lt;code&gt;--error-logfile error.log&lt;/code&gt; and &lt;code&gt;--log-level debug&lt;/code&gt; to the end of the line.&lt;/p&gt;

&lt;p&gt;Change the &lt;code&gt;ExecStart&lt;/code&gt; line:&lt;/p&gt;

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

&lt;span class="nv"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/www/myproject/.venv/bin/gunicorn &lt;span class="nt"&gt;--workers&lt;/span&gt; 3 &lt;span class="nt"&gt;--bind&lt;/span&gt; unix:/path/to/myproject/myproject.sock wsgi:app


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To this:&lt;/p&gt;

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

&lt;span class="nv"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/var/www/myproject/.venv/bin/gunicorn &lt;span class="nt"&gt;--workers&lt;/span&gt; 3 &lt;span class="nt"&gt;--bind&lt;/span&gt; unix:/path/to/myproject/myproject.sock wsgi:app &lt;span class="nt"&gt;--error-logfile&lt;/span&gt; error.log &lt;span class="nt"&gt;--log-level&lt;/span&gt; debug


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Check the Nginx log files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ less /var/www/nginx/error.log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ less /var/www/myproject/error.log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Check to see if the Nginx server is listening on port 80.&lt;/p&gt;

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

&lt;span class="nv"&gt;$ &lt;/span&gt;ss &lt;span class="nt"&gt;-lnt&lt;/span&gt; | &lt;span class="nb"&gt;grep &lt;/span&gt;80
LISTEN    0         511                0.0.0.0:80               0.0.0.0:&lt;span class="k"&gt;*&lt;/span&gt; 
LISTEN    0         511                   &lt;span class="o"&gt;[&lt;/span&gt;::]:80                  &lt;span class="o"&gt;[&lt;/span&gt;::]:&lt;span class="k"&gt;*&lt;/span&gt; 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Use curl to check for a 200 OK response.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ curl -I http://myproject&lt;/code&gt;&lt;/p&gt;


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

&lt;p&gt;HTTP/1.0 200 OK&lt;br&gt;
Content-Type: text/html&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;utf-8&lt;br&gt;
Content-Length: 30&lt;br&gt;
Server: Werkzeug/1.0.1 Python/2.7.16&lt;br&gt;
Date: Wed, 03 Feb 2021 15:18:55 GMT&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Conclusion&lt;br&gt;
&lt;/h1&gt;

&lt;p&gt;You have learned to configure Gunicorn to run a Flask application. You learned how to run Gunicorn as a systemd service. You learned to configured a virtual host in Nginx. You should now be able to deploy a Flask application to a server.&lt;/p&gt;

&lt;p&gt;Follow me on &lt;a href="https://github.com/brandon-wallace" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to leave questions, suggestions, and comments.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>python</category>
      <category>nginx</category>
      <category>flask</category>
    </item>
  </channel>
</rss>
