<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:schema="http://schema.org/" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" version="2.0" xml:base="https://www.linuxjournal.com/">
  <channel>
    <title>#Shells</title>
    <link>https://www.linuxjournal.com/</link>
    <description/>
    <language>en</language>
    
    <item>
  <title>The Power of Linux Shell Environment Variables</title>
  <link>https://www.linuxjournal.com/content/power-linux-shell-environment-variables</link>
  <description>  &lt;div data-history-node-id="1341316" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img loading="lazy" src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/the-power-of-linux-shell-environment-variables.jpg" width="850" height="500" alt="The Power of Linux Shell Environment Variables" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/george-whittaker" lang="" about="https://www.linuxjournal.com/users/george-whittaker" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;George Whittaker&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;If you're working in a Linux environment, chances are you've encountered environment variables—even if you didn’t realize it at the time. They quietly power much of what goes on behind the scenes in your shell sessions, influencing everything from what shell prompt you see to which programs are available when you type a command. Whether you're an experienced sysadmin or a new Linux user, mastering environment variables is essential for customizing and controlling your shell experience.&lt;/p&gt;

&lt;p&gt;In this guide, we'll take a dive into environment variables in the Linux shell. By the end, you'll not only know how to view and set these variables, but also how to persist them, use them in scripts, and troubleshoot issues effectively.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;What Are Environment Variables?&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;At a basic level, &lt;strong&gt;environment variables&lt;/strong&gt; are dynamic named values that affect the behavior of running processes on your Linux system. Think of them as configuration settings that your shell (like Bash or Zsh) and applications refer to in order to understand how they should operate.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;
	&lt;p&gt;The &lt;code&gt;PATH&lt;/code&gt; variable tells the shell where to look for executable files.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;The &lt;code&gt;HOME&lt;/code&gt; variable stores the path to your home directory.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;The &lt;code&gt;LANG&lt;/code&gt; variable defines your system’s language and character encoding.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;&lt;span class="h3-replacement"&gt;&lt;strong&gt;Environment Variables vs Shell Variables&lt;/strong&gt;&lt;/span&gt;

&lt;p&gt;There is an important distinction between &lt;strong&gt;shell variables&lt;/strong&gt; and &lt;strong&gt;environment variables&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;Shell variables&lt;/strong&gt; are local to the shell session in which they are defined.&lt;/p&gt;
	&lt;/li&gt;
	&lt;li&gt;
	&lt;p&gt;&lt;strong&gt;Environment variables&lt;/strong&gt; are shell variables that have been &lt;em&gt;exported&lt;/em&gt;, meaning they are inherited by child processes spawned from the shell.&lt;/p&gt;
	&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;&lt;strong&gt;Viewing Environment Variables&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Before you can modify or use environment variables, it's important to know how to inspect them.&lt;/p&gt;

&lt;span class="h3-replacement"&gt;&lt;strong&gt;View All Environment Variables&lt;/strong&gt;&lt;/span&gt;

&lt;p&gt;&lt;code&gt;printenv &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;&lt;code&gt;env &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Both commands list environment variables currently set for the session.&lt;/p&gt;

&lt;span class="h3-replacement"&gt;&lt;strong&gt;View a Specific Variable&lt;/strong&gt;&lt;/span&gt;

&lt;p&gt;&lt;code&gt;echo $HOME &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will display the current user's home directory.&lt;/p&gt;

&lt;span class="h3-replacement"&gt;&lt;strong&gt;View All Shell Variables&lt;/strong&gt;&lt;/span&gt;

&lt;p&gt;&lt;code&gt;set &lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command displays all shell variables and functions. It's broader than &lt;code&gt;printenv&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Setting and Exporting Environment Variables&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;You can define your own variables or temporarily change existing ones within your shell.&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/power-linux-shell-environment-variables" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Tue, 08 Apr 2025 16:00:00 +0000</pubDate>
    <dc:creator>George Whittaker</dc:creator>
    <guid isPermaLink="false">1341316 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>SSH Key Rotation with the POSIX Shell - Sunset Nears for Elderly Keys</title>
  <link>https://www.linuxjournal.com/content/ssh-key-rotation-posix-shell-sunset-nears-elderly-keys</link>
  <description>  &lt;div data-history-node-id="1340862" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img loading="lazy" src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/ssh-key-rotation-with-the-psix-shell.jpg" width="850" height="500" alt="SSH Key Rotation with the POSIX Shell" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/charles-fisher" lang="" about="https://www.linuxjournal.com/users/charles-fisher" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Charles Fisher&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;OpenBSD has recently stressed to us the value of key rotation by their use of “&lt;a href="https://www.google.com/url?q=http://www.openbsd.org/papers/bsdcan-signify.html&amp;source=gmail-html&amp;ust=1638984274167000&amp;usg=AOvVaw22y3ZbpLKGxMQK67aecok5"&gt;Signify&lt;/a&gt;” distribution release signatures. We have realized that SSH keys should also rotate, to reduce the risk of powerful keys that fall into the wrong hands which become “the gift that keeps on giving.” There have always been &lt;a href="https://www.google.com/url?q=https://www.ssh.com/academy/iam/ssh-key-management&amp;source=gmail-html&amp;ust=1638984274167000&amp;usg=AOvVaw2MLa9NGIpef9GfVUuVmZuF"&gt;open questions&lt;/a&gt; on the retirement of SSH keys. These questions have &lt;a href="https://www.google.com/url?q=https://tailscale.com/blog/rotate-ssh-keys/&amp;source=gmail-html&amp;ust=1638984274167000&amp;usg=AOvVaw1pNKpjTfA13B7PZBGY3ElC"&gt;grown in volume&lt;/a&gt; and many are joining the &lt;a href="https://www.google.com/url?q=https://engineering.fb.com/2016/09/12/security/scalable-and-secure-access-with-ssh/&amp;source=gmail-html&amp;ust=1638984274167000&amp;usg=AOvVaw0kkWOyzgz_dSrQuV8s7Wj0"&gt;advocacy&lt;/a&gt; for SSH certificate authorities.&lt;/p&gt;

