<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Tutorial Works</title>
    <description>Trusted content for developers, engineers and software architects.</description>
    <link>https://www.tutorialworks.com/</link>
    <atom:link href="https://www.tutorialworks.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Fri, 20 Dec 2024 09:34:44 +0000</pubDate>
    <lastBuildDate>Fri, 20 Dec 2024 09:34:44 +0000</lastBuildDate>
    <generator>Jekyll v4.1.1</generator>
    
      <item>
        <title>Using environment variables in shell scripts: Tutorial</title>
        <description>&lt;p&gt;Environment variables are one of those Linux things that, once they click, you’ll be using them everywhere.&lt;/p&gt;

&lt;p&gt;In this tutorial we’ll dabble a bit with environment variables, and see how they can be used in shell scripts. Everything we do in this tutorial will be done in the terminal, so you’ll get some good practice with the Linux command line too.&lt;/p&gt;

&lt;p&gt;But first, environment variables: what are they?&lt;/p&gt;

&lt;h2 id=&quot;what-are-environment-variables&quot;&gt;What are environment variables?&lt;/h2&gt;

&lt;p&gt;Environment variables (or “env vars” if you want to save some breath) are a way of storing configuration information in Linux. They’re a good way to store configuration, or temporary data that you want to use in your programs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux usually has a bunch of environment variables that are already defined.&lt;/strong&gt; They’re like built-in properties. They tell you information about your system, such as the current user, the current working directory, and the current shell. They’re called things like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;USERNAME&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PWD&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SHELL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can also add your own custom environment variables to store information about your own programs.&lt;/p&gt;

&lt;h2 id=&quot;what-youll-need-for-the-tutorial&quot;&gt;What you’ll need for the tutorial&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;A Linux terminal, or a virtual machine running Linux. Any distribution of Linux should be fine.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You should have experience editing files using a text editor such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nano&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vim&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;steps&quot;&gt;Steps&lt;/h2&gt;

&lt;h3 id=&quot;looking-at-environment-variables&quot;&gt;Looking at environment variables&lt;/h3&gt;
&lt;p&gt;First let’s explore the environment variables that are already in your system, probably without you even realising it.&lt;/p&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Print your system’s environment variables.&lt;/strong&gt; Run the following command to print your system’s environment variables:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;printenv&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;Now you should see a list of environment variables, like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HOME&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SHELL&lt;/code&gt;. For example, the output on my system looks like this:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SHELL=/bin/bash
SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/5046,unix/unix:/tmp/.ICE-unix/5046
COLORTERM=truecolor
HISTCONTROL=ignoredups
XDG_MENU_PREFIX=gnome-
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p class=&quot;tip&quot;&gt;You can also use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;printenv&lt;/code&gt; command to print the value of a &lt;strong&gt;specific&lt;/strong&gt; environment variable. For example, try typing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;printenv HOME&lt;/code&gt; and seeing what you get!&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Search for a string in an environment variable.&lt;/strong&gt; Next, run the following command to search for a string in an environment variable name or value:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;printenv&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;SHELL
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;This command uses the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grep&lt;/code&gt; command to search for the string &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SHELL&lt;/code&gt; in the output of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;printenv&lt;/code&gt;.&lt;/p&gt;

    &lt;p&gt;Grep is an absolutely essential command for searching for things. You will probably use it every day.&lt;/p&gt;

    &lt;p&gt;We can also search for strings in the &lt;strong&gt;values&lt;/strong&gt; of our environment variables. So let’s search for the string &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt;:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;printenv&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;If you’re using bash as your Linux shell, you should see a line like this:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SHELL=/bin/bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;using-environment-variables-in-a-command&quot;&gt;Using environment variables in a command&lt;/h3&gt;
&lt;p&gt;Now that we’ve seen how to print and search for environment variables, how can we use them?&lt;/p&gt;

&lt;p&gt;One of the most common times you might use environment variables is when you’re running a command.&lt;/p&gt;

&lt;p&gt;For example, you might want to run a command on a specific file, but you don’t want to type the full path to the file.&lt;/p&gt;

&lt;p&gt;Or, you might want to give a sensitive password to a command, without having to type it in, or show it on-screen.&lt;/p&gt;

&lt;p&gt;Let’s use an environment variable in a command.&lt;/p&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Pass an environment variable to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt; command.&lt;/strong&gt; The echo command is one of the simplest Linux commands there is! It just prints whatever you pass to it.&lt;/p&gt;

    &lt;p&gt;Run the following command to print the value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HOME&lt;/code&gt; environment variable. We’re using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HOME&lt;/code&gt; because it’s a variable that’s set on all Linux systems:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;Note that we use the special &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$HOME&lt;/code&gt; syntax to access the value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HOME&lt;/code&gt; variable.&lt;/p&gt;

    &lt;p&gt;You should see output like this:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/home/tdonohue
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;(Note that your username will be different!)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Use an environment variable in another command.&lt;/strong&gt; Now let’s use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HOME&lt;/code&gt; environment variable in another command. Run the following command:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;This command uses the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd&lt;/code&gt; command to change the current working directory to the value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HOME&lt;/code&gt; environment variable.&lt;/p&gt;

    &lt;p class=&quot;tip&quot;&gt;You can always check the current working directory using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pwd&lt;/code&gt; command.&lt;/p&gt;

    &lt;p&gt;Now if you run the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pwd&lt;/code&gt; command, you should see that you’ve been taken to your home directory!&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;how-did-that-work&quot;&gt;How did that work?&lt;/h4&gt;
&lt;p&gt;So what just happened? When you type in a command with an environment variable, a &lt;i&gt;substitution&lt;/i&gt; happens.&lt;/p&gt;

&lt;p&gt;When you type the command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo $HOME&lt;/code&gt;, the &lt;strong&gt;shell&lt;/strong&gt; replaces the variable reference &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$HOME&lt;/code&gt; with the value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HOME&lt;/code&gt; environment variable.&lt;/p&gt;

&lt;p&gt;This means that Bash (or whichever shell you use) is responsible for the substitution. It’s not the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt; command that does it.&lt;/p&gt;

&lt;p&gt;So the first command that was &lt;strong&gt;actually&lt;/strong&gt; run, was this: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo /home/username&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;using-environment-variables-in-a-shell-script&quot;&gt;Using environment variables in a shell script&lt;/h3&gt;
&lt;p&gt;Now let’s get a bit more creative, and use environment variables in a shell script.&lt;/p&gt;

&lt;h4 id=&quot;create-the-script&quot;&gt;Create the script&lt;/h4&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Create a shell script.&lt;/strong&gt; Create a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello.sh&lt;/code&gt;. Remember you can create a file using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;touch&lt;/code&gt; command, or using your text editor like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vim&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nano&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pico&lt;/code&gt;. Then add the following code to it:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, world!&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;This is a simple shell script that prints “Hello, world!” to the terminal.&lt;/p&gt;

    &lt;p&gt;The line &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#!/bin/bash&lt;/code&gt; is called a &lt;i&gt;shebang&lt;/i&gt;. It tells the operating system that this file is a shell script, and that it should be run using the Bash shell.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Make the script executable.&lt;/strong&gt; In Linux, scripts aren’t executable by default, so we need to run the following command to make it executable:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;chmod&lt;/span&gt; +x hello.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;We use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chmod&lt;/code&gt; command to change the permissions of a file. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+x&lt;/code&gt; option means “add execute permissions”.&lt;/p&gt;

    &lt;p class=&quot;tip&quot;&gt;You can always check the permissions of a file using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -l&lt;/code&gt; command. For example, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls -l hello.sh&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Run the script.&lt;/strong&gt; Run the following command to run the script:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./hello.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;add-environment-variables-to-the-script&quot;&gt;Add environment variables to the script&lt;/h4&gt;
&lt;p&gt;Now that we have our test script, let’s add some environment variables.&lt;/p&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Reference an environment variable in the script.&lt;/strong&gt; Adding variables in shell scripts makes them more dynamic.&lt;/p&gt;

    &lt;p&gt;Let’s change the greeting to say hello to the current user. Fortunately in Linux there is usually an environment variable called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;USERNAME&lt;/code&gt; that stores the current user’s username.&lt;/p&gt;

    &lt;p&gt;So edit the file so it looks like this:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$USERNAME&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;!&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$USERNAME&lt;/code&gt; syntax is used to access the value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;USERNAME&lt;/code&gt; variable.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Run the script.&lt;/strong&gt; Once you’ve made the changes above, run the modified script.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./hello.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;You should see this output:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Hello, tdonohue!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;(Again, or whatever your username is!)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;define-our-own-environment-variables&quot;&gt;Define our own environment variables&lt;/h3&gt;
&lt;p&gt;Finally, to finish off, let’s define our own environment variables.&lt;/p&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Define an environment variable.&lt;/strong&gt; Run the following command to define an environment variable called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SECRET_CODE&lt;/code&gt;:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;SECRET_CODE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1234&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export&lt;/code&gt; command is used to define an environment variable. The syntax is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export VARIABLE_NAME=&quot;value&quot;&lt;/code&gt;.&lt;/p&gt;

    &lt;p class=&quot;tip&quot;&gt;You can also define an environment variable without the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export&lt;/code&gt; command, but it will only be available in the current shell session. Using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export&lt;/code&gt; makes it available to all child processes, including the programs you run.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Edit the script to print the environment variable.&lt;/strong&gt; Now let’s edit the script to use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SECRET_CODE&lt;/code&gt; environment variable. Edit the file so it looks like this:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$USERNAME&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;!&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Your secret code is &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$SECRET_CODE&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;Now when we run the script, it will print the value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SECRET_CODE&lt;/code&gt; environment variable.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Run the script and let’s see it in action.&lt;/strong&gt;&lt;/p&gt;

    &lt;p&gt;You know what to do:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./hello.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;And you should see:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Hello, tdonohue!
Your secret code is 1234
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And that’s the end of the tutorial!&lt;/p&gt;

&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;
&lt;p&gt;You did it. You’ve completed the tutorial!&lt;/p&gt;

&lt;p&gt;In this tutorial, you learned how to:&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;Print your system’s environment variables&lt;/li&gt;
  &lt;li&gt;Search for a string in an environment variable&lt;/li&gt;
  &lt;li&gt;Pass an environment variable to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt; command&lt;/li&gt;
  &lt;li&gt;Use environment variables in a shell script&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See you in the next tutorial!&lt;/p&gt;

&lt;!-- ## What&apos;s next?

