<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Linux on maladroit.dev</title><link>https://maladroit-dev-398201.gitlab.io/tags/linux/</link><description>Recent content in Linux on maladroit.dev</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://maladroit-dev-398201.gitlab.io/tags/linux/index.xml" rel="self" type="application/rss+xml"/><item><title>alias</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/alias/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/alias/</guid><description>&lt;h1 id="alias"&gt;alias&lt;/h1&gt;
&lt;p&gt;Creating an alias for complex commands&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;alias workspace&lt;span style="color:#f92672"&gt;=&lt;/span&gt;cd ~/workspace
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>cd</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/cd/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/cd/</guid><description>&lt;h1 id="cd"&gt;cd&lt;/h1&gt;
&lt;p&gt;Change directory. Works with the &lt;a href="https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/directory"&gt;Directory&lt;/a&gt;
path special characters&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# navigates to the workspace directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd ~/workspace
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# navigates to the previous directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd -
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Command line arguments</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/command-line-arguments/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/command-line-arguments/</guid><description>&lt;h1 id="command-line-arguments"&gt;Command line arguments&lt;/h1&gt;
&lt;p&gt;Command line arguments are passed to command line applications and come in two
varieties.&lt;/p&gt;
&lt;h2 id="positional-arguments"&gt;Positional arguments&lt;/h2&gt;
&lt;p&gt;Positional arguments can be any number of arguments that are separated by a
space. If an argument contains a space in it, it must either be escaped or
surrounded with quotes&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd ~/workspace
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Escaping whitespace&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd ~/workspace/ian&lt;span style="color:#ae81ff"&gt;\ &lt;/span&gt;weller
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd &lt;span style="color:#e6db74"&gt;&amp;#34;~/workspace/ian weller&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# This is technically two positional arguments being passed&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo Hello World
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="optional-arguments"&gt;Optional arguments&lt;/h2&gt;
&lt;p&gt;Arguments that are either prefixed with the short-form &lt;code&gt;-&lt;/code&gt; or the long-form
&lt;code&gt;--&lt;/code&gt;. Optional arguments usually change the functionality of the command they
are passed to. Short-form optional arguments can be separated out or combined.&lt;/p&gt;</description></item><item><title>Command Line Interface</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/command-line-interface/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/command-line-interface/</guid><description>&lt;h1 id="command-line-interface"&gt;Command Line Interface&lt;/h1&gt;
&lt;p&gt;A terminal used for interacting with an operating system. CLI applications can
be very useful for a variety of reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Interact with head-less servers&lt;/li&gt;
&lt;li&gt;String multiple commands together using STDIN and STDOUT&lt;/li&gt;
&lt;li&gt;Can be automated using scripting or schedulers&lt;/li&gt;
&lt;li&gt;Easy to write&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Command substitution</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/command-substitution/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/command-substitution/</guid><description>&lt;h1 id="command-substitution"&gt;Command-substitution&lt;/h1&gt;
&lt;p&gt;Command substitution replaces itself with the internal command.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python script.py --secret_key &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;cat ~/.secret_key&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Alternatively, process substitution can be used to instead create a temporary
file with the contents of the command, and then return the file path.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python script.py --file &amp;lt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;python generate_key.py&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Directory</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/directory/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/directory/</guid><description>&lt;h1 id="directory"&gt;Directory&lt;/h1&gt;
&lt;p&gt;Directories are files that store other files.&lt;/p&gt;
&lt;h2 id="path-special-characters"&gt;Path special characters&lt;/h2&gt;
&lt;p&gt;The following are pathing characters used for navigating directories:&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Special character&lt;/th&gt;
 &lt;th&gt;Description&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;/&lt;/td&gt;
 &lt;td&gt;Root path&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;.&lt;/td&gt;
 &lt;td&gt;Symlink to current directory&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;..&lt;/td&gt;
 &lt;td&gt;Symlink to the parent directory&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;~&lt;/td&gt;
 &lt;td&gt;User directory&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;~iweller&lt;/td&gt;
 &lt;td&gt;The user directory for iweller&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="top-level-directories"&gt;Top level directories&lt;/h2&gt;