&lt;p&gt;To “rotate” an SSH key is to replace it, in such a way that it is no longer recognized, requiring removal from the &lt;code&gt;authorized_keys&lt;/code&gt; file. SSH rotation is &lt;a href="https://www.google.com/url?q=https://medium.com/rackbrains/automate-ssh-key-rotation-with-ansible-part-1-a99934d2dfc9&amp;source=gmail-html&amp;ust=1638984274167000&amp;usg=AOvVaw2ZhCSS29y0V6a_qIpTs00O"&gt;commonly addressed&lt;/a&gt; with Ansible, but this leaves many users on smaller systems or lacking privilege without recourse. A more basic and accessible method to migrate SSH keys is sorely lacking.&lt;/p&gt;

&lt;p&gt;Below is presented an SSH key rotation script written in nothing more than the POSIX shell.&lt;/p&gt;

&lt;p&gt;There is palpable danger in the misuse of such a tool. Many administrators control inaccessible systems that entail massive inconvenience in a loss of control. Demonstrated here are rotation schemes of increasing risk, for any holder of a key to choose, to their own tolerance. Hopefully, I have not made grave mistakes in the design.&lt;/p&gt;

&lt;p&gt;The most conservative users of this approach should tread with extreme caution, test carefully, and ensure alternate means of access prior to any deployment. As the author, I have no desire to assume any responsibility for a failed rotation, and its consequences. I especially disavow the “wipe” option below to remove entries from &lt;code&gt;authorized_keys&lt;/code&gt;. It is presented as commentary, not working code.&lt;/p&gt;

&lt;p&gt;In any case, we foolishly rush in where the more prudent fear to tread.&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/ssh-key-rotation-posix-shell-sunset-nears-elderly-keys" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Tue, 07 Dec 2021 17:00:00 +0000</pubDate>
    <dc:creator>Charles Fisher</dc:creator>
    <guid isPermaLink="false">1340862 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>Parallel shells with xargs: Utilize all your cpu cores on UNIX and Windows</title>
  <link>https://www.linuxjournal.com/content/parallel-shells-xargs-utilize-all-your-cpu-cores-unix-and-windows</link>
  <description>  &lt;div data-history-node-id="1340828" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img loading="lazy" src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/parallel-shells-with-xargs-unix.jpg" width="850" height="500" alt="Parallel Shells With xargs Unix" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/charles-fisher" lang="" about="https://www.linuxjournal.com/users/charles-fisher" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Charles Fisher&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p dir="ltr"&gt;One particular frustration with the UNIX shell is the inability to easily schedule multiple, concurrent tasks that fully utilize CPU cores presented on modern systems. The example of focus in this article is file compression, but the problem rises with many computationally intensive tasks, such as image/audio/media processing, password cracking and hash analysis, database &lt;a href="https://en.wikipedia.org/wiki/Extract,_transform,_load"&gt;Extract, Transform, and Load&lt;/a&gt;, and backup activities. It is understandably frustrating to wait for gzip * running on a single CPU core, while most of a machine's processing power lies idle.&lt;/p&gt;

&lt;p dir="ltr"&gt;This can be understood as a weakness of the first decade of &lt;a href="https://en.wikipedia.org/wiki/Research_Unix"&gt;Research UNIX&lt;/a&gt; which was not developed on machines with &lt;a href="https://en.wikipedia.org/wiki/Symmetric_multiprocessing"&gt;SMP&lt;/a&gt;. The Bourne shell did not emerge from the 7th edition with any native syntax or controls for cohesively managing the resource consumption of background processes.&lt;/p&gt;

&lt;p dir="ltr"&gt;Utilities have haphazardly evolved to perform some of these functions. The &lt;a href="https://www.gnu.org/software/findutils/manual/html_node/find_html/xargs-options.html"&gt;GNU version of xargs&lt;/a&gt; is able to exercise some primitive control in allocating background processes, which is &lt;a href="https://www.gnu.org/software/findutils/manual/html_node/find_html/Controlling-Parallelism.html"&gt;discussed at some length&lt;/a&gt; in the documentation. While the GNU extensions to xargs have proliferated to many other implementations (notably BusyBox, including the release for Microsoft Windows, example below), they &lt;a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/xargs.html"&gt;are not POSIX.2-compliant&lt;/a&gt;, and likely will not be found on commercial UNIX.&lt;/p&gt;

&lt;p dir="ltr"&gt;Historic users of xargs will remember it as a useful tool for directories that contained too many files for echo * or other wildcards to be used; in this situation xargs is called to repeatedly batch groups of files with a single command. As xargs has evolved beyond POSIX, it has assumed a new relevance which is useful to explore.&lt;/p&gt;

&lt;hr /&gt;&lt;h2 dir="ltr"&gt;Why is &lt;a href="https://en.wikipedia.org/wiki/POSIX#Parts_before_1997"&gt;POSIX.2&lt;/a&gt; this bad?&lt;/h2&gt;

&lt;p dir="ltr"&gt;A clear understanding of the lack of cohesive job scheduling in UNIX requires some history of the evolution of these utilities.&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/parallel-shells-xargs-utilize-all-your-cpu-cores-unix-and-windows" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Tue, 16 Feb 2021 17:00:00 +0000</pubDate>
    <dc:creator>Charles Fisher</dc:creator>
    <guid isPermaLink="false">1340828 at https://www.linuxjournal.com</guid>
    </item>

  </channel>
</rss>