-   [Learn more about environment variables](https://www.tutorialspoint.com/unix/unix-environment.htm)
-   [Learn more about shell scripts](https://www.tutorialspoint.com/unix/shell_scripting.htm)
-   [Learn more about the `printenv` command](https://www.computerhope.com/unix/uprintenv.htm)
-   [Learn more about the `grep` command](https://www.computerhope.com/unix/ugrep.htm)

 --&gt;
</description>
        <pubDate>Thu, 21 Sep 2023 06:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/environment-variables-shell-scripts/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/environment-variables-shell-scripts/</guid>
        
        
        <category>linux</category>
        
      </item>
    
      <item>
        <title>Unit vs integration testing: What&apos;s the difference?</title>
        <description>&lt;p&gt;Developers have a job to create reliable, working software. But how do you know that your code works? Whether you’re developing a small app or a large system, you need to test your code.&lt;/p&gt;

&lt;div class=&quot;summary contiguous&quot;&gt;
  &lt;h3 id=&quot;what-to-know&quot;&gt;What to know&lt;/h3&gt;

  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;Unit testing focuses on testing individual units of code in isolation, using specific test data, while integration testing examines how different systems or parts of the code interact with each other.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Unit tests are faster, easier to maintain, and validate the correctness of individual parts of the program, while integration tests are slower, more complex, and identify compatibility and integration issues.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Both unit and integration testing are important, and it’s good practice to write both.&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;p&gt;There are several types of tests. To be confident in writing tests, you need to understand the difference between them. Unit and integration testing are two common types of testing. The main difference between the two is the scope of the test: unit tests are about testing a single unit of code, while integration tests are about testing how different parts of your code work together.&lt;/p&gt;

&lt;figure class=&quot;full&quot; vocab=&quot;http://schema.org/&quot; typeof=&quot;ImageObject&quot;&gt;
  &lt;img src=&quot;https://assets.tutorialworks.com/images/man-at-machine.webp&quot; width=&quot;1200&quot; height=&quot;675&quot; loading=&quot;lazy&quot; property=&quot;contentUrl&quot; alt=&quot;A man at a machine, doing some testing&quot; /&gt;&lt;/figure&gt;

&lt;h2 id=&quot;unit-testing-explained&quot;&gt;Unit testing explained&lt;/h2&gt;

&lt;p&gt;A &lt;i&gt;Unit test&lt;/i&gt; is a way of verifying the correctness of a software program by testing a single part of it, in isolation. In practice, the term “unit” in “unit test” usually means testing a single function or method.&lt;/p&gt;

&lt;p&gt;Unit tests are usually small enough that they run quickly, and can be run often. This allows developers to quickly test their code, and to catch any errors before they become a problem.&lt;/p&gt;

&lt;p&gt;Unit tests should also be isolated, which means that each test should run independently from other tests. The outcome from one unit test should not affect another.&lt;/p&gt;

&lt;div class=&quot;secondary&quot;&gt;
  &lt;h4 id=&quot;an-example&quot;&gt;An example&lt;/h4&gt;

  &lt;p&gt;You write a test for a function in your application that calculates the total price of an order. The function takes a list of products and returns the total price.&lt;/p&gt;

  &lt;p&gt;You call the function with a list of products, and verify that the result is correct.&lt;/p&gt;

  &lt;p&gt;This is a unit test. It tests a small piece of code, and it’s isolated from other tests.&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;integration-testing-explained&quot;&gt;Integration testing explained&lt;/h2&gt;

&lt;p&gt;&lt;i&gt;Integration tests&lt;/i&gt; are a way of testing how different parts of your code work together. Integration tests are usually slower than unit tests, because they have a wider scope, and are often run less frequently.&lt;/p&gt;

&lt;p&gt;These types of tests are designed to test the interaction between components of a system.&lt;/p&gt;

&lt;div class=&quot;secondary&quot;&gt;
  &lt;h4 id=&quot;an-example-1&quot;&gt;An example&lt;/h4&gt;

  &lt;p&gt;You write a  test that logs on to your application, and verifies that the user was logged in successfully.&lt;/p&gt;

  &lt;p&gt;This test might involve several components:&lt;/p&gt;

  &lt;ul class=&quot;default&quot;&gt;
    &lt;li&gt;making a request to &lt;strong&gt;your logon method&lt;/strong&gt;&lt;/li&gt;
    &lt;li&gt;the logon method might call &lt;strong&gt;an API&lt;/strong&gt; to authenticate the user&lt;/li&gt;
    &lt;li&gt;the logon method might save the user’s details to &lt;strong&gt;a database&lt;/strong&gt;&lt;/li&gt;
  &lt;/ul&gt;

  &lt;p&gt;This is an integration test. It tests how different systems or parts of your code work together.&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;whats-the-difference-between-unit-and-integration-tests&quot;&gt;What’s the difference between unit and integration tests?&lt;/h2&gt;

&lt;p&gt;This table summarises some of the key differences between unit testing and integration testing:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th&gt;Unit testing&lt;/th&gt;
      &lt;th&gt;Integration testing&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Purpose&lt;/td&gt;
      &lt;td&gt;Validates individual parts of a program&lt;/td&gt;
      &lt;td&gt;Verifies how parts work together&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Scope&lt;/td&gt;
      &lt;td&gt;Focuses on individual units&lt;/td&gt;
      &lt;td&gt;Tests interaction between units&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Isolation&lt;/td&gt;
      &lt;td&gt;Tests parts separately&lt;/td&gt;
      &lt;td&gt;Tests parts together&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Granularity&lt;/td&gt;
      &lt;td&gt;Tests small, focused parts&lt;/td&gt;
      &lt;td&gt;Tests end-to-end scenarios&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Environment&lt;/td&gt;
      &lt;td&gt;Uses mocks or stubs in place of external dependencies&lt;/td&gt;
      &lt;td&gt;Uses real &lt;strong&gt;or&lt;/strong&gt; simulated integration environment&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Data used in the test&lt;/td&gt;
      &lt;td&gt;Specific test data, often to make a certain event or error happen&lt;/td&gt;
      &lt;td&gt;Realistic, production-like data&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Execution speed&lt;/td&gt;
      &lt;td&gt;Faster execution times&lt;/td&gt;
      &lt;td&gt;Slower, due to larger scope&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Level of complexity&lt;/td&gt;
      &lt;td&gt;Less complex, due to isolation&lt;/td&gt;
      &lt;td&gt;More complex, due to interaction&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Bug detection&lt;/td&gt;
      &lt;td&gt;Identifies logic errors&lt;/td&gt;
      &lt;td&gt;Identifies compatibility and integration issues&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Maintenance&lt;/td&gt;
      &lt;td&gt;Easier to maintain&lt;/td&gt;
      &lt;td&gt;Challenging, as dependencies can change often&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;which-is-more-important&quot;&gt;Which is more important?&lt;/h2&gt;

&lt;p&gt;It might be tempting to think that you can focus on one type of testing, and ignore the other. But both unit and integration testing are important, and you should have a good mix of both.&lt;/p&gt;

&lt;p&gt;Unit testing focuses on testing logic within a software program, which can be subject to programmer error.&lt;/p&gt;

&lt;p&gt;But most software applications also depend on another system – for example, a program might depend on a database or an API. Integration testing focuses on testing how the different parts of a software system work together.&lt;/p&gt;

&lt;p&gt;If you’re unsure which to write first, people suggest writing unit tests first, and then adding integration tests as you go. This is perhaps because unit tests are smaller and easier to write, and they can help you to refactor your code.&lt;/p&gt;

&lt;h3 id=&quot;the-test-pyramid&quot;&gt;The test pyramid&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;test pyramid&lt;/strong&gt;, originally by Mike Cohn, is a good visual illustration for the relative size and importance of tests. The test pyramid shows that the bulk of tests are often unit tests, with a smaller number of integration tests:&lt;/p&gt;

&lt;figure class=&quot;full&quot; vocab=&quot;http://schema.org/&quot; typeof=&quot;ImageObject&quot;&gt;
  &lt;img src=&quot;https://assets.tutorialworks.com/images/test-pyramid.webp&quot; width=&quot;1701&quot; height=&quot;1025&quot; loading=&quot;lazy&quot; property=&quot;contentUrl&quot; alt=&quot;The test pyramid&quot; /&gt;&lt;figcaption&gt;
      &lt;p&gt;The test pyramid, showing the scope and speed of tests&lt;/p&gt;

      
    &lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;Vladimir Khorikov, in his book &lt;a href=&quot;https://www.manning.com/books/unit-testing&quot;&gt;Unit Testing Principles, Practices, and Patterns&lt;/a&gt;, says:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Check as many of the business scenario’s edge cases as possible with unit tests; use integration tests to cover one happy path, as well as any edge cases that can’t be covered by unit tests.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;closing-the-loop&quot;&gt;Closing the loop&lt;/h2&gt;

&lt;p&gt;In software development, testing is essential to ensure the reliability and functionality of code. Unit testing focuses on testing individual units of code in isolation, using specific test data to validate their correctness. On the other hand, integration testing examines how different parts of the code interact with each other, using realistic production-like data to identify compatibility and integration issues.&lt;/p&gt;

&lt;p&gt;Both types of testing are crucial, and a balanced combination of unit and integration tests will help you build great, reliable software.&lt;/p&gt;

</description>
        <pubDate>Sun, 09 Jul 2023 17:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/unit-vs-integration-testing/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/unit-vs-integration-testing/</guid>
        
        <category>Testing</category>
        
        
        <category>software-development</category>
        
      </item>
    
      <item>
        <title>7 power features of the Linux shell you really need to know</title>
        <description>&lt;p&gt;The Linux shell is a powerful tool with many features that aren’t immediately obvious to the beginner. In this article, we’ll see some of the hidden power features of the Linux shell which will make your Linux shell experience a whole lot easier. From simple shortcuts to more advanced features, try one of these tricks today.&lt;/p&gt;

&lt;figure class=&quot;full&quot; vocab=&quot;http://schema.org/&quot; typeof=&quot;ImageObject&quot;&gt;
  &lt;img src=&quot;https://assets.tutorialworks.com/images/penguin-plumber.jpg&quot; width=&quot;1200&quot; height=&quot;675&quot; loading=&quot;lazy&quot; property=&quot;contentUrl&quot; alt=&quot;A penguin plumber with some plumbing tools&quot; /&gt;&lt;/figure&gt;

&lt;p&gt;So, I use the Linux shell a lot. I use it for my day job, and I also use it for my personal projects. I use it to do a lot of the legwork for this blog.&lt;/p&gt;

&lt;p&gt;I’ve been working with Linux for several years and picked up some useful tips. There are some Linux features which I didn’t know about &lt;strong&gt;for years&lt;/strong&gt;, but now I use them &lt;strong&gt;all the time&lt;/strong&gt;. And there’s still a ton of stuff that I don’t know!&lt;/p&gt;

&lt;p&gt;In this post, I want to share some power features which I think are so useful, you’ll want to start using them every day. I’ll also share the proper names of these features, so if you want to know more, you know what to look for in the manual.&lt;/p&gt;

&lt;p&gt;And, as a bonus, you’ll sound like you know what you’re talking about at work :-)&lt;/p&gt;

&lt;p class=&quot;tip&quot;&gt;These commands work on the Bash or “GNU Bourne-Again SHell” which is the default shell on most Linux distributions. If you’re using a different shell, you might need to use a slightly different command.&lt;/p&gt;

&lt;p&gt;Without further ado, let’s get into the seven power features of the Linux shell.&lt;/p&gt;

&lt;h2 id=&quot;1-save-output-from-a-command-to-a-file&quot;&gt;1. Save output from a command to a file&lt;/h2&gt;

&lt;p&gt;A lot of features in the Linux shell are activated simply by using a special character. So to be a pro, you just need to remember some characters. ;-)&lt;/p&gt;

&lt;p&gt;Our first special character in Linux is the humble “greater-than” sign: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt;. With this character, you can save the output of a command to a file.&lt;/p&gt;

&lt;p&gt;For example, here’s how to use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt; operator to redirect the output of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt; command, to a file called “hello.txt”:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, world!&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; hello.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will create a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello.txt&lt;/code&gt; and write the text &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello, world!&lt;/code&gt; to it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is really useful when you want to share a command’s output with someone. No more do you need to suffer the embarrassment of pulling out your phone and taking a picture of your heavily-stained screen. 🤦‍♂️ Simply use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt; operator and send them the file! Voila!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here’s how to use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt; it with another command; let’s use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&lt;/code&gt; operator to save the output of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; command to a file:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; files.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you have a file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;files.txt&lt;/code&gt; that contains a list of the files in the current directory.&lt;/p&gt;

&lt;h3 id=&quot;double-up-to-append-to-a-file-&quot;&gt;Double up to append to a file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;You can also use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&amp;gt;&lt;/code&gt; operator to &lt;strong&gt;append&lt;/strong&gt; to a file. This means that if the file already exists, the output will be &lt;strong&gt;added to the end of the file&lt;/strong&gt;. If the file doesn’t exist, it will be created.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, world!&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; hello.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will append the text &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello, world!&lt;/code&gt; to the end of the file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;run-a-command-and-see-its-output-while-saving-it-with-tee&quot;&gt;Run a command and see its output while saving it with ‘tee’&lt;/h3&gt;

&lt;p&gt;But what if you want to save the output from a command &lt;strong&gt;and also see it on the screen?&lt;/strong&gt; No problem. Just use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tee&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;Let’s say you want to see the output of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; command, but you also want to save the output to a file. You can do this by using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tee&lt;/code&gt; 🫖 command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;tee &lt;/span&gt;files.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;It’s called “tee” because in plumbing, a “tee” connects two pipes together!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;🔵 &lt;strong&gt;PROPER NAME IN LINUX: Redirection.&lt;/strong&gt; To learn more, type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man sh&lt;/code&gt;, press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; and search for “redirection”.&lt;/p&gt;

&lt;h2 id=&quot;2-run-commands-in-the-background&quot;&gt;2. Run commands in the background&lt;/h2&gt;

&lt;p&gt;Ever wanted to run a command, but keep using the command line at the same time, and without having to open a new terminal? You can do that with another special character, the ampersand: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;&lt;/code&gt; character, you can run a command in the background in a &lt;i&gt;subshell&lt;/i&gt;. When you put a command into the background, you can get on with other stuff while the command is doing its thing.&lt;/p&gt;

&lt;p class=&quot;note&quot;&gt;A subshell is a copy of your current shell that runs your background command. You can think of it as a mini-shell that runs your background command and then terminates.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sleep &lt;/span&gt;1000 &amp;amp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This example will run the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sleep&lt;/code&gt; command in the background for 1,000 seconds, and then exit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not sure if your command is still running?&lt;/strong&gt; You can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jobs&lt;/code&gt; command to see what’s running in the background:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;jobs&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;1]+  Running                 &lt;span class=&quot;nb&quot;&gt;sleep &lt;/span&gt;1000 &amp;amp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;bring-a-job-to-the-foreground-and-then-to-the-background-again&quot;&gt;Bring a job to the foreground and then to the background again&lt;/h3&gt;

&lt;p&gt;What if you want to bring a background job into the foreground – so you can see what it’s doing – and then put it back into the background? No problem, this is pretty common! Here’s how it’s done:&lt;/p&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Run the program:&lt;/strong&gt; Run your program, adding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;&lt;/code&gt; to run it in the background.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Bring it to the foreground:&lt;/strong&gt; Type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fg&lt;/code&gt;, to bring the job back into the foreground. When the job is in the foreground, you’ll see its output in your terminal.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Suspend the program:&lt;/strong&gt; Now you can can press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl+Z&lt;/code&gt; to &lt;strong&gt;suspend&lt;/strong&gt; the command. (During this time, the command isn’t really running, it’s paused. ⏸️)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Background the program:&lt;/strong&gt; Finally, type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bg&lt;/code&gt; to put the job back into the background.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s what it looks like:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# start sleep in the background&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sleep &lt;/span&gt;1000 &amp;amp;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;1] 12345

&lt;span class=&quot;c&quot;&gt;# bring it to the foreground&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;fg
sleep &lt;/span&gt;1000

&lt;span class=&quot;c&quot;&gt;# sleep is now running in the foreground, press Ctrl+Z to suspend it&lt;/span&gt;

^Z
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;1]+  Stopped                 &lt;span class=&quot;nb&quot;&gt;sleep &lt;/span&gt;1000
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# sleep is now suspended, type bg to put it back into the background&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;bg&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;1]+ &lt;span class=&quot;nb&quot;&gt;sleep &lt;/span&gt;1000 &amp;amp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;🔵 &lt;strong&gt;PROPER NAME IN LINUX: Asynchronous commands or background jobs.&lt;/strong&gt; To learn more, type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man sh&lt;/code&gt;, press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; and search for “job control”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handy for:&lt;/strong&gt; Running more than one command at a time. Especially useful if you’re connected to a remote server via SSH and you only have one connection.&lt;/p&gt;