&lt;p&gt;The following are common root level directories&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Directories&lt;/th&gt;
 &lt;th&gt;Description&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;/bin&lt;/td&gt;
 &lt;td&gt;binary programs&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;/etc&lt;/td&gt;
 &lt;td&gt;system configuration files&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;/home&lt;/td&gt;
 &lt;td&gt;home directory for users on the machine&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;/opt&lt;/td&gt;
 &lt;td&gt;third party software&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;/tmp&lt;/td&gt;
 &lt;td&gt;temporary space, cleared on reboot&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;/usr&lt;/td&gt;
 &lt;td&gt;user related programs&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;/var&lt;/td&gt;
 &lt;td&gt;log files&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>File</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/file/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/file/</guid><description>&lt;h1 id="file"&gt;File&lt;/h1&gt;
&lt;p&gt;In Linux, everything is considered a file. General files can be anything from
text, audio, pictures, etc. These can be in text or binary format. Additionally
there are &lt;a href="https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/directory"&gt;Directory&lt;/a&gt; files that serve as
containers for other files. Finally device files are any IO devices connected to
the computer such as disks, keyboards, etc.&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>git</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/git/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/git/</guid><description>&lt;h1 id="git"&gt;git&lt;/h1&gt;
&lt;h2 id="worktrees"&gt;worktrees&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git config remote.origin.fetch &lt;span style="color:#e6db74"&gt;&amp;#34;+refs/heads/*:refs/remotes/origin/*&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://jqlang.github.io/jq/manual/"&gt;jq manual&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>GUI</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/graphical-user-interface/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/graphical-user-interface/</guid><description>&lt;h1 id="graphical-user-interface"&gt;Graphical-User-Interface&lt;/h1&gt;
&lt;p&gt;A graphical &lt;a href="https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell"&gt;Shell&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>history</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/history/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/history/</guid><description>&lt;h1 id="history"&gt;history&lt;/h1&gt;
&lt;p&gt;History views the history of previously executed commands. Commands are kept in
the $HISTFILE and are not updated until the user logs out. Updating the
$HISTFILE can be forced using the command &lt;code&gt;history -w&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="reuse-commands"&gt;Reuse commands&lt;/h2&gt;
&lt;p&gt;Previously executed commands can be replayed using the &lt;code&gt;!&lt;/code&gt; operator. This can
work for both commands or specifying command parameters.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose -f ~/special-file.yml up -d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# replay the last command&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;!!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# replay specific command with last seen arguments&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;!docker-compose
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="hiding-from-history"&gt;Hiding from history&lt;/h2&gt;
&lt;p&gt;Adding a space to the front of any command will prevent it from being written to
the $HISTFILE.&lt;/p&gt;</description></item><item><title>jq</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/jq/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/jq/</guid><description>&lt;h1 id="jq"&gt;jq&lt;/h1&gt;
&lt;p&gt;jq is a command line tool for processing JSON. It is a single binary, written in
C, and has no runtime dependencies. This allows jq to be very fast, reliable,
consistent across all machines.&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://jqlang.github.io/jq/manual/"&gt;jq manual&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Kernel</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/kernel/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/kernel/</guid><description>&lt;h1 id="kernel"&gt;Kernel&lt;/h1&gt;</description></item><item><title>Linux</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/linux/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/linux/</guid><description>&lt;h1 id="linux"&gt;Linux&lt;/h1&gt;</description></item><item><title>Logical operators</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/logical-operators/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/logical-operators/</guid><description>&lt;h1 id="logical-operators"&gt;Logical-operators&lt;/h1&gt;
&lt;p&gt;Logical operators can be used as conditional logic for connecting commands
together&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Operator&lt;/th&gt;
 &lt;th&gt;Outcome&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;&amp;amp;&amp;amp;&lt;/td&gt;
 &lt;td&gt;Will run the next command if the first one succeeded&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;||&lt;/td&gt;
 &lt;td&gt;Will run the next command if the first one failed&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;;&lt;/td&gt;
 &lt;td&gt;Will run both commands regardless of the outcome&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Programs</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/programs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/programs/</guid><description>&lt;h1 id="programs"&gt;Programs&lt;/h1&gt;
