<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tutorial on Douglas Domingos :: CompSci@UFCG</title><link>https://dougdomingos.netlify.app/tags/tutorial/</link><description>Recent content in Tutorial on Douglas Domingos :: CompSci@UFCG</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 20 Nov 2024 18:49:01 -0300</lastBuildDate><atom:link href="https://dougdomingos.netlify.app/tags/tutorial/index.xml" rel="self" type="application/rss+xml"/><item><title>Creating a Multiboot USB Drive with Ventoy</title><link>https://dougdomingos.netlify.app/posts/multiboot-usb-with-ventoy/</link><pubDate>Wed, 20 Nov 2024 18:49:01 -0300</pubDate><guid>https://dougdomingos.netlify.app/posts/multiboot-usb-with-ventoy/</guid><description>Introduction During a deploy of our custom Linux Mint images in one of the labs at UFCG, I&amp;rsquo;ve learned about Ventoy – an interesting tool for creating bootable USB drives. Of all the tools I&amp;rsquo;ve used for this task (like Rufus and Etcher), Ventoy catched my interest for three reasons:
It does not require flashing the ISO into the USB drive It allows you to add multiple ISO files to the USB drive, without tweaking with disk partitions It allows you to choose which image to boot from at startup Ventoy is also very easy to install and use, as it provides packages with graphical interface for Linux, so you don&amp;rsquo;t have to worry with cryptic shell commands.</description><content>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>During a deploy of our custom Linux Mint images in one of the labs at UFCG, I&amp;rsquo;ve
learned about &lt;a href="https://www.ventoy.net/en/index.html">Ventoy&lt;/a> – an interesting
tool for &lt;strong>creating bootable USB drives&lt;/strong>. Of all the tools I&amp;rsquo;ve used for this
task (like Rufus and Etcher), Ventoy catched my interest for three reasons:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>It does not require flashing the ISO&lt;/strong> into the USB drive&lt;/li>
&lt;li>It allows you to &lt;strong>add multiple ISO files&lt;/strong> to the USB drive, without
tweaking with disk partitions&lt;/li>
&lt;li>It allows you to &lt;strong>choose which image to boot from at startup&lt;/strong>&lt;/li>
&lt;/ol>
&lt;p>Ventoy is also very easy to install and use, as &lt;strong>it provides packages with
graphical interface&lt;/strong> for Linux, so you don&amp;rsquo;t have to worry with cryptic shell
commands. But that&amp;rsquo;s boring, so we&amp;rsquo;re going to get our hands dirty anyways
&amp;#x1f971;&lt;/p>
&lt;h2 id="how-ventoy-works">How Ventoy works?&lt;/h2>
&lt;p>While installing Ventoy on an USB drive, it will create two main partitions:&lt;/p>
&lt;ul>
&lt;li>The EFI partition (formatted as &lt;code>FAT&lt;/code>), where Ventoy&amp;rsquo;s bootloader and
configurations are stored, and only 32MB in size&lt;/li>
&lt;li>The main partition (usually formatted as &lt;code>exFAT&lt;/code> or &lt;code>FAT32&lt;/code>), where you can
place your ISO files&lt;/li>
&lt;/ul>
&lt;p>When booting from the USB drive, &lt;strong>Ventoy&amp;rsquo;s bootloader will look for ISO files&lt;/strong>
inside the main partition and &lt;strong>list them at the boot menu&lt;/strong>. Please note that
the disk layout may vary, depending on whether you choose the
&lt;a href="https://www.ventoy.net/en/doc_disk_layout.html">MBR&lt;/a> or
&lt;a href="https://www.ventoy.net/en/doc_disk_layout_gpt.html">GPT&lt;/a> partitioning scheme.&lt;/p>
&lt;h2 id="using-ventoy-on-linux">Using Ventoy on Linux&lt;/h2>
&lt;p>As mentioned before, we&amp;rsquo;ll be installing Ventoy through CLI – like &lt;em>real&lt;/em> Linux
users would. So, you&amp;rsquo;ll need to download the binary packages (e.g.
&lt;code>ventoy-1.0.XX-linux.tar.gz&lt;/code> file), which are avaliable at
&lt;a href="https://sourceforge.net/projects/ventoy/files/">SourceForge&lt;/a>. I recommend
unpacking the tarball at &lt;code>/opt&lt;/code> for convenience.&lt;/p>
&lt;p>Inside the package, you&amp;rsquo;ll see a bunch of executable files. Since we won&amp;rsquo;t use a
graphical interface, our focus is in the &lt;code>Ventoy2Disk.sh&lt;/code> script.&lt;/p>
&lt;blockquote>
&lt;p>If you wish to install Ventoy using a graphical interface, &lt;strong>execute one of
the files labeled with the &lt;code>VentoyGUI&lt;/code> prefix&lt;/strong>. Please note that you have to
choose &lt;strong>the executable with the same architecture as your machine&lt;/strong> (e.g.
&lt;code>VentoyGUI.x86_64&lt;/code> for 64-bit machines).&lt;/p>
&lt;p>You may also &lt;strong>use an Web UI&lt;/strong> by executing the &lt;code>VentoyWeb.sh&lt;/code> and opening
your browser at &lt;code>http://localhost:24680&lt;/code>&lt;/p>
&lt;/blockquote>
&lt;p>If you plan to use Ventoy frequently, it might be interesting to &lt;strong>add the
executables to your &lt;code>$PATH&lt;/code>&lt;/strong>. For that, I have an article on how to install
packages manually on Linux, which you can find
&lt;a href="https://dougdomingos.github.io/v2/posts/installing-packages-in-opt">here&lt;/a>.&lt;/p>
&lt;h2 id="installing-ventoy-on-a-usb-drive">Installing Ventoy on a USB drive&lt;/h2>
&lt;p>Now that we have the package set up on our machine, let&amp;rsquo;s take a look on how to
use &lt;code>Ventoy2Disk.sh&lt;/code>. After running the script without any arguments, we get the
following output:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>[...]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Usage: Ventoy2Disk.sh CMD [ OPTION ] /dev/sdX
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CMD:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -i install Ventoy to sdX (fails if disk already installed with Ventoy)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -I force install Ventoy to sdX (no matter if installed or not)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -u update Ventoy in sdX
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -l list Ventoy information in sdX
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> OPTION: (optional)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -r SIZE_MB preserve some space at the bottom of the disk (only for install)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -s/-S enable/disable secure boot support (default is enabled)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -g use GPT partition style, default is MBR (only for install)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -L Label of the 1st exfat partition (default is Ventoy)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> -n try non-destructive installation (only for install)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Although the text is pretty straightforward, we need to find &lt;strong>which device is
our USB drive&lt;/strong> – specified by &lt;code>/dev/sdX&lt;/code>. For that, you can use the &lt;code>lsblk&lt;/code>
command to list all the block devices in the system. Here&amp;rsquo;s a sample output for
this command:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span>user@host:~# lsblk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[...]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sda 8:0 0 238,5G 0 disk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>├─sda3 8:3 0 237,5G 0 part /
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>└─sda4 8:4 0 1G 0 part /boot/efi
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sdb 8:16 1 7,5G 0 disk
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>├─sdb1 8:17 1 7,5G 0 part /media/dougsilva/Ventoy
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>└─sdb2 8:18 1 32M 0 part
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>[...]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>USB devices are usually mounted at the &lt;code>/media&lt;/code> directory&lt;/strong>. In my case, the
USB drive is represented by &lt;code>sdb&lt;/code> device, so I must pass &lt;code>/dev/sdb&lt;/code> as the
installation device to the &lt;code>Ventoy2Disk.sh&lt;/code> script. Below are some examples on
how to configure your installation:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-text" data-lang="text">&lt;span style="display:flex;">&lt;span># Install Ventoy on /dev/sdX. This will fail if Ventoy is already installed.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo ./Ventoy2Disk.sh -i /dev/sdX
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># Force install on /dev/sdX, ignoring any existent Ventoy installation
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo ./Ventoy2Disk.sh -I /dev/sdX
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># Install on /dev/sdX while keeping a 500MB free space at the end of the device
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo ./Ventoy2Disk.sh -i -r 500 /dev/sdX
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span># Install on /dev/sdX with GPT partition style and labelling the main partition as &amp;#34;Multiboot USB&amp;#34;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo ./Ventoy2Disk.sh -i -g -L &amp;#34;Multiboot USB&amp;#34; /dev/sdX
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Please note that installing Ventoy &lt;strong>WILL ERASE ALL DATA FROM THE DEVICE&lt;/strong>, so
you should backup any important files from the USB drive before installation.
Also, while installing through command-line, &lt;strong>be careful to not mistake your
USB drive for another device&lt;/strong>.&lt;/p>
&lt;blockquote>
&lt;p>You can also use the &lt;code>fdisk -l&lt;/code> command to list the devices of your machine
with a more verbose output. This allows you to search for a device with &lt;code>grep&lt;/code>
(i.e. &lt;code>fdisk -l | grep &amp;quot;YOUR_DEVICE&amp;quot;&lt;/code>).&lt;/p>
&lt;/blockquote>
&lt;h2 id="booting-up-the-usb-drive">Booting up the USB drive&lt;/h2>
&lt;p>After the installation is complete, you can simply drag-and-drop your ISO files
into the main partition, reboot your machine and boot from the USB drive. If you
had no unpleasant surprises during installation, you should see the following
screen:&lt;/p>
&lt;p>&lt;img alt="Ventoy Menu screen" src="https://dougdomingos.netlify.app/images/ventoy-iso-menu.png" title="Ventoy Menu screen">&lt;/p>
&lt;p>From here, simply choose which ISO you wish to boot, and select the
&lt;code>Boot in normal mode&lt;/code> option. For more information about boot modes, read
&lt;a href="https://www.ventoy.net/en/doc_secondary_boot_menu.html">the documentation&lt;/a>.&lt;/p>
&lt;blockquote>
&lt;p>Some machines have &lt;strong>a hot key for entering the Boot Menu&lt;/strong> at startup, so you
don&amp;rsquo;t need to &lt;strong>manually change the boot order&lt;/strong> in your BIOS. Please check
out &lt;a href="https://www.disk-image.com/faq-bootmenu.htm">this list&lt;/a> for reference.&lt;/p>
&lt;/blockquote>
&lt;h2 id="considerations-about-secure-boot">Considerations about Secure Boot&lt;/h2>
&lt;p>Since Ventoy 1.0.76, &lt;strong>Secure Boot support is enabled by default&lt;/strong>. This means
that Ventoy should work &lt;strong>whether Secure Boot is enabled in your machine or
not&lt;/strong>.&lt;/p>
&lt;p>If Secure Boot is indeed enabled in your machine, you should see the screen
below when booting Ventoy for the first time. Please follow these instructions
in &lt;a href="https://www.ventoy.net/en/doc_secure.html">Ventoy&amp;rsquo;s documentation&lt;/a> on how to
allow Ventoy on Secure Boot.&lt;/p>
&lt;p>&lt;img alt="Ventoy&amp;rsquo;s Secure Boot prompt screen" src="https://dougdomingos.netlify.app/images/sb-first-boot.png" title="Ventoy's Secure Boot prompt screen">&lt;/p>
&lt;p>However, if you see &lt;strong>another error screen&lt;/strong> while booting Ventoy, &lt;strong>your system
may not support Ventoy on Secure Boot&lt;/strong>. As such, you&amp;rsquo;ll need to disable the
option in your Ventoy installation and your BIOS.&lt;/p>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Until now, Ventoy has proved to be a handy tool for testing Linux distributions
and keeping backup ISOs for system recovery. It&amp;rsquo;s easy to install and use, it&amp;rsquo;s
lightweight and also quite fast when compared to similar tools.&lt;/p>
&lt;p>While I have not tried installing a system through Ventoy, I plan to try it out
soon with Fedora, and if everything goes as expected, I may use it to setup a
dual-boot installation with Windows in the (not so) far future.&lt;/p></content></item><item><title>Installing software in Linux, the "hard" way</title><link>https://dougdomingos.netlify.app/posts/installing-packages-in-opt/</link><pubDate>Sun, 15 Sep 2024 13:34:18 -0300</pubDate><guid>https://dougdomingos.netlify.app/posts/installing-packages-in-opt/</guid><description>Introduction Picture this: you&amp;rsquo;re setting up the packages and tools to develop your brand new application. Everything is going smooth, until you found out that one of the softwares you need is only avaliable as package of executable binaries, without any installers and nowhere to be found in your package managers. Seems like quite the overhead, right?
Well, not to worry! Because today we&amp;rsquo;re out to get our hands dirty and learn how to install ANY PACKAGE in a Linux system ‒ and you might just learn a few new tricks about Linux along the way.</description><content>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>Picture this: you&amp;rsquo;re setting up the packages and tools to develop your brand new
application. Everything is going smooth, until you found out that &lt;strong>one of the
softwares you need is only avaliable as package of executable binaries&lt;/strong>,
without any installers and nowhere to be found in your package managers. Seems
like quite the overhead, right?&lt;/p>
&lt;p>Well, not to worry! Because today we&amp;rsquo;re out to get our hands dirty and learn how
to install &lt;strong>ANY PACKAGE&lt;/strong> in a Linux system ‒ and you might just learn a few
new tricks about Linux along the way.&lt;/p>
&lt;h2 id="i-housing-the-package">I. Housing the package&lt;/h2>
&lt;p>The first step to solve our problem is to define &lt;strong>where the package will be
stored in our system&lt;/strong>. In practice, you may use any directory you&amp;rsquo;d like, but
to keep things organized, let&amp;rsquo;s use the &lt;code>/opt&lt;/code> directory.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>The &lt;code>/opt&lt;/code> directory&lt;/strong> is reserved for installing software and packages that
are not part of the system&amp;rsquo;s core components, i.e, &lt;strong>not necessary for your
system to function&lt;/strong> properly.&lt;/p>
&lt;p>When installing your package, &lt;strong>you should create a new directory&lt;/strong>
(preferably with the package name, like &lt;code>/opt/&amp;lt;package_name&amp;gt;&lt;/code>) to &lt;strong>avoid
mixing up files&lt;/strong> of different packages.&lt;/p>
&lt;/blockquote>
&lt;p>You may have noticed that inside your package, there&amp;rsquo;s a &lt;code>/bin&lt;/code> directory that
contains some executable files. At this point, we can run these files, but we&amp;rsquo;ll
have to specify the full path of the file every time.&lt;/p>
&lt;h2 id="ii-make-your-package-avaliable-with-path">II. Make your package avaliable with &lt;code>$PATH&lt;/code>&lt;/h2>
&lt;p>To avoid having to pass the full path of the executables each time we run the
software, we&amp;rsquo;ll make use of the &lt;code>$PATH&lt;/code> environmental variable to &lt;strong>specify the
path of our installation&lt;/strong>.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>The &lt;code>$PATH&lt;/code> variable&lt;/strong> is a special shell variable that defines a &lt;strong>list of
directories where executable files are located&lt;/strong>. Each directory is
&lt;strong>delimited by a colon&lt;/strong> (&lt;code>:&lt;/code>)&lt;/p>
&lt;p>You may specify new directories in &lt;code>$PATH&lt;/code> by &lt;strong>exporting the variable with
the new value&lt;/strong> (&lt;code>export PATH=/new/dir/path:$PATH&lt;/code>).&lt;/p>
&lt;/blockquote>
&lt;p>Now, there are two ways of adding a executable to &lt;code>$PATH&lt;/code>:&lt;/p>
&lt;h3 id="adding-a-_symlink_-to-the-executables">Adding a &lt;em>Symlink&lt;/em> to the executables&lt;/h3>
&lt;p>&lt;em>Symlinks&lt;/em> are (roughly) &lt;strong>files that &amp;ldquo;point&amp;rdquo; to other file paths or
directories&lt;/strong>. This allows us to access files accross the file system (and even
other file systems), &lt;strong>without specifying the full path&lt;/strong>.&lt;/p>
&lt;p>You can create new &lt;em>symlinks&lt;/em> using the command &lt;code>ln -s TARGET LINK_NAME&lt;/code>, where:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;code>TARGET&lt;/code> is the &lt;strong>path of the file which the &lt;em>symlink&lt;/em> will point to&lt;/strong>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;code>LINK_NAME&lt;/code> is the &lt;strong>path where the &lt;em>symlink&lt;/em> will be created&lt;/strong>&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>To make it avaliable in &lt;code>$PATH&lt;/code>, we may &lt;strong>create a &lt;em>symlink&lt;/em> inside a directory
that is already in &lt;code>$PATH&lt;/code>&lt;/strong>. In this case, let&amp;rsquo;s use the &lt;code>/usr/local/bin&lt;/code>
directory to store our &lt;em>symlink&lt;/em>.&lt;/p>
&lt;p>To create our &lt;em>symlink&lt;/em>, simply run the following comman:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Replace the placeholders with the proper names of your directories/files&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ln -s /opt/&amp;lt;package_name&amp;gt;/bin/&amp;lt;filename&amp;gt; /usr/local/bin/&amp;lt;filename&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Once created, the executable will be avaliable in your shell. Try it out by
&lt;strong>typing the name of the &lt;em>symlink&lt;/em> in your terminal&lt;/strong>.&lt;/p>
&lt;h4 id="trade-offs-of-using-_symlinks_">Trade-offs of using &lt;em>symlinks&lt;/em>&lt;/h4>
&lt;p>This approach is &lt;strong>pretty straightforward and easy to setup&lt;/strong>. We don&amp;rsquo;t need to
edit the value of &lt;code>$PATH&lt;/code>, thus &lt;strong>avoiding possible configuration errors&lt;/strong>.
Also, by placing the &lt;em>symlink&lt;/em> inside &lt;code>/usr/local/bin&lt;/code>, we make it &lt;strong>avaliable
for all users of the system&lt;/strong>.&lt;/p>
&lt;p>Unfortunately, there are also drawbacks. If you need to add multiple
executables, you&amp;rsquo;ll need do &lt;strong>create one &lt;em>symlink&lt;/em> per executable&lt;/strong>. You may
&lt;strong>create a &lt;em>symlink&lt;/em> to the &lt;code>/bin&lt;/code> directory&lt;/strong> of the package, but you&amp;rsquo;ll still
need to &lt;strong>specify the name of the executable&lt;/strong>.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>Links in Linux&lt;/strong>&lt;br>
Links are a powerful tool in Linux, allowing you to &lt;strong>create shortcuts between
files and directories&lt;/strong>, &lt;strong>organizing your files easily&lt;/strong>, and much more. I
recommend reading this
&lt;a href="https://www.redhat.com/sysadmin/linking-linux-explained">RedHat post about linking in Linux&lt;/a>.&lt;/p>
&lt;/blockquote>
&lt;h3 id="adding-the-package-directory-to-path">Adding the package directory to &lt;code>$PATH&lt;/code>&lt;/h3>
&lt;p>If you want a more &lt;strong>robust solution&lt;/strong>, you may effectivelly edit the &lt;code>$PATH&lt;/code>
variable to &lt;strong>include your package directory&lt;/strong>. For that, we&amp;rsquo;ll need to &lt;strong>create
a configuration file&lt;/strong> to export our updated &lt;code>$PATH&lt;/code>.&lt;/p>
&lt;blockquote>
&lt;p>&lt;strong>The &lt;code>/etc/&lt;/code> directory&lt;/strong> contains configuration files of system applications,
e.g. service management, network, SSH, and many more. Be careful when making
changes to files here.&lt;/p>
&lt;/blockquote>
&lt;p>Similar to &lt;code>/opt&lt;/code>, Linux also has a directory for &lt;strong>storing system-wide
configuration files: the &lt;code>/etc&lt;/code> directory&lt;/strong>. Actually, there&amp;rsquo;s the &lt;code>/etc/opt&lt;/code>
directory, which is intended to store configuration files for &lt;strong>applications
installed in &lt;code>/opt&lt;/code>&lt;/strong>.&lt;/p>
&lt;p>To create the configuration file, head to &lt;code>/etc/opt&lt;/code> and create a new file,
named as &lt;code>&amp;lt;package_name&amp;gt;rc&lt;/code>. Inside it, paste the following code and replace the
placeholders with the correspondent paths:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># Replace &amp;#34;PACKAGE_HOME&amp;#34; with the name of your package&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export PACKAGE_HOME&lt;span style="color:#f92672">=&lt;/span>/opt/&amp;lt;package_dir&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>export PATH&lt;span style="color:#f92672">=&lt;/span>$PACKAGE_HOME/bin:$PATH
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>To load the settings into your shell session, run
&lt;code>source /etc/opt/&amp;lt;config_file&amp;gt;&lt;/code> and check your &lt;code>$PATH&lt;/code> variable with
&lt;code>echo $PATH&lt;/code>. If the directory of your package is there, your configuration file
is working.&lt;/p>
&lt;p>Now, you might have noticed that &lt;strong>the configurations aren&amp;rsquo;t loaded
automatically&lt;/strong> when you open a new terminal. To address this, simply add this
configuration to one of the following files:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># This loads &amp;#34;PACKAGE&amp;#34; into $PATH&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">[&lt;/span> -f /etc/opt/&amp;lt;config_file&amp;gt; &lt;span style="color:#f92672">]&lt;/span> &lt;span style="color:#f92672">&amp;amp;&amp;amp;&lt;/span> source /etc/opt/&amp;lt;config_file&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>
&lt;p>For &lt;strong>only one user&lt;/strong>, append the load configuration at the end of &lt;code>~/.bashrc&lt;/code>&lt;/p>
&lt;/li>
&lt;li>
&lt;p>For &lt;strong>all users&lt;/strong>, create a shell script (with the &lt;code>.sh&lt;/code> suffix) in
&lt;code>/etc/profile.d/&lt;/code> with the load configuration&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h4 id="trade-offs-of-using-path">Trade-offs of using &lt;code>$PATH&lt;/code>&lt;/h4>
&lt;p>One advantage of this approach is that &lt;strong>every executable inside the &lt;code>/bin&lt;/code>
directory will be avaliable&lt;/strong> in your shell. Also, you may choose to &lt;strong>make it
avaliable for only one user or for all users&lt;/strong>, by simply placing the load
configuration in a different file.&lt;/p>
&lt;p>However, &lt;strong>tweaking with the &lt;code>$PATH&lt;/code> variable may break your shell
configuration&lt;/strong> if you&amp;rsquo;re not careful enough. The same goes for editing files
inside &lt;code>/etc/profile.d&lt;/code>; it&amp;rsquo;s best to create a new file rather than edit an
existing one.&lt;/p>
&lt;h2 id="iii-updating-the-desktop-menu-bonus">III. Updating the desktop menu (BONUS)&lt;/h2>
&lt;p>If you’re installing an application with a graphical interface (not CLI-based),
you’ll likely want to add it to your desktop menu for easier access. In this
case, we&amp;rsquo;ll need to take an extra step.&lt;/p>
&lt;p>The entries in your desktop menu are located in the &lt;code>/usr/share/applications&lt;/code>
directory. Each application has a &lt;code>.desktop&lt;/code> entry file, containing settings for
how it is displayed in the menu.&lt;/p>
&lt;p>To add a desktop entry file for your application:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>Create a new &lt;code>.desktop&lt;/code> entry file with the name of your application&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Open the file and add the following configuration, replacing the placeholders
with the correct settings:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f92672">[&lt;/span>Desktop Entry&lt;span style="color:#f92672">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Version&lt;span style="color:#f92672">=&lt;/span>1.0
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Type&lt;span style="color:#f92672">=&lt;/span>Application
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Name&lt;span style="color:#f92672">=&lt;/span>&amp;lt;APP_NAME&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Icon&lt;span style="color:#f92672">=&lt;/span>/opt/&amp;lt;PACKAGE_NAME&amp;gt;/&amp;lt;ICON_FILE&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Exec&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">&amp;#34;/opt/&amp;lt;PACKAGE_NAME&amp;gt;/&amp;lt;EXEC_FILE&amp;gt;&amp;#34;&lt;/span> %f
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Comment&lt;span style="color:#f92672">=&lt;/span>&amp;lt;APP_DESCRIPTION&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Categories&lt;span style="color:#f92672">=&lt;/span>&amp;lt;KEYWORD1;KEYWORD2;&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Save the file and run &lt;code>sudo update-desktop-database&lt;/code>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;p>Now, the application is avaliable in your app menu, without the need to start it
through the terminal.&lt;/p>
&lt;h2 id="summary">Summary&lt;/h2>
&lt;ul>
&lt;li>
&lt;p>Install your package in the &lt;code>/opt&lt;/code> directory&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Use &lt;em>symlinks&lt;/em> or edit your &lt;code>$PATH&lt;/code> variable to include the package
executables for an user or all the system&lt;/p>
&lt;/li>
&lt;li>
&lt;p>If the package is not CLI-based, add a &lt;code>.desktop&lt;/code> entry file at
&lt;code>/usr/share/applications&lt;/code> to add the package to your desktop menu&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="conclusion">Conclusion&lt;/h2>
&lt;p>Although application support for Linux platforms is pretty decent today, you&amp;rsquo;ll
eventually come across a situation like the one we&amp;rsquo;ve discussed here. Also, you
can automate this process by creating shell scripts to setup the files for you.&lt;/p>
&lt;p>Well, that&amp;rsquo;s it. Until next time! &amp;#x1f44b;&lt;/p></content></item></channel></rss>