&lt;figure class=&quot;full&quot; vocab=&quot;http://schema.org/&quot; typeof=&quot;ImageObject&quot;&gt;
  &lt;img src=&quot;https://assets.tutorialworks.com/images/penguin-power-tools.jpg&quot; width=&quot;1200&quot; height=&quot;675&quot; loading=&quot;lazy&quot; property=&quot;contentUrl&quot; alt=&quot;A penguin using some power tools in a workshop&quot; /&gt;&lt;/figure&gt;

&lt;h2 id=&quot;3-use-wildcard-patterns-to-refer-to-groups-of-files&quot;&gt;3. Use wildcard patterns to refer to groups of files&lt;/h2&gt;

&lt;p&gt;You don’t always have to type filenames. There is a handy shortcut!&lt;/p&gt;

&lt;p&gt;The shell will automatically expand filenames or lists of files when you use a feature called pattern matching.&lt;/p&gt;

&lt;p&gt;Pattern matching lets you find a file or group of files by some pattern in their filename. You can use pattern matching in most of your Linux commands, including &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rm&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cp&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mv&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grep&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;find&lt;/code&gt;. It’s really helpful because it means you don’t need to type exact filenames all the time!&lt;/p&gt;

&lt;p&gt;This feature is really useful when you want to do something to a group of files; like delete them, or move them to a different directory. And don’t we all want to save typing? (Yes, we do.)&lt;/p&gt;

&lt;p&gt;To use this feature, just remember the wildcard characters. Here are the most common wildcards:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt; matches zero or more characters. (I use this a lot!)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?&lt;/code&gt; matches exactly one character&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[abc]&lt;/code&gt; matches any one of the characters &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;c&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[a-z]&lt;/code&gt; matches any character between &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;z&lt;/code&gt; (useful for matching all letters of the alphabet!)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, you can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt; wildcard to match any number of characters:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will print the names of &lt;strong&gt;all&lt;/strong&gt; files that end with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.txt&lt;/code&gt; to the screen.&lt;/p&gt;

&lt;p&gt;Here’s another example. Let’s print the contents of all files which have four characters in their name and end in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.conf&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /etc/????.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p class=&quot;tip&quot;&gt;If you ever want to preview what an expansion will look like after it’s been expanded, use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo&lt;/code&gt; command! For example:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo cat /etc/????.conf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;🔵 &lt;strong&gt;PROPER NAME IN LINUX: Pathname expansion, pattern matching, “globbing”.&lt;/strong&gt; To learn more, type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man sh&lt;/code&gt;, press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; and search for “pathname expansion”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it’s helpful for:&lt;/strong&gt; Doing something to many files at once; like deleting them, or moving them to a different directory.&lt;/p&gt;

&lt;h2 id=&quot;4-pipe-output-from-one-command-into-another&quot;&gt;4. Pipe output from one command into another&lt;/h2&gt;

&lt;p&gt;Working in the Linux shell is often about running small commands which do one thing, and then taking the output of that command and passing it as the input to another command.&lt;/p&gt;

&lt;p&gt;The pipe operator &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;|&lt;/code&gt; is another special character! It lets you take the output from a command and use it as the input to another command. It’s probably &lt;strong&gt;the most useful&lt;/strong&gt; operator on the Linux command line and I use it every single day.&lt;/p&gt;

&lt;p&gt;For example, we can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; command to list the files in a directory, and then pipe the output to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grep&lt;/code&gt; command to search. Here’s an example:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; /etc | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;cron
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This example will list the contents of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc&lt;/code&gt; directory and then search the output for any files that contain the word &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cron&lt;/code&gt; in the filename.&lt;/p&gt;

&lt;p&gt;Here are some other examples of using the pipe to combine commands:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Print your command history and search the list for the text &apos;ls&apos;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;history&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;grep ls&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Print all running processes and search the list for the text &apos;java&apos;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ps aux | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;java

&lt;span class=&quot;c&quot;&gt;# Print the contents of a file and convert double spaces to tabs&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /var/myfile | &lt;span class=&quot;nb&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;  &apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;\t&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;🔵 &lt;strong&gt;PROPER NAME IN LINUX: Pipelines.&lt;/strong&gt; To learn more, type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man sh&lt;/code&gt;, press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; and search for “pipelines”.&lt;/p&gt;

&lt;h2 id=&quot;5-autocomplete-everything&quot;&gt;5. Autocomplete everything&lt;/h2&gt;

&lt;p&gt;Autocomplete is one of the most useful features of the Linux command line. It’s so useful that I can’t imagine using the command line without it.&lt;/p&gt;

&lt;p&gt;Autocomplete is a feature that lets you type the first few letters of a command or filename, and then press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Tab&lt;/code&gt; to complete the rest of the word. It’s really useful when you’re typing long filenames or commands.&lt;/p&gt;

&lt;p&gt;To start using it, just type a command or a filename.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;systemd-
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Tab&lt;/code&gt; to get a list of possible completions:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;systemd-
systemd-analyze
systemd-ask-password
systemd-cat
systemd-cgls
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It’s like the autocomplete feature on your iPhone… except it actually suggests useful stuff.&lt;/p&gt;

&lt;div class=&quot;secondary&quot;&gt;
  &lt;h3 id=&quot;some-commands-have-their-own-autocomplete-too&quot;&gt;Some commands have their own autocomplete, too&lt;/h3&gt;

  &lt;p&gt;You can also use autocomplete with some commands!&lt;/p&gt;

  &lt;p&gt;Yes, many commands have their own autocomplete, too. For example, if you type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls --&lt;/code&gt; and then press the tab key, the command line will show all of the possible options you can use.&lt;/p&gt;

  &lt;p&gt;And more complex commands, like &lt;strong&gt;kubectl&lt;/strong&gt; (for Kubernetes), have their own autocomplete too. (Check the documentation for the tool you’re using to see if you need to install its completion feature.)&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;🔵 &lt;strong&gt;PROPER NAME IN LINUX: Completion, programmable completion.&lt;/strong&gt; To learn more, type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man bash&lt;/code&gt;, press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; and search for “completion” or “READLINE”.&lt;/p&gt;

&lt;h2 id=&quot;6-change-text-in-the-command-line&quot;&gt;6. Change text in the command line&lt;/h2&gt;

&lt;p&gt;How often have you typed a command and realised you’ve got the first part wrong – and needed to go backspace all the way to change it? Or have you ever used a Linux shell and wished you could copy and paste bits of your command?&lt;/p&gt;

&lt;p&gt;Well I think this trick is the most hidden of them all. The Linux shell has special key combinations that you can use to cut, copy and paste text in the command line - without needing a mouse:&lt;/p&gt;

&lt;h4 id=&quot;move-around-the-command-line&quot;&gt;Move around the command line&lt;/h4&gt;

&lt;p&gt;You probably know that you can use the arrow keys (Left and Right) to move the cursor around the command line.&lt;/p&gt;

&lt;p&gt;But did you know that you can also use these keys too:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl+A&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl+E&lt;/code&gt; keys move to the beginning or end of the line.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Alt+B&lt;/code&gt; moves the cursor back one word&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Alt+F&lt;/code&gt; moves the cursor forward one word&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;cut-and-edit-parts-of-your-command&quot;&gt;Cut and edit parts of your command&lt;/h4&gt;

&lt;p&gt;These key combinations will save you a ton of typing. Use these key combos to edit your typing at the command line:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl-K&lt;/code&gt; will delete everything from the cursor to the end of the line (kind of like deleting forwards)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl-U&lt;/code&gt; will delete everything from the cursor to the start of the line (kind of like deleting backwards)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl-W&lt;/code&gt; will delete the word before the cursor.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl-Y&lt;/code&gt; will paste the last thing you deleted. This is called “yanking” 😳&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🔵 &lt;strong&gt;PROPER NAME IN LINUX: Killing, yanking (and other weird names).&lt;/strong&gt; These are features of the “READLINE” part of the shell. To learn more, type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man bash&lt;/code&gt;, press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt; and search for “READLINE”.&lt;/p&gt;

&lt;h2 id=&quot;7-go-back-in-history&quot;&gt;7. Go back in history&lt;/h2&gt;

&lt;p&gt;When you need to repeat yourself, or run the same command again, you can use the &lt;strong&gt;up and down arrow keys&lt;/strong&gt; to scroll through your command history.&lt;/p&gt;

&lt;p&gt;But it gets better. You can also see your command history in the Linux command line. Use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;history&lt;/code&gt; command to list the commands that you have run recently:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;history&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Written a long, complicated command and want to run it again? Find the command you want to re-run, and use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;!&lt;/code&gt; operator &lt;strong&gt;+&lt;/strong&gt; its number, to run the command again:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;123
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will re-run the command that was run in history position 123.&lt;/p&gt;

&lt;p&gt;And, most useful of all, you can search for commands in your history too. pressing &lt;kbd&gt;Ctrl-R&lt;/kbd&gt; will let you search through your history using a text interface. Then just press &lt;kbd&gt;Enter&lt;/kbd&gt; to run the command again.&lt;/p&gt;

&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;

&lt;p&gt;Now you’ve seen a whole bunch of features you probably didn’t even know existed in the Linux command line. Now you’ll be chomping at the bit to get started!&lt;/p&gt;

&lt;p&gt;But before you do, there’s one more thing you need to remember…&lt;/p&gt;

&lt;p&gt;You can find out more about any command you’re using by using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man&lt;/code&gt; command. For example, to find out more about the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; command, type:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;man ls
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I hope you use these hidden features of the Linux shell to make your Linux life easier, and to get things done faster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Linuxing!&lt;/strong&gt;&lt;/p&gt;