&lt;p&gt;A program is a step by step procedure that is used for solving a computational
problem. Programs are different from
&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/algorithms"&gt;algorithms&lt;/a&gt; in that they are written during
the Software implementation phase. A program must be written in a programming
language and should be tested by the programmer.&lt;/p&gt;</description></item><item><title>pwd</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/pwd/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/pwd/</guid><description>&lt;h1 id="pwd"&gt;pwd&lt;/h1&gt;
&lt;p&gt;pwd is print working directory.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pwd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# /home/maladroitthief/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="related"&gt;Related&lt;/h2&gt;
&lt;p&gt;The environment variables &lt;code&gt;$PWD&lt;/code&gt; and &lt;code&gt;$OLDPWD&lt;/code&gt; can be used to reference the
current and previous working directory of the current session.&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Shell</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell/</guid><description>&lt;h1 id="shell"&gt;Shell&lt;/h1&gt;
&lt;p&gt;A graphical or text interface used to interact with the operating system.&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Shell expansion</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell-expansion/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell-expansion/</guid><description>&lt;h1 id="shell-expansion"&gt;Shell-expansion&lt;/h1&gt;
&lt;p&gt;Shell expansions are shortcuts that can save a significant amount of time typing.&lt;/p&gt;
&lt;h2 id="file-globbing"&gt;File globbing&lt;/h2&gt;
&lt;p&gt;Replacing a pattern in a file name or directory&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Expansion&lt;/th&gt;
 &lt;th&gt;Description&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;~&lt;/td&gt;
 &lt;td&gt;Expansion for current home directory&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;*&lt;/td&gt;
 &lt;td&gt;Matches &lt;code&gt;0 TO n&lt;/code&gt; characters&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;[ab]&lt;/td&gt;
 &lt;td&gt;Matches the characters &lt;code&gt;a OR b&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;[0-9]&lt;/td&gt;
 &lt;td&gt;Matches characters in the sequence &lt;code&gt;0 TO 9&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;[a-z]&lt;/td&gt;
 &lt;td&gt;Matches characters in the sequence &lt;code&gt;a TO z&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;^&lt;/td&gt;
 &lt;td&gt;Negate the expansion: &lt;code&gt;^[ab]&lt;/code&gt; is NOT a OR b&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;$&lt;/td&gt;
 &lt;td&gt;Match the end: &lt;code&gt;a$&lt;/code&gt; is ends in &lt;code&gt;a&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;(PATTERN1|PATTERN2)&lt;/td&gt;
 &lt;td&gt;Match &lt;code&gt;PATTERN1 OR PATTERN2&lt;/code&gt;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Shell script</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell-script/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell-script/</guid><description>&lt;h1 id="shell-script"&gt;Shell script&lt;/h1&gt;
&lt;h2 id="template"&gt;Template&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/usr/bin/env bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set -o errexit
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set -o nounset
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;set -o pipefail
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;[[&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TRACE-0&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;1&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;]]&lt;/span&gt;; &lt;span style="color:#66d9ef"&gt;then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;	set -o xtrace
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;fi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;[[&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;1-&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt;~ ^-*h&lt;span style="color:#f92672"&gt;(&lt;/span&gt;elp&lt;span style="color:#f92672"&gt;)&lt;/span&gt;?$ &lt;span style="color:#f92672"&gt;]]&lt;/span&gt;; &lt;span style="color:#66d9ef"&gt;then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; echo &lt;span style="color:#e6db74"&gt;&amp;#39;Usage: ./script.sh arg-one arg-two
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;This is an awesome bash script to make your life better.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; exit
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;fi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;dirname &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$0&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;main&lt;span style="color:#f92672"&gt;()&lt;/span&gt; &lt;span style="color:#f92672"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; echo &lt;span style="color:#66d9ef"&gt;do&lt;/span&gt; awesome stuff
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;main &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$@&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Shell variables</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell-variables/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/shell-variables/</guid><description>&lt;h1 id="shell-variables"&gt;Shell-variables&lt;/h1&gt;
&lt;p&gt;Shell variables are variables that are only applied to the current shell
instance.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;var&lt;span style="color:#f92672"&gt;=&lt;/span&gt;TestVar
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo $var
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;var&lt;span style="color:#e6db74"&gt;}&lt;/span&gt; &lt;span style="color:#75715e"&gt;# long format for expressions in strings&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="environment-variables"&gt;Environment variables&lt;/h2&gt;
&lt;p&gt;Environment variables are shell variables that are inherited by all system
processes. A shell variable can be promoted to an environment variable by
exporting it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export var&lt;span style="color:#f92672"&gt;=&lt;/span&gt;TestVar
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;All current environment variables can be viewed using &lt;code&gt;export&lt;/code&gt;&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Standard streams</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/standard-streams/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/standard-streams/</guid><description>&lt;h1 id="standard-streams"&gt;Standard-streams&lt;/h1&gt;
&lt;p&gt;Standard in, out, and error streams created when a command is run. They are
usefully for passing data between applications. Most CLI applications support
using &lt;code&gt;stdin&lt;/code&gt; as in input and will create both &lt;code&gt;stdout&lt;/code&gt; and &lt;code&gt;stderr&lt;/code&gt; outputs,
allowing multiple commands to be chained together.&lt;/p&gt;
&lt;p&gt;The streams behave like files and are given the following descriptors:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;stdin&lt;/code&gt;: 0&lt;/li&gt;
&lt;li&gt;&lt;code&gt;stdout&lt;/code&gt;: 1&lt;/li&gt;
&lt;li&gt;&lt;code&gt;stderr&lt;/code&gt;: 2&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These streams can be redirected using &lt;code&gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; where &lt;code&gt;&amp;gt;&lt;/code&gt; overwrites the file
and &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; appends to the end. To redirect a specific stream, prepend the
operators with the stream descriptor.&lt;/p&gt;</description></item><item><title>tee</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/tee/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/tee/</guid><description>&lt;h1 id="tee"&gt;tee&lt;/h1&gt;
&lt;p&gt;The tee command reads from &lt;a href="https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/standard-streams"&gt;&lt;code&gt;stdin&lt;/code&gt;&lt;/a&gt; and writes to both
&lt;code&gt;stdout&lt;/code&gt; and one or more files.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;df -h | tee disk_usage.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Terminal</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/terminal/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/terminal/</guid><description>&lt;h1 id="terminal"&gt;Terminal&lt;/h1&gt;
&lt;p&gt;A text based shell.&lt;/p&gt;
&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>xargs</title><link>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/xargs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://maladroit-dev-398201.gitlab.io/kb/computer-engineering/xargs/</guid><description>&lt;h1 id="xargs"&gt;xargs&lt;/h1&gt;
&lt;p&gt;The &lt;code&gt;xargs&lt;/code&gt; command will run a command multiple times.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Remove all .png files in the currect directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;find . -name &lt;span style="color:#e6db74"&gt;&amp;#34;*.png&amp;#34;&lt;/span&gt; | xargs rm -rf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="references"&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://maladroit-dev-398201.gitlab.io/kb/reference/command-line-a-modern-introduction"&gt;Command-Line-A-modern-introduction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>