</description>
        <pubDate>Sat, 29 Oct 2022 08:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/linux-shell-power-features/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/linux-shell-power-features/</guid>
        
        <category>Linux</category>
        
        
        <category>linux</category>
        
      </item>
    
      <item>
        <title>Maven POM template - an example</title>
        <description>&lt;p&gt;When you’re kickstarting a new Java project, you might find yourself getting stuck at the first hurdle. How do you set up your brand new project with Maven?&lt;/p&gt;

&lt;p&gt;If you’re using &lt;a target=&quot;_blank&quot; href=&quot;https://maven.apache.org&quot;&gt;Maven&lt;/a&gt; to build your project (and many teams use it, so you’re in good company!), you’ll find that you need to create something called a &lt;strong&gt;pom file&lt;/strong&gt;. What’s a pom file? It’s an XML file – usually called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pom.xml&lt;/code&gt; – where you tell Maven all about your project, and declare all of your dependencies.&lt;/p&gt;

&lt;p&gt;You’re probably thinking, what does a pom file look like? And is there a basic beginner pom file that you can use?&lt;/p&gt;

&lt;p&gt;Fortunately, most &lt;a href=&quot;/java-ide/&quot;&gt;IDEs&lt;/a&gt; can create your pom file for you. Just create a new Java project and follow the wizard steps. But, if you’re doing this on your own, don’t worry! You don’t need to write one from scratch. We’ve prepared an example pom file for you.&lt;/p&gt;

&lt;h2 id=&quot;maven-pomxml-template&quot;&gt;Maven pom.xml template&lt;/h2&gt;

&lt;p&gt;Here’s an example pom.xml that you can use to kickstart your next project:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://maven.apache.org/POM/4.0.0&quot;&lt;/span&gt; 
        &lt;span class=&quot;na&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;modelVersion&amp;gt;&lt;/span&gt;4.0.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/modelVersion&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;com.example&lt;span class=&quot;nt&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;your-project-name&lt;span class=&quot;nt&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;packaging&amp;gt;&lt;/span&gt;jar&lt;span class=&quot;nt&quot;&gt;&amp;lt;/packaging&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;1.0-SNAPSHOT&lt;span class=&quot;nt&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;name&amp;gt;&lt;/span&gt;your-project-name&lt;span class=&quot;nt&quot;&gt;&amp;lt;/name&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;properties&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;maven.compiler.source&amp;gt;&lt;/span&gt;1.7&lt;span class=&quot;nt&quot;&gt;&amp;lt;/maven.compiler.source&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;maven.compiler.target&amp;gt;&lt;/span&gt;1.7&lt;span class=&quot;nt&quot;&gt;&amp;lt;/maven.compiler.target&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;project.build.sourceEncoding&amp;gt;&lt;/span&gt;UTF-8&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project.build.sourceEncoding&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/properties&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;dependencies&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Your dependencies go here, like this! --&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;c&quot;&gt;&amp;lt;!--
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;junit&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;junit&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;3.8.1&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/dependencies&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nt&quot;&gt;&amp;lt;build&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;plugins&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Your plugins go here! --&amp;gt;&lt;/span&gt;

        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/plugins&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/build&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can add this into your project’s folder as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pom.xml&lt;/code&gt;. Don’t forget to:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Add the dependencies that you need in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dependencies&lt;/code&gt; section&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Add any plugins you need in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plugins&lt;/code&gt; section&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Start adding your source code into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/main/java&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;alternative-ways-to-bootstrap-a-maven-project&quot;&gt;Alternative ways to bootstrap a Maven project&lt;/h2&gt;

&lt;p&gt;Are there any other ways to generate this pom file? Yes, many! Here are some of the ways:&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Using your IDE&lt;/strong&gt;. Most Java IDEs like IntelliJ or Eclipse include wizards or templates which can generate your pom file for you.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Spring&lt;/strong&gt; has an online wizard called the &lt;a target=&quot;_blank&quot; href=&quot;https://start.spring.io&quot;&gt;Spring Initializr&lt;/a&gt;, which bootstraps a new Spring or Spring Boot project, and includes a ready-made pom file. Of course, this is mostly useful if you’re using the Spring framework.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Quarkus&lt;/strong&gt; also has an online wizard at &lt;a target=&quot;_blank&quot; href=&quot;https://code.quarkus.io&quot;&gt;code.quarkus.io&lt;/a&gt; to bootstrap a new project. Again, only applies if you’re using &lt;a href=&quot;/java-frameworks/&quot;&gt;Quarkus&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;From the command line,&lt;/strong&gt; Maven’s own &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mvn archetype:generate&lt;/code&gt; command will create a new project for you from an archetype (template).&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But for now, I hope you found this example pom.xml useful!&lt;/p&gt;

</description>
        <pubDate>Wed, 05 Oct 2022 08:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/maven-pom-template/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/maven-pom-template/</guid>
        
        <category>Java</category>
        
        
        <category>java</category>
        
      </item>
    
      <item>
        <title>Secure your Linux services with this guide to systemd&apos;s little-known security options</title>
        <description>&lt;p&gt;Systemd doesn’t just start and stop services… it can do a whole bunch of other stuff too. The problem is, most of us don’t know about it!
But fortunately there’s a cheatsheet and command to help you.
So if you’re creating a systemd service, consider using this handy guide to add some much-needed security to your services.&lt;/p&gt;

&lt;h3 id=&quot;why-systemd-is-a-power-tool&quot;&gt;Why systemd is a “power tool”&lt;/h3&gt;

&lt;p&gt;So what exactly is systemd? Systemd is basically a controller, at the heart of your modern Linux system, which starts and manages services in your userspace. (&lt;i&gt;Userspace&lt;/i&gt; is the technical term for the area of a Linux-based operating system where you run programs; in other words, userspace is the bit that’s not the Linux kernel.)&lt;/p&gt;

&lt;!-- But systemd doesn&apos;t **only** start and stop services. It can do a lot more stuff. It can run programs on a timer, manage mount points on the file system, collect and store logging data (with _journald_) and lots more. --&gt;

&lt;p&gt;Systemd lets you configure your services in infinite ways. You can run services on a schedule, configure an action to take when a service fails, configure a service to automatically start its &lt;em&gt;dependent&lt;/em&gt; services, and more. You could probably spend your whole career studying systemd. (And it’d be a fine career choice, to be honest.) But most of us want to get the most out of these tools &lt;strong&gt;without&lt;/strong&gt; studying them for years.&lt;/p&gt;

&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://news.ycombinator.com/item?id=32888538&quot;&gt;Source: Hacker News&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;instantly-see-how-secure-your-services-are&quot;&gt;Instantly see how secure your services are&lt;/h3&gt;

&lt;p&gt;Systemd usually runs as the first process on boot (PID 1), which means that it has an awful lot of power over your Linux environment. “With great power, comes great responsibility,” they say. So for something with that amount of power, it’s helpful to have some checks and balances.&lt;/p&gt;

&lt;p&gt;Systemd comes with a command line tool called &lt;i&gt;systemd-analyze security&lt;/i&gt; which shows you instantly whether your services are using its security options. It gives each service an “exposure” score. I ran &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemd-analyze security&lt;/code&gt; on my Linux workstation, and I got these results:&lt;/p&gt;

&lt;figure class=&quot;full&quot; vocab=&quot;http://schema.org/&quot; typeof=&quot;ImageObject&quot;&gt;
  &lt;img src=&quot;https://assets.tutorialworks.com/images/systemd-analyze-security.png&quot; width=&quot;1184&quot; height=&quot;844&quot; loading=&quot;lazy&quot; property=&quot;contentUrl&quot; alt=&quot;Systemd Analyze Security results&quot; /&gt;&lt;/figure&gt;

&lt;p&gt;These results are not exactly encouraging for my Linux skills! But I’m running a Linux personal desktop; you might be aiming for different results if you’re running a database server in production. 😉&lt;/p&gt;

&lt;h3 id=&quot;try-this-cheatsheet-to-create-more-secure-services&quot;&gt;Try this cheatsheet to create more secure services&lt;/h3&gt;

&lt;p&gt;So once you’ve analyzed your services, you might want to add some security settings to them. Perhaps you want to &lt;i&gt;sandbox&lt;/i&gt; your services, or prevent them from acquiring additional permissions. To do this you need to know the settings you need to add to your unit files.&lt;/p&gt;

&lt;p&gt;These settings are all documented in &lt;a target=&quot;_blank&quot; href=&quot;https://www.freedesktop.org/software/systemd/man/systemd.unit.html&quot;&gt;the official documentation&lt;/a&gt; but is there an example? Yes! GitHub user Kevin Gallagher (ageis) did the hard work and created this awesome cheatsheet which shows some default systemd unit security settings and includes the relevant sections of the systemd docs, so you can find out more about them. Sharing here because I think it’s great:&lt;/p&gt;

&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://gist.github.com/ageis/f5595e59b1cddb1513d1b425a323db04&quot; class=&quot;button btn btn--info btn--large&quot;&gt;Get the cheatsheet&lt;/a&gt; on GitHub Gist&lt;/p&gt;

&lt;p&gt;Now you’ll be on your way to sandboxing your services, limiting their access to the file system, hiding access to the bits of the system that they don’t need, and so on.&lt;/p&gt;

&lt;h3 id=&quot;read-more-about-systemd&quot;&gt;Read more about systemd&lt;/h3&gt;

&lt;p&gt;If you want to get more help you can always check out the manual pages by typing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man&lt;/code&gt;. The manual pages are really detailed and accurate.&lt;/p&gt;

&lt;p&gt;Personally, I like to peruse the man pages – &lt;em&gt;of a Sunday morning&lt;/em&gt; – whilst wearing a monocle and a tweed jacket. 🧐  If you want to do the same, you can read an introduction to systemd with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;man 1 systemd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Or, see all of the options you can use in a &lt;i&gt;unit file&lt;/i&gt; with:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;man 5 systemd.unit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As always, you can list all of the systemd manual pages using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man -k systemd&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy service-writing!&lt;/strong&gt;&lt;/p&gt;

&lt;!--
- What is systemd?
- Systemd is very complex
  - It does a lot of different jobs
  - (Much to the annoyance of some people but the delight of others)
  - And it has tons of config options which I&apos;m certainly still learning about.
- GitHub user Kevin Gallagher (ageis) has created this handy reference to hardening
- The Gist.
  - big blue button to link to the Gist
  - Screenshot
- Top takeaway
- Why this is useful
- How to get more help in the manual pages (man 5 systemd)
--&gt;

</description>
        <pubDate>Fri, 23 Sep 2022 08:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/systemd-service-hardening/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/systemd-service-hardening/</guid>
        
        <category>Linux</category>
        
        
        <category>linux</category>
        
      </item>
    
      <item>
        <title>Six helpful dnf/yum commands to manage software on Red Hat</title>
        <description>&lt;p&gt;In Red Hat Enterprise Linux and its related distributions (like Fedora and Rocky Linux), YUM and DNF are used to install, manage and remove software. These distros use packages in the RPM format (unlike Ubuntu/Debian which use &lt;strong&gt;apt&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;So in RHEL or Fedora, this means you’ll often be using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yum&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf&lt;/code&gt; commands to install and manage software on your system.&lt;/p&gt;

&lt;div class=&quot;secondary&quot;&gt;
  &lt;h3 id=&quot;yum-is-the-same-as-dnf&quot;&gt;yum is the same as dnf!&lt;/h3&gt;

  &lt;p&gt;In recent versions of Linux, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yum&lt;/code&gt; is the same as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf&lt;/code&gt;! In fact, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yum&lt;/code&gt; command is just a &lt;i&gt;symbolic link&lt;/i&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf&lt;/code&gt;.&lt;/p&gt;

  &lt;p&gt;I can check this on my Fedora 36 system. This example output shows that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/bin/yum&lt;/code&gt; is just a link to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf-3&lt;/code&gt; command:&lt;/p&gt;

  &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ls -la /usr/bin/yum 
lrwxrwxrwx. 1 root root 5 Sep  9 14:49 /usr/bin/yum -&amp;gt; dnf-3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Now let’s look at six &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf&lt;/code&gt; (or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yum&lt;/code&gt;!) commands which you can use to install and manage software on Fedora or Red Hat Enterprise Linux.&lt;/p&gt;

&lt;h2 id=&quot;search-for-a-package&quot;&gt;Search for a package&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Most of the time, when you want to install some software on Linux, the best place to look is the default repositories.&lt;/strong&gt; Software in your distro’s repositories is usually tailored for your Linux distribution; it installs files in the right places, creates a system service and so on.&lt;/p&gt;

&lt;p&gt;On Fedora, you’ll usually have the &lt;em&gt;fedora&lt;/em&gt; and &lt;em&gt;updates&lt;/em&gt; repositories enabled by default, which both contain lots of packages.&lt;/p&gt;

&lt;p&gt;RHEL is an “enterprise” Linux distribution, has far fewer packages in its default repositories, and those are often a little more behind the “cutting-edge”, but they are generally stable and safe to install.&lt;/p&gt;

&lt;p&gt;You can search for software in the default repositories using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf search&lt;/code&gt;, for example:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dnf search nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will search for packages containing the string &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nginx&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;install-a-package-from-a-repository&quot;&gt;Install a package from a repository&lt;/h2&gt;

&lt;p&gt;When you’ve browsed the search results and decided which package you want to install, you can use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf install&lt;/code&gt; command. This will look in repositories for a package with the exact name, and install it.&lt;/p&gt;

&lt;p&gt;For example, to install nginx:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dnf install nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p class=&quot;tip&quot;&gt;Don’t forget you’ll need superuser privileges to install software, so add “sudo” to the front of the command.&lt;/p&gt;

&lt;h2 id=&quot;install-a-local-rpm-file&quot;&gt;Install a local rpm file&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Some software isn’t distributed in repositories, but is distributed as a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.rpm&lt;/code&gt; file instead.&lt;/strong&gt; You can sometimes encounter this if you’re installing some commercial, closed-source software. Or, some open source projects might provide a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.rpm&lt;/code&gt; file on their download or GitHub Releases page.&lt;/p&gt;

&lt;p&gt;Whichever way you acquire a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.rpm&lt;/code&gt; file, you can install it with rpm using the same &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;install&lt;/code&gt; command:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dnf install your-rpm-file.rpm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can also install an RPM file directly from a URL!:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dnf install http://github.com/example/example-app/releases/myapp.rpm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;list-all-installed-packages&quot;&gt;List all installed packages&lt;/h2&gt;

&lt;p&gt;Another common task is to find out all of the packages which are installed on your system, and their versions. This allows you you see all of the software applications which you have installed.&lt;/p&gt;

&lt;p&gt;Why might you want to know this?&lt;/p&gt;

&lt;p&gt;Sometimes you might want to check if a system has been configured correctly… or perhaps you’re wondering why a particular command is missing?&lt;/p&gt;

&lt;p&gt;Here’s the command you need to show all installed packages:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dnf list --installed
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The output from this command will show you the package name, the version, and which repository it was installed from (e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@fedora&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@updates&lt;/code&gt;, etc.)&lt;/p&gt;

&lt;p&gt;Packages which have been installed from a &lt;em&gt;file&lt;/em&gt; are usually shown as coming from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@System&lt;/code&gt; repository.&lt;/p&gt;

&lt;div class=&quot;secondary&quot;&gt;
  &lt;h3 id=&quot;search-for-a-specific-installed-package&quot;&gt;Search for a specific installed package&lt;/h3&gt;

  &lt;p&gt;Searching for a specific installed package? Well, for extra points, you can also pipe this command into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grep&lt;/code&gt;, which will let you search for all installed packages which match a string.&lt;/p&gt;

  &lt;p&gt;For example, if I want to see all the &lt;em&gt;podman&lt;/em&gt; packages on my system:&lt;/p&gt;

  &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[tdonohue@fedora ~]$ dnf list --installed | grep podman
podman.x86_64                                        4:4.2.0-2.fc36                      @updates                             
podman-compose.noarch                                1.0.3-6.fc36                        @updates                             
podman-gvproxy.x86_64                                4:4.2.0-2.fc36                      @updates                             
podman-plugins.x86_64                                4:4.2.0-2.fc36                      @updates             
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/div&gt;

  &lt;p&gt;Zingggg! ✨&lt;/p&gt;
&lt;/div&gt;

&lt;h2 id=&quot;which-files-are-included-in-a-package&quot;&gt;Which files are included in a package?&lt;/h2&gt;

&lt;p&gt;Before you install a package, you can find out what’s contained inside it. The &lt;em&gt;massively useful&lt;/em&gt; thing about packages is that they install files to &lt;strong&gt;a specific location&lt;/strong&gt;. So you can see, upfront, exactly what will be installed, &lt;strong&gt;and where&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So, to find out which files and paths are included in a package:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dnf repoquery -l nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The output from this command shows you all of the files in a package, and their paths.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where does everything go?&lt;/strong&gt; You’ll often see that application binaries will be installed into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/bin&lt;/code&gt;, the manpages will be added into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/share/man&lt;/code&gt; and the program’s config files will go into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;which-packages-provide-a-command&quot;&gt;Which packages provide a command?&lt;/h2&gt;

&lt;p&gt;If you know you need a command, but you’re not sure which package provides that command, then you can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf provides&lt;/code&gt; to query the repositories.&lt;/p&gt;

&lt;p&gt;For example, when I wanted to install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kubectl&lt;/code&gt; (for working with Kubernetes), I wasn’t sure which package I needed to install. So I searched like this:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dnf provides /usr/bin/kubectl
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;… and the result told me that the package which contains &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kubectl&lt;/code&gt; is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kubernetes-client&lt;/code&gt; (which is in the Fedora repositories, but might not be in the RHEL repositories).&lt;/p&gt;

&lt;p&gt;If you’re not exactly sure of the path to the command, you can search with a wildcard:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dnf provides &quot;*/bin/top&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;

&lt;p&gt;There are tons more commands you can use to manage packages on your Linux system, but these ones are very handy to know! To find out more, type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man dnf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Useful links:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://docs.rockylinux.org/books/admin_guide/13-softwares/&quot;&gt;Rocky Linux - Software management&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/managing_software_with_the_dnf_tool/con_software-management-tools-in-red-hat-enterprise-linux-9_managing-software-with-the-dnf-tool&quot;&gt;RHEL 9 Documentation - Software management tools in RHEL 9&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Wed, 21 Sep 2022 08:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/dnf-useful-commands/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/dnf-useful-commands/</guid>
        
        <category>Linux</category>
        
        
        <category>linux</category>
        
      </item>
    
      <item>
        <title>5 ways to learn Linux to advance your career</title>
        <description>&lt;p&gt;Want to learn Linux to grow your career? Here are some tips if you’re planning to learn &lt;a href=&quot;/what-is-linux/&quot;&gt;Linux&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;tips-for-learning-linux&quot;&gt;Tips for learning Linux&lt;/h2&gt;

&lt;div class=&quot;article-list&quot;&gt;

  &lt;h3 id=&quot;read-a-book&quot;&gt;Read a book&lt;/h3&gt;

  &lt;p&gt;&lt;strong&gt;Books are comprehensive.&lt;/strong&gt; Linux is pretty big. Sometimes it can feel like in order to do something, you need to learn about 100 concepts beforehand. Books go into thorough detail and will cover more than any video course.&lt;/p&gt;

  &lt;p&gt;Investing in a Linux book is a great idea, as you’ll probably return to it for years to come.&lt;/p&gt;

  &lt;p&gt;We recommend:&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;&lt;strong&gt;Linux Bible.&lt;/strong&gt;
It’s in its 10th Edition now, so if that’s not a good sign that you should pick it up, I don’t know what is.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;&lt;strong&gt;How Linux Works.&lt;/strong&gt;
This is more of a “why” book.
It explains the reasons that Linux works the way that it does.&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ul&gt;

  &lt;h4 id=&quot;does-it-matter-which-distribution&quot;&gt;Does it matter which distribution?&lt;/h4&gt;
  &lt;p&gt;These Linux books are geared towards using Linux for business, not for gaming or home use. So they mostly focus on the big enterprise distributions, Red Hat and Ubuntu.&lt;/p&gt;

  &lt;h3 id=&quot;take-a-course-andor-an-exam&quot;&gt;Take a course and/or an exam&lt;/h3&gt;
  &lt;p&gt;If you want to learn Linux and the command line step-by-step, then take a course and an exam. The good thing about taking a course is that it will cover the core topics you need to know.&lt;/p&gt;

  &lt;p class=&quot;tip&quot;&gt;Try to find a course for system administrators. This will give you a good grounding in Linux commands, managing a server, installing packages, and so on.&lt;/p&gt;

  &lt;p&gt;Here are some ideas for Linux training:&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;Training for the &lt;strong&gt;Red Hat Certified System Administrator (RHCSA)&lt;/strong&gt; certification will give you the knowledge you need to be confident with Red Hat Enterprise Linux.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Online learning platforms like &lt;a target=&quot;_blank&quot; href=&quot;https://acloudguru.com/linux-training&quot;&gt;A Cloud Guru&lt;/a&gt; and &lt;a target=&quot;_blank&quot; href=&quot;https://www.oreilly.com/&quot;&gt;O’Reilly&lt;/a&gt; have self-paced Linux training courses.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;The Linux Foundation offers Linux system administration training and certification. The &lt;a target=&quot;_blank&quot; href=&quot;https://training.linuxfoundation.org/system-administration/&quot;&gt;Linux Foundation Certified System Administrator (LFCS)&lt;/a&gt; is a well-recognised certification.&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ul&gt;

  &lt;h3 id=&quot;play-with-your-own-linux-server&quot;&gt;Play with your own Linux server&lt;/h3&gt;
  &lt;p&gt;You can get started with Linux by creating a Linux virtual machine on your own PC, using a program like &lt;a target=&quot;_blank&quot; href=&quot;https://www.virtualbox.org/&quot;&gt;VirtualBox&lt;/a&gt;. A virtual machine is a safe environment. In a VM, you can play around and learn, without being too concerned, because you won’t break anything.&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;&lt;strong&gt;Run Linux in Docker.&lt;/strong&gt; You could also run Linux in a container.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;&lt;strong&gt;Dual-boot.&lt;/strong&gt; Once you’ve learned some of the basics, you could then choose to dual-boot to Linux. Dual-booting is where you install Linux as a secondary operating system on your PC, and you can choose to boot into it.&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ul&gt;

  &lt;p&gt;&lt;strong&gt;RECOMMENDED:&lt;/strong&gt; See our step-by-step tutorial on &lt;a href=&quot;/linux-vm-vagrant/&quot;&gt;running a web server in a Linux virtual machine with Vagrant&lt;/a&gt;.&lt;/p&gt;

  &lt;h3 id=&quot;get-command-line-experience&quot;&gt;Get command line experience&lt;/h3&gt;
  &lt;p&gt;If you’re learning Linux for DevOps, you should force yourself to use the command line. So, ideally, install a Linux distribution &lt;em&gt;without&lt;/em&gt; a desktop environment.&lt;/p&gt;

  &lt;p&gt;If you don’t install a desktop environment, you’ll only have the shell/terminal as your friend. &lt;strong&gt;But you will make the quickest progress this way.&lt;/strong&gt;&lt;/p&gt;

  &lt;p&gt;When you’re learning the command line, also make time to learn a text editor like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nano&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vim&lt;/code&gt;. Vim is the text editor that comes with most distributions of Linux, with a quirky set of keyboard commands that take time to learn but will help you get things done quicker.&lt;/p&gt;

  &lt;p&gt;&lt;strong&gt;RECOMMENDED:&lt;/strong&gt; See our &lt;a href=&quot;/linux-commands/&quot;&gt;guide to the top Linux commands&lt;/a&gt;.&lt;/p&gt;

  &lt;h4 id=&quot;top-need-to-know-linux-commands&quot;&gt;Top ‘need-to-know’ Linux commands&lt;/h4&gt;
  &lt;p&gt;There are dozens of Linux commands, some of which you’ll use more often than others. Here are some of the top commands that I use almost every day. You will probably use these often if you are going to be using Linux:&lt;/p&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Command&lt;/th&gt;
        &lt;th&gt;What it does&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pwd&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Navigating the file system.&lt;/strong&gt; These commands move between directories (folders), and list their contents.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkdir&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rm&lt;/code&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Create and delete stuff.&lt;/strong&gt; These commands can make a directory or delete files.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vi&lt;/code&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Editing files.&lt;/strong&gt; Vi, or &lt;em&gt;vim&lt;/em&gt;, is the ubiquitous text editor that you’ll find on most Linux systems. It’s extremely powerful but takes time to learn.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;grep&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;find&lt;/code&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Searching files.&lt;/strong&gt; These commands are used to find files on disk and search for text patterns.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yum&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnf&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt&lt;/code&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Installing packages.&lt;/strong&gt; These commands install or upgrade software on the operating system.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ps&lt;/code&gt;, &lt;a href=&quot;/linux-top-command-explained/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;top&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Process monitoring.&lt;/strong&gt; How many programs are running on the server, and how much resources are they using? Useful for troubleshooting.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zip&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unzip&lt;/code&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Working with archive files.&lt;/strong&gt; These commands compress and extract archive files, like &lt;em&gt;zip&lt;/em&gt;, &lt;em&gt;tar&lt;/em&gt; or &lt;em&gt;tgz&lt;/em&gt; (compressed-tar) files.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sed&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;awk&lt;/code&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Text manipulation.&lt;/strong&gt; These commands are often chained together to extract data from files or input, and then used to create input to another command. These are used in DevOps to help write &lt;em&gt;automation&lt;/em&gt; scripts.&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

  &lt;h3 id=&quot;get-help-anytime&quot;&gt;Get help anytime&lt;/h3&gt;
  &lt;p&gt;On your Linux journey, your emergency exit is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man&lt;/code&gt;.&lt;/p&gt;

  &lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man&lt;/code&gt; is the command to show the “manual” and is your best buddy on Linux.&lt;/strong&gt;&lt;/p&gt;

  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man&lt;/code&gt; holds the documentation for almost everything on your Linux system. It tells you how to run commands, how to configure things, and is a goldmine of info.&lt;/p&gt;

  &lt;p&gt;The only problem is, you need to know how to find things in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man&lt;/code&gt;, and how to read man pages. Spend time learning how to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man&lt;/code&gt; first, and it will pay dividends for you in the future.&lt;/p&gt;

  &lt;p class=&quot;tip&quot;&gt;If you’re already on a Linux server, try typing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man ls&lt;/code&gt;, and it will show you the manual for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls&lt;/code&gt; command (which lists files and directories).&lt;/p&gt;

  &lt;p&gt;To search the manual on Linux, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man -k &amp;lt;search term&amp;gt;&lt;/code&gt;. This will find the manual pages which match your search query.&lt;/p&gt;

  &lt;p&gt;Outside of the manual, you can also get help with using Linux on forums and Q&amp;amp;A sites, like:&lt;/p&gt;

  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://www.reddit.com/r/linux4noobs/&quot;&gt;Linux4Noobs subreddit&lt;/a&gt; &lt;span class=&quot;pill beginner&quot;&gt;Beginner&lt;/span&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://unix.stackexchange.com/&quot;&gt;Unix &amp;amp; Linux Stack Exchange&lt;/a&gt; &lt;span class=&quot;pill intermediate&quot;&gt;Intermediate&lt;/span&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ul&gt;

&lt;/div&gt;

</description>
        <pubDate>Mon, 01 Aug 2022 08:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/learn-linux/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/learn-linux/</guid>
        
        <category>Linux</category>
        
        
        <category>linux</category>
        
      </item>
    
      <item>
        <title>XSD vs WSDL: What&apos;s the difference?</title>
        <description>&lt;p&gt;When you’re working with XML web services, you’ll often come across the terms WSDL and XSD. But do you know what they do, and what makes them different from each other? Read on to find out more.&lt;/p&gt;

&lt;h2 id=&quot;what-is-xsd&quot;&gt;What is XSD?&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;XSD, or XML Schema Definition, is a language for describing what an XML document should look like.&lt;/strong&gt; XSD helps a computer system to validate an XML document.&lt;/p&gt;

&lt;p&gt;You can use XSD to define the structure and rules for an XML document. XSD allows you to declare things like:&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;The list of elements which are allowed in an XML document, and a description of each element&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The order of those elements&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;What contents the elements can contain  (e.g. string or date)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Whether elements can contain more (child) elements&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;XSD can be used to validate any XML document – whether it’s received by email, file transfer, or a web service call.&lt;/strong&gt; So it’s often used in backend processes to make sure that data is OK before processing it. If an XML document passes validation, it’s sometimes called &lt;i&gt;schema-valid&lt;/i&gt;.&lt;/p&gt;

&lt;figure class=&quot;&quot; vocab=&quot;http://schema.org/&quot; typeof=&quot;ImageObject&quot;&gt;
  &lt;img src=&quot;https://assets.tutorialworks.com/images/xsd-explainer.png&quot; width=&quot;874&quot; height=&quot;877&quot; loading=&quot;lazy&quot; property=&quot;contentUrl&quot; alt=&quot;Illustration showing process of validating an XML document with XML Schema&quot; /&gt;&lt;figcaption&gt;
      &lt;p&gt;Validating an XML document with XML Schema&lt;/p&gt;

      
        &lt;p class=&quot;credit small&quot;&gt;
          Source: Tutorial Works
        &lt;/p&gt;
      
    &lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;An XML Schema Definition is itself just an XML document&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;, so it looks like a regular XML file. When a document is written in XML Schema Definition language, it’s often saved with the extension &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.xsd&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;XSD is a &lt;a target=&quot;_blank&quot; href=&quot;https://www.w3.org/TR/xmlschema-0/&quot;&gt;standard&lt;/a&gt;, agreed by the W3C. There are other ways to write rules for XML documents (like Document Type Definitions (DTDs), Relax-NG and Schematron) but XSD is probably the most popular way to validate an XML document.&lt;/p&gt;

&lt;h3 id=&quot;what-does-it-look-like&quot;&gt;What does it look like?&lt;/h3&gt;

&lt;p&gt;You begin an XSD document with the root element, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;schema&lt;/code&gt;. You define each tag in the XML document using the tag &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;element&lt;/code&gt;. Each of these elements can contain simple content (which means something like a string or a date), or more complex data (like nested elements).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt; You’re writing an XSD for an XML document to describe a Customer. In the XSD, you might declare that a Customer must have 1 Address, and that each Address must contain a State, but the Zip code is optional:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:schema&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:xsd=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.w3.org/2001/XMLSchema&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:element&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Customer&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;CustomerType&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:complexType&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;CustomerType&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:sequence&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:element&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Name&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;xsd:string&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:element&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Address&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;AddressType&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/xsd:sequence&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/xsd:complexType&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:complexType&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;AddressType&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:sequence&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:element&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Street&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;xsd:string&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:element&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;City&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;xsd:string&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:element&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;State&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;xsd:string&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:element&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;ZipCode&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;xsd:string&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;minOccurs=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsd:element&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Country&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;xsd:string&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/xsd:sequence&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/xsd:complexType&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/xsd:schema&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We have an XML document that we’d like to validate against this XSD:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Customer&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Name&amp;gt;&lt;/span&gt;Bob Carolgees&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Name&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;Address&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Street&amp;gt;&lt;/span&gt;1 Homer Street&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Street&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;City&amp;gt;&lt;/span&gt;Flanville&lt;span class=&quot;nt&quot;&gt;&amp;lt;/City&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;State&amp;gt;&lt;/span&gt;BZ&lt;span class=&quot;nt&quot;&gt;&amp;lt;/State&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Country&amp;gt;&lt;/span&gt;DE&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Country&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/Address&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Customer&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We could now validate this with the &lt;i&gt;xmllint&lt;/i&gt; tool on Linux:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;xmllint --schema customer.xsd bob.xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If you try it yourself, you should see that the message &lt;em&gt;“customer.xml validates”&lt;/em&gt;. Success!&lt;/p&gt;

&lt;h3 id=&quot;what-can-you-do-with-xsd&quot;&gt;What can you do with XSD?&lt;/h3&gt;

&lt;p&gt;So how is XSD used in the real world?&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Write an XSD.&lt;/strong&gt; You can create an XSD document and write rules in it, using a text editor, or specialised software like &lt;a target=&quot;_blank&quot; href=&quot;https://www.altova.com/xmlspy-xml-editor&quot;&gt;XMLSpy&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Validate with a command-line tool.&lt;/strong&gt; You can use a tool like &lt;a target=&quot;_blank&quot; href=&quot;https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html&quot;&gt;xmllint&lt;/a&gt; to validate XML documents using your XML Schema definition.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Validate in your code.&lt;/strong&gt; Most programming languages have libraries to validate XML documents using XSD, so you can add validation to your own applications. For example, in Python you might use the &lt;a target=&quot;_blank&quot; href=&quot;https://pypi.org/project/xmlschema/&quot;&gt;xmlschema&lt;/a&gt; package.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Validation in another app.&lt;/strong&gt; When a software application receives some data in XML format (e.g. from a business partner), it might use XSD to validate the incoming XML document.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Web services.&lt;/strong&gt; If a program exposes an XML web service, it might use an XSD to check that its inbound and outbound messages are valid.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;!-- - When a program receives an XML document -- for example, a file of orders from a business partner, `CustomerOrder2022.xml` -- it might check that the incoming XML document is valid, by validating it against an XSD, `customerorder.xsd`. If the file fails validation (e.g. missing elements, or wrong data types) it might be rejected and returned to the partner. --&gt;

&lt;hr class=&quot;cloud2&quot; /&gt;

&lt;h2 id=&quot;what-is-wsdl&quot;&gt;What is WSDL?&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;WSDL, or Web Services Description Language, is an XML-based language for describing web services.&lt;/strong&gt;&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;WSDL defines a standard set of XML elements, which describe all the features of a web service. You write a WSDL document, using these elements to describe your web service.&lt;/p&gt;

&lt;p&gt;You can use WSDL to describe a web service, so that potential consumers of the service know how to use it. A WSDL document declares things like:&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;The operations you can call on the service&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;How the input and output messages should look&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Which protocol or data format you should use to access the service&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The location of the service (e.g. its HTTP endpoint)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;WSDL looks like a regular XML file, and it’s usually saved with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.wsdl&lt;/code&gt; extension.&lt;/p&gt;

&lt;p&gt;WSDL is also a standard from the W3C. 
You don’t have to use WSDL, but since it documents a web service completely, it’s become a common way to share information about web services (especially SOAP web services).
Because of its widespread adoption, there are many tools which can understand WSDL files and use them to connect to web services.&lt;/p&gt;

&lt;h3 id=&quot;what-does-it-look-like-1&quot;&gt;What does it look like?&lt;/h3&gt;

&lt;p&gt;There are two major versions of WSDL:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;A WSDL 1.1 document starts with the root element, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;definitions&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;A WSDL 2.0 document starts with the root element, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;description&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;WSDL contains elements to define the web service operations, data types, protocol and data formats, and location of the service. Inside the WSDL document, you can use &lt;strong&gt;XML Schema (XSD)&lt;/strong&gt; to define the messages which should be received and sent by the web service.&lt;/p&gt;

&lt;!-- TODO example code. --&gt;

&lt;h3 id=&quot;what-can-you-do-with-wsdl&quot;&gt;What can you do with WSDL?&lt;/h3&gt;

&lt;p&gt;WSDL has been around for a long time, although it’s still used for lots of internal systems. So what can you do with it?&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Write a WSDL.&lt;/strong&gt; You can write a WSDL document using any text editor. It’s written in XML.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Describe your web service.&lt;/strong&gt; Inside the WSDL file you can describe all of the operations your web service has, and the structure of the input and output messages.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Generate a WSDL from code.&lt;/strong&gt; In some programming languages, you can generate a WSDL document automatically from your code. This is much easier than writing a WSDL document manually.&lt;/p&gt;

    &lt;p&gt;For example… In Java, you can write code for a web service using the &lt;a target=&quot;_blank&quot; href=&quot;https://www.baeldung.com/jax-ws&quot;&gt;JAX-WS&lt;/a&gt; APIs, and add a library like &lt;a target=&quot;_blank&quot; href=&quot;https://cxf.apache.org/&quot;&gt;CXF&lt;/a&gt; which implements the JAX-WS standard. When you deploy your code, a WSDL will be automatically generated.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Create a web service client.&lt;/strong&gt; If a web service provides a WSDL, you can import the WSDL into your programming language, and use it to create a &lt;i&gt;client&lt;/i&gt;. There are libraries to help you do this in most programming languages. It can save a lot of time and means you don’t have to write a bunch of XML yourself!&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Share it.&lt;/strong&gt; You can publish a WSDL into a repository, so that people can find it and discover your web service.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr class=&quot;cloud1&quot; /&gt;

&lt;h2 id=&quot;how-is-xsd-related-to-wsdl&quot;&gt;How is XSD related to WSDL?&lt;/h2&gt;

&lt;p&gt;WSDL describes the interface of a web service. One of the key things you need to know when connecting to a web service is how you should construct your request message. So, the WSDL defines what the input and output messages for the service should look like.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WSDL didn’t introduce a new language for describing these messages. Instead, it chose to adopt XML Schema Definition as its type system.&lt;/strong&gt; &lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; 
So WSDL uses the features of XSD to describe input and output messages – by defining the elements, their types, their sequence, and so on.&lt;/p&gt;

&lt;p&gt;Most WSDL documents either include an XSD document, or they reference an XSD document located somewhere else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So WSDL and XSD are closely related.&lt;/strong&gt; You will often see XSD being used to describe the input and output messages of a web service.&lt;/p&gt;

&lt;h3 id=&quot;chains&quot;&gt;Chains&lt;/h3&gt;
&lt;p&gt;Sometimes, you might also see a chain of documents, where a WSDL references an external XSD document, which itself references another XSD document.&lt;/p&gt;

&lt;p&gt;You might see this when dealing with very complex web services, or many web services which share similar messages. So the messages might be defined in one place, and then referenced from many places.&lt;/p&gt;

&lt;!-- You can also extend WSDL by using another way to describe your messages instead of XSD, but you tend to not see that very often. --&gt;

&lt;hr class=&quot;cloud3&quot; /&gt;

&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;

&lt;p&gt;XML Schema Definition, or XSD, is almost the &lt;em&gt;de facto&lt;/em&gt; way to write rules for your XML documents. An XSD document describes which elements should be present in an XML document. It can be used to validate XML.&lt;/p&gt;

&lt;p&gt;WSDL, or Web Services Definition Language, is a way to describe web services. It’s also written in XML. Many WSDL documents use XML Schema to describe the types of messages that a web service either consumes or produces.&lt;/p&gt;

&lt;p&gt;There are so many ways to create a web service. But now you’re familiar with XSD and WSDL, you’ll be on your way to creating and consuming XML-based web services!&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://www.w3.org/standards/xml/schema&quot;&gt;XML Technology: Schema&lt;/a&gt;. &lt;em&gt;W3C&lt;/em&gt;. Retrieved 2022-07-14. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://courses.cs.duke.edu/fall14/compsci316/lectures/12-xml-notes.pdf&quot;&gt;XML, DTD and XML Schema&lt;/a&gt;. &lt;em&gt;Duke University&lt;/em&gt;. 2014. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://www.w3.org/TR/wsdl/&quot;&gt;Web Services Description Language (WSDL) Version 2.0 Part 1: Core Language&lt;/a&gt;. &lt;em&gt;W3C&lt;/em&gt;. 26 June 2007. &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://www.ibm.com/docs/en/app-connect/11.0.0?topic=services-what-is-wsdl&quot;&gt;What is WSDL?&lt;/a&gt;. &lt;em&gt;IBM&lt;/em&gt;. Retrieved 2022-07-05. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 04 Jul 2022 08:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/xsd-vs-wsdl/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/xsd-vs-wsdl/</guid>
        
        <category>Integration</category>
        
        
        <category>integration</category>
        
      </item>
    
      <item>
        <title>How to download all Maven dependencies into a folder</title>
        <description>&lt;p&gt;In this article we’ll look at how to use Maven to download all of your Java project’s dependencies, like libraries and frameworks, and save them into a specific folder.&lt;/p&gt;

&lt;!-- TODO pattern picture of lots of empty jam jars flying downwards through the sky --&gt;

&lt;!-- TODO infographic of Maven goals, plugins, phases. --&gt;

&lt;div class=&quot;summary&quot;&gt;
  &lt;h3 id=&quot;summary&quot;&gt;Summary&lt;/h3&gt;

  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;You can use the &lt;a target=&quot;_blank&quot; href=&quot;https://maven.apache.org/plugins/maven-dependency-plugin/&quot;&gt;Maven Dependency Plugin&lt;/a&gt; to download dependencies.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mvn dependency:copy-dependencies&lt;/code&gt;, to download all your dependencies and save them in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target/dependency&lt;/code&gt; folder.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;You can change the target location by setting the property &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;outputDirectory&lt;/code&gt;.&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;

&lt;p class=&quot;warning&quot;&gt;&lt;strong&gt;Normally, you don’t need to download your dependencies explicitly!&lt;/strong&gt; Maven automatically downloads your project’s dependencies, whenever you run a build. (So you can ignore this post.)&lt;/p&gt;

&lt;p&gt;So why might you need to download dependencies? Well, you might need to do this if…&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;You want to run your project (and its dependencies) on another machine which doesn’t have internet access&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You want to debug a library, so you want a local copy&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You simply like collecting jars&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If this sounds like you, read on.&lt;/p&gt;

&lt;figure class=&quot;full&quot; vocab=&quot;http://schema.org/&quot; typeof=&quot;ImageObject&quot;&gt;
  &lt;img src=&quot;https://assets.tutorialworks.com/images/jar-cloud-thumb.png&quot; width=&quot;1200&quot; height=&quot;675&quot; loading=&quot;lazy&quot; property=&quot;contentUrl&quot; alt=&quot;Illustration of glass jars flying through the sky&quot; /&gt;&lt;/figure&gt;

&lt;h2 id=&quot;all-deps&quot;&gt;Steps to download all dependencies&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;When you want to do something in Maven, you usually need a plugin.&lt;/strong&gt; Most features in Maven – like compiling code, running tests and downloading dependencies – are implemented inside a plugin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To download dependencies, you can use the &lt;a target=&quot;_blank&quot; href=&quot;https://maven.apache.org/plugins/maven-dependency-plugin/&quot;&gt;Maven Dependency Plugin&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;download-dependencies-without-building-your-project&quot;&gt;Download dependencies (without building your project)&lt;/h3&gt;
&lt;p&gt;From the Maven Dependency Plugin, we can use the &lt;i&gt;goal&lt;/i&gt; &lt;a target=&quot;_blank&quot; href=&quot;https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy-dependencies&lt;/code&gt;&lt;/a&gt;. It downloads dependencies from a &lt;i&gt;repository&lt;/i&gt; (usually the “main” online repository, &lt;a target=&quot;_blank&quot; href=&quot;https://search.maven.org&quot;&gt;Maven Central&lt;/a&gt;) to our local project folder.&lt;/p&gt;

&lt;p&gt;You can execute this &lt;i&gt;goal&lt;/i&gt; separately, without building your project.&lt;/p&gt;

&lt;p&gt;Here’s how to do it:&lt;/p&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;In your project’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pom.xml&lt;/code&gt;, make sure that you’ve added all the dependencies you want to use.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Drop to a terminal in your project folder (where your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pom.xml&lt;/code&gt; is located).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Run this command to execute the &lt;i&gt;goal&lt;/i&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy-dependencies&lt;/code&gt;, which starts downloading dependencies:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mvn dependency:copy-dependencies
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Maven Dependency Plugin will download dependencies (for example, JAR files) into the folder &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target/dependency&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Afterwards, you will see that the files have been downloaded:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ls -al target/dependency
total 63676
drwxr-xr-x. 2 tdonohue tdonohue    16384 Jun 26 10:46 .
drwxr-xr-x. 7 tdonohue tdonohue     4096 Jun 26 10:46 ..
-rw-r--r--. 1 tdonohue tdonohue   364206 Jun 26 10:46 aesh-2.6.jar
-rw-r--r--. 1 tdonohue tdonohue     6806 Jun 26 10:46 apiguardian-api-1.1.2.jar
-rw-r--r--. 1 tdonohue tdonohue   199943 Jun 26 10:46 arc-2.9.2.Final.jar
-rw-r--r--. 1 tdonohue tdonohue   122176 Jun 26 10:46 asm-9.3.jar
....
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And that’s pretty much it.&lt;/p&gt;

&lt;h3 id=&quot;download-dependencies-to-a-specific-location&quot;&gt;Download dependencies to a specific location&lt;/h3&gt;
&lt;p&gt;Want to download to a different location? No problem.&lt;/p&gt;

&lt;p&gt;The Maven Dependency Plugin &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy-dependency&lt;/code&gt; goal saves files to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target/dependency&lt;/code&gt; by default. &lt;strong&gt;But you can change the behaviour, by setting the property &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;outputDirectory&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mvn dependency:copy-dependencies -DoutputDirectory=/mydeps
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(See how we use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-D&lt;/code&gt; to set a property.)&lt;/p&gt;

&lt;p&gt;Now Maven will download the artifacts to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/mydeps&lt;/code&gt; directory.&lt;/p&gt;

&lt;h2 id=&quot;how-does-it-work&quot;&gt;How does it work?&lt;/h2&gt;
&lt;p&gt;Like most features in Maven, this is made possible by a plugin, the &lt;a target=&quot;_blank&quot; href=&quot;https://maven.apache.org/plugins/maven-dependency-plugin/&quot;&gt;Maven Dependency Plugin&lt;/a&gt;. The plugin helps you to manage your project’s dependencies:&lt;/p&gt;

&lt;p&gt;About the plugin:&lt;/p&gt;

&lt;table class=&quot;keyfacts&quot;&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Name&lt;/td&gt;
      &lt;td&gt;Maven Dependency Plugin&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Purpose&lt;/td&gt;
      &lt;td&gt;The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Homepage&lt;/td&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://maven.apache.org/plugins/maven-dependency-plugin/&quot;&gt;maven-dependency-plugin&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;abbr title=&quot;A keyword that you can use to execute goals from this plugin without needing to add it into your POM&quot;&gt;Prefix&lt;/abbr&gt;&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dependency:&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Example goals&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy-dependencies&lt;/code&gt; – downloads dependencies&lt;br /&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;analyze&lt;/code&gt; – calculates used/unused dependencies&lt;br /&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tree&lt;/code&gt; – shows the dependency tree for your project&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The plugin analyses the dependencies in your project, and copies dependencies from Maven Central (or the repository you have configured).&lt;/p&gt;

&lt;p&gt;There are lots of other plugins for Maven, too - see the &lt;a target=&quot;_blank&quot; href=&quot;https://maven.apache.org/plugins/index.html&quot;&gt;list&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;

&lt;p&gt;We’ve seen how you can use the Maven Dependency Plugin to download all of your project’s dependencies (JAR files) into a single folder.&lt;/p&gt;

&lt;p&gt;We activate this plugin using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dependency:&lt;/code&gt; prefix, and then choose the goal to execute. In our case, we use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy-dependencies&lt;/code&gt; &lt;i&gt;goal&lt;/i&gt;.&lt;/p&gt;

&lt;p&gt;If you want to check out what else the plugin can do, see the &lt;a target=&quot;_blank&quot; href=&quot;https://maven.apache.org/plugins/maven-dependency-plugin/&quot;&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy building!&lt;/p&gt;

</description>
        <pubDate>Sun, 26 Jun 2022 09:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/maven-download-dependencies/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/maven-download-dependencies/</guid>
        
        <category>Java</category>
        
        <category>Apache Maven</category>
        
        
        <category>java</category>
        
      </item>
    
      <item>
        <title>Java frameworks: Spring vs Quarkus</title>
        <description>&lt;p&gt;After you’ve mastered your ints and hashmaps, you probably want to know how Java software is developed in the real world. Well, you probably won’t write as much code as you think. Most programming problems have already been solved in frameworks. But which are the most well-known Java frameworks? Let’s find out.&lt;/p&gt;

&lt;figure class=&quot;full&quot; vocab=&quot;http://schema.org/&quot; typeof=&quot;ImageObject&quot;&gt;
  &lt;img src=&quot;https://assets.tutorialworks.com/images/java-frameworks.png&quot; width=&quot;1200&quot; height=&quot;675&quot; loading=&quot;lazy&quot; property=&quot;contentUrl&quot; alt=&quot;A mug of coffee with a Spring leaf design next to another mug with an atom Quarkus design&quot; /&gt;&lt;/figure&gt;

&lt;p&gt;For most Java developers, frameworks are a part of everyday life.&lt;/p&gt;

&lt;p&gt;Perhaps you’re just learning Java and you want to get the lay of the land, or you’re an operations engineer who wants to understand more about those Java workloads you’re running.&lt;/p&gt;

&lt;p&gt;Well, here are the frameworks you will probably see in modern Java development.&lt;/p&gt;

&lt;h2 id=&quot;why-frameworks&quot;&gt;Why frameworks?&lt;/h2&gt;
&lt;p&gt;A good framework helps you build solid foundations for your application &lt;strong&gt;and&lt;/strong&gt; means that you don’t need to “reinvent the wheel” for every bit of functionality you need.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(We might think that we can forge a piece of metal into something that turns round and round, but it’s easier and cheaper to just buy a wheel.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Of course, you can still write an app from scratch without a framework.&lt;/strong&gt; But in most companies – especially larger ones – you’ll see frameworks in use.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because a framework provides a common way to write an application. It helps developers work together, and it reduces the amount of boilerplate code that you need to write.&lt;/p&gt;

&lt;p&gt;Let’s see two of the most well-known Java frameworks in use today: Spring and Quarkus.&lt;/p&gt;

&lt;h2 id=&quot;spring&quot;&gt;🍃 Spring&lt;/h2&gt;

&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://spring.io/&quot;&gt;Spring&lt;/a&gt; is an umbrella brand for a whole bunch of frameworks and libraries for Java. Specifically many new Java projects these days start on &lt;strong&gt;Spring Boot&lt;/strong&gt;:&lt;/p&gt;

&lt;table class=&quot;keyfacts&quot;&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Website&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://spring.io/projects/spring-boot&quot; target=&quot;_blank&quot;&gt;https://spring.io/projects/spring-boot&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Stargazers&lt;/td&gt;
      &lt;td&gt;61,000+&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;GitHub&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/spring-projects/spring-boot&quot; target=&quot;_blank&quot;&gt;https://github.com/spring-projects/spring-boot&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;License&lt;/td&gt;
      &lt;td&gt;Apache 2.0&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Examples&lt;/td&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://github.com/gothinkster/spring-boot-realworld-example-app&quot;&gt;GoThinkster RealWorld&lt;/a&gt;, &lt;a target=&quot;_blank&quot; href=&quot;https://github.com/spring-projects/spring-petclinic&quot;&gt;Spring Petclinic&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Spring started out as a dependency injection framework, but now it’s much more than that. The various projects in Spring help Java developers to do things like connect to a database, or write reactive (asynchronous) applications.&lt;/p&gt;

&lt;p&gt;Let’s dive in to Spring.&lt;/p&gt;

&lt;h3 id=&quot;what-is-spring-whats-inside-the-box&quot;&gt;What is Spring? What’s inside the box?&lt;/h3&gt;
&lt;p&gt;Spring has many projects, but the most well-known ones are:&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://spring.io/projects/spring-framework&quot;&gt;&lt;strong&gt;Spring Framework&lt;/strong&gt;&lt;/a&gt;. This is the main project, and is the basis for everything else in the Spring universe. Spring Framework is a dependency injection container, and a bunch of utilities.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://spring.io/projects/spring-boot&quot;&gt;&lt;strong&gt;Spring Boot&lt;/strong&gt;&lt;/a&gt;. Spring Boot is the modern way to create a Spring application. You don’t need to use Boot to create a Spring app. But most people do, because it’s easier! It makes it easy to “bootstrap” a Spring project (it configures your Spring Framework container and auto-configures lots of third-party libraries too.)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The are lots of other projects under the ‘Spring’ name.&lt;/strong&gt; Some of them help you work with data (Spring Data), write batch processing programs (Spring Batch), or create REST services (Spring REST).&lt;/p&gt;

&lt;!-- 
&quot;Bootstrapping&quot; means... TODO
Compiles to a standalone JAR file. Copy and run anywhere.
Spring Boot is basically like a kit car. You can choose from a lot of different parts (the libraries), all curated to work with each other. You assemble it yourself.
Contains an embedded web server. The default is Tomcat but you can also use Jetty or even Undertow - https://www.baeldung.com/spring-boot-servlet-containers 
It contains a LOT, so it can be difficult to &quot;wrap your head around it&quot;
Spring Data, Spring Batch, Spring Rest.
Spring MVC + Thymeleaf. For web applications which need to render a front-end.  
--&gt;

&lt;h3 id=&quot;what-do-you-need-to-know&quot;&gt;What do you need to know?&lt;/h3&gt;
&lt;p&gt;What should you know about Spring?&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Spring enables the Inversion-of-Control design pattern.&lt;/strong&gt; Inside your application, Spring creates a virtual ‘container’ called the &lt;i&gt;Application Context&lt;/i&gt;. Inside the container, it creates objects from your classes, and then wires them up together (simple, right?)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;It’s stable and well-documented.&lt;/strong&gt; Spring is supported by VMware, who employ developers that work on Spring and keep it patched and up-to-date.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Big community.&lt;/strong&gt; There are almost 200,000 questions about Spring on Stack Overflow, an annual &lt;a target=&quot;_blank&quot; href=&quot;https://springone.io/&quot;&gt;Spring conference&lt;/a&gt;, and lots of blog posts to learn from.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Good for cloud-native microservices.&lt;/strong&gt; Spring Boot helped spread the trend of running Java applications without an application server. Spring Boot builds your application to a single &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.jar&lt;/code&gt; file. This makes it easier to implement microservices.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;The inertia effect.&lt;/strong&gt; Spring is used by lots of developers, so… it gets used by &lt;em&gt;even more&lt;/em&gt; developers. If you know Spring, you won’t have a problem finding a job in Java today.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-develop-apps-with-spring-boot&quot;&gt;How to develop apps with Spring Boot&lt;/h3&gt;

&lt;p&gt;Most people start with Spring Boot. It’s the easiest way to start developing a Spring application:&lt;/p&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Generate your app.&lt;/strong&gt; Go to &lt;a target=&quot;_blank&quot; href=&quot;https://start.spring.io/&quot;&gt;start.spring.io&lt;/a&gt;, use the application generator. Add the Spring Web dependency. This generates a Spring Boot application with an embedded web server (so you can create APIs).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Write your code.&lt;/strong&gt; Load the project into your IDE. Add &lt;a target=&quot;_blank&quot; href=&quot;https://www.jrebel.com/blog/spring-annotations-cheat-sheet&quot;&gt;annotations&lt;/a&gt; to your code when you need Spring to do something.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Compile your app to a JAR file.&lt;/strong&gt; Use the Maven plugin to compile your application into a single JAR file.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Deploy and run it.&lt;/strong&gt; Run the packaged JAR file on a virtual machine with Java installed, run in the cloud (e.g. &lt;a target=&quot;_blank&quot; href=&quot;https://aws.amazon.com/blogs/devops/deploying-a-spring-boot-application-on-aws-using-aws-elastic-beanstalk/&quot;&gt;deploy it onto AWS Elastic Beanstalk&lt;/a&gt;) or package it into a container image and run on Kubernetes.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;quarkus&quot;&gt;⚛ Quarkus&lt;/h2&gt;
&lt;p&gt;Quarkus is a framework for developing small, fast Java apps.&lt;/p&gt;

&lt;table class=&quot;keyfacts&quot;&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Website&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://quarkus.io&quot; target=&quot;_blank&quot;&gt;https://quarkus.io&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Stargazers&lt;/td&gt;
      &lt;td&gt;10,000+&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;GitHub&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/quarkusio/quarkus&quot; target=&quot;_blank&quot;&gt;https://github.com/quarkusio/quarkus&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;License&lt;/td&gt;
      &lt;td&gt;Apache 2.0&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Examples&lt;/td&gt;
      &lt;td&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://github.com/quarkusio/quarkus-quickstarts&quot;&gt;quarkus-quickstarts&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Quarkus consists of a runtime “core” which you use to develop your application.&lt;/p&gt;

&lt;p&gt;Then you add &lt;i&gt;extensions&lt;/i&gt; which give you features and functionality you want to add to your app.&lt;/p&gt;

&lt;h3 id=&quot;what-is-quarkus-whats-inside-the-box&quot;&gt;What is Quarkus? What’s inside the box?&lt;/h3&gt;
&lt;p&gt;So what &lt;strong&gt;is&lt;/strong&gt; Quarkus, really? When you create apps with it, what components do you use?&lt;/p&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Quarkus Core.&lt;/strong&gt; This is the runtime core which helps you build the scaffolding for your app. It manages the lifecycle of your application and handles capabilities like configuration management, etc.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Reactive Engine.&lt;/strong&gt; Under the hood, Quarkus uses a tool called Vert.x to manage tasks from the various internal components. Vert.x is a Java toolkit for creating &lt;i&gt;reactive&lt;/i&gt; applications. It helps applications to perform some tasks quicker, by allowing the application to work on another task, while it’s waiting for the result of another task. (It’s a bit more complicated than this, but &lt;a target=&quot;_blank&quot; href=&quot;https://vertx.io/introduction-to-vertx-and-reactive/&quot;&gt;you can read more&lt;/a&gt;.)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Quarkus Extensions.&lt;/strong&gt; To add a framework or library to your Quarkus app, you need to add an &lt;i&gt;extension&lt;/i&gt;. There are a growing number of extensions. For example, there is a JPA extension which lets you add Hibernate, so that you can save data to a database. Or, you can use the Arc extension to add support for CDI (Contexts &amp;amp; Dependency Injection).&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;what-do-you-need-to-know-1&quot;&gt;What do you need to know?&lt;/h3&gt;

&lt;ul class=&quot;default&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Quarkus optimises your app at build time.&lt;/strong&gt; Quarkus uses a special build process, which removes some unused code and classes. It also tries to do some of your app’s initialisation work upfront during the build, so that the compiled app has to do less work on startup.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Uses less memory, starts up faster.&lt;/strong&gt; Some tests have shown that Quarkus uses less memory at runtime and starts up quicker. This means that it’s a good choice for developing microservices.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Compiles to a native binary on Linux.&lt;/strong&gt; A Quarkus application can be compiled to a native binary on Linux. This means that your application can run on a Linux system without needing to run inside the Java Virtual Machine (JVM), so it can be much smaller and faster.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Uses Java standards that you might already know.&lt;/strong&gt; Quarkus lets you code using some well-known Java standards, like CDI, JPA, JAX-RS and MicroProfile.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Live coding.&lt;/strong&gt; While you’re developing, Quarkus can automatically compile your code changes and reload your application, without you having to stop and start it yourself. It’s very fast, and feels just like you are developing a PHP or Node.js app.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Tooling to create containers.&lt;/strong&gt; The Quarkus build tooling lets you easily create a container (Docker) image for your application.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-develop-apps-with-quarkus&quot;&gt;How to develop apps with Quarkus&lt;/h3&gt;

&lt;p&gt;To get started with Quarkus, you can create a skeleton project and add the extensions that you need.&lt;/p&gt;

&lt;p&gt;Here’s how to do it:&lt;/p&gt;

&lt;ol class=&quot;tech-steps&quot;&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Generate your app.&lt;/strong&gt; Go to &lt;a target=&quot;_blank&quot; href=&quot;https://code.quarkus.io/&quot;&gt;code.quarkus.io&lt;/a&gt; to generate a new Quarkus application. Add the capabilities you want to your app, by choosing &lt;i&gt;Extensions&lt;/i&gt;. Download the source code as a ZIP file.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Write your code.&lt;/strong&gt; Import the source code into your IDE. Write your code.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Build your application to a JAR or native binary.&lt;/strong&gt; Use the Quarkus Maven Plugin to package your app, and optionally into a native binary and/or into a container.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Deploy and run it.&lt;/strong&gt; Run it on a cloud provider, Kubernetes cluster, FaaS/serverless platform (like &lt;a target=&quot;_blank&quot; href=&quot;https://quarkus.io/guides/amazon-lambda-http&quot;&gt;AWS Lambda&lt;/a&gt; or Azure Functions) or just a plain old virtual machine.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;/h2&gt;

&lt;p&gt;Two of the biggest Java frameworks in use today are Spring (well, specifically Spring Boot) and Quarkus.&lt;/p&gt;

&lt;p&gt;If you want to understand Java, then try to create a simple application in either of these two frameworks. It will give you a better idea of how Java programs are written in the real world.&lt;/p&gt;

&lt;p&gt;Of course, there are many more frameworks in Java; too numerous to cover here. (But that’s maybe an article for another day!)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Java programming.&lt;/strong&gt;&lt;/p&gt;

</description>
        <pubDate>Mon, 30 May 2022 07:00:00 +0000</pubDate>
        <link>https://www.tutorialworks.com/java-frameworks/</link>
        <guid isPermaLink="true">https://www.tutorialworks.com/java-frameworks/</guid>
        
        <category>Java</category>
        
        
        <category>java</category>
        
      </item>
    
  </channel>
</rss>
