<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://danielschwensen.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://danielschwensen.github.io/" rel="alternate" type="text/html" /><updated>2026-02-14T11:29:29+00:00</updated><id>https://danielschwensen.github.io/feed.xml</id><title type="html">My Personal Notes</title><subtitle>This blog serves as a dedicated space for the documentation of my explorations, with particular emphasis on Powershell and AWS, among other topics.
</subtitle><author><name>Daniel Schwensen</name></author><entry><title type="html">PowerShell and SQLite: Managing Data Efficiently</title><link href="https://danielschwensen.github.io/2026-02-14-PowerShell-and-SQLite/" rel="alternate" type="text/html" title="PowerShell and SQLite: Managing Data Efficiently" /><published>2026-02-14T00:00:00+00:00</published><updated>2026-02-14T00:00:00+00:00</updated><id>https://danielschwensen.github.io/PowerShell-and-SQLite</id><content type="html" xml:base="https://danielschwensen.github.io/2026-02-14-PowerShell-and-SQLite/"><![CDATA[<p>SQLite is a lightweight, file-based database that requires no server. Combined with PowerShell, it allows you to manage data quickly and easily – ideal for local projects, automation, or small datasets.</p>

<h3 id="prerequisites"><strong>Prerequisites</strong></h3>

<p>SQLite must be available on your system. Install it e.g. via Chocolatey:</p>

<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">choco</span><span class="w"> </span><span class="nx">install</span><span class="w"> </span><span class="nx">sqlite</span><span class="w">
</span></code></pre></div></div>

<p>Alternatively, you can download <code class="language-plaintext highlighter-rouge">sqlite3.exe</code> directly from <a href="https://www.sqlite.org/download.html">sqlite.org</a> and add it to your PATH.</p>

<h3 id="create-a-database-and-table"><strong>Create a Database and Table</strong></h3>

<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$DbPath</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s2">"C:\temp\books.db"</span><span class="w">

</span><span class="c"># Create database and table</span><span class="w">
</span><span class="n">sqlite3</span><span class="w"> </span><span class="nv">$DbPath</span><span class="w"> </span><span class="s2">"CREATE TABLE IF NOT EXISTS books (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    title TEXT NOT NULL,
    author TEXT NOT NULL,
    read INTEGER DEFAULT 0
);"</span><span class="w">
</span></code></pre></div></div>

<h3 id="insert-data"><strong>Insert Data</strong></h3>

<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">sqlite3</span><span class="w"> </span><span class="nv">$DbPath</span><span class="w"> </span><span class="s2">"INSERT INTO books (title, author, read) VALUES ('Friends, Lovers and the Big Terrible Thing', 'Matthew Perry', 1);"</span><span class="w">
</span><span class="n">sqlite3</span><span class="w"> </span><span class="nv">$DbPath</span><span class="w"> </span><span class="s2">"INSERT INTO books (title, author, read) VALUES ('C# in Depth', 'Jon Skeet', 0);"</span><span class="w">
</span></code></pre></div></div>

<h3 id="query-data"><strong>Query Data</strong></h3>

<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># List all books</span><span class="w">
</span><span class="n">sqlite3</span><span class="w"> </span><span class="nt">-header</span><span class="w"> </span><span class="nt">-column</span><span class="w"> </span><span class="nv">$DbPath</span><span class="w"> </span><span class="s2">"SELECT * FROM books;"</span><span class="w">
</span></code></pre></div></div>

<p>Output:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>id  title                                          author          read
--  ---------------------------------------------  --------------  ----
1   Friends, Lovers and the Big Terrible Thing     Matthew Perry   1
2   C# in Depth                                    Jon Skeet       0
</code></pre></div></div>

<h3 id="processing-query-results-in-powershell"><strong>Processing Query Results in PowerShell</strong></h3>

<p>The output of <code class="language-plaintext highlighter-rouge">sqlite3</code> can be directly converted into PowerShell variables:</p>

<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Use CSV mode for easy parsing</span><span class="w">
</span><span class="nv">$Results</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">sqlite3</span><span class="w"> </span><span class="nt">-csv</span><span class="w"> </span><span class="nt">-header</span><span class="w"> </span><span class="nv">$DbPath</span><span class="w"> </span><span class="s2">"SELECT title, author FROM books WHERE read = 0;"</span><span class="w">
</span><span class="nv">$Books</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">$Results</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">ConvertFrom-Csv</span><span class="w">

</span><span class="kr">foreach</span><span class="w"> </span><span class="p">(</span><span class="nv">$Book</span><span class="w"> </span><span class="kr">in</span><span class="w"> </span><span class="nv">$Books</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="n">Write-Host</span><span class="w"> </span><span class="s2">"Not yet read: </span><span class="si">$(</span><span class="nv">$Book</span><span class="o">.</span><span class="nf">title</span><span class="si">)</span><span class="s2"> by </span><span class="si">$(</span><span class="nv">$Book</span><span class="o">.</span><span class="nf">author</span><span class="si">)</span><span class="s2">"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<h3 id="update-and-delete-data"><strong>Update and Delete Data</strong></h3>

<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># Mark book as read</span><span class="w">
</span><span class="n">sqlite3</span><span class="w"> </span><span class="nv">$DbPath</span><span class="w"> </span><span class="s2">"UPDATE books SET read = 1 WHERE title = 'C# in Depth';"</span><span class="w">

</span><span class="c"># Delete an entry</span><span class="w">
</span><span class="n">sqlite3</span><span class="w"> </span><span class="nv">$DbPath</span><span class="w"> </span><span class="s2">"DELETE FROM books WHERE id = 2;"</span><span class="w">
</span></code></pre></div></div>

<h3 id="helper-function-for-repeated-queries"><strong>Helper Function for Repeated Queries</strong></h3>

<p>To simplify repeated calls, a small wrapper function comes in handy:</p>

<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kr">function</span><span class="w"> </span><span class="nf">Invoke-Sqlite</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="kr">param</span><span class="p">(</span><span class="w">
        </span><span class="p">[</span><span class="n">string</span><span class="p">]</span><span class="nv">$Database</span><span class="p">,</span><span class="w">
        </span><span class="p">[</span><span class="n">string</span><span class="p">]</span><span class="nv">$Query</span><span class="w">
    </span><span class="p">)</span><span class="w">
    </span><span class="nv">$Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">sqlite3</span><span class="w"> </span><span class="nt">-csv</span><span class="w"> </span><span class="nt">-header</span><span class="w"> </span><span class="nv">$Database</span><span class="w"> </span><span class="nv">$Query</span><span class="w">
    </span><span class="kr">if</span><span class="w"> </span><span class="p">(</span><span class="nv">$Output</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w">
        </span><span class="kr">return</span><span class="w"> </span><span class="nv">$Output</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">ConvertFrom-Csv</span><span class="w">
    </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">

</span><span class="c"># Usage</span><span class="w">
</span><span class="nv">$AllBooks</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Invoke-Sqlite</span><span class="w"> </span><span class="nt">-Database</span><span class="w"> </span><span class="nv">$DbPath</span><span class="w"> </span><span class="nt">-Query</span><span class="w"> </span><span class="s2">"SELECT * FROM books;"</span><span class="w">
</span><span class="nv">$AllBooks</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">Format-Table</span><span class="w">
</span></code></pre></div></div>]]></content><author><name>Daniel Schwensen</name></author><category term="Scripting" /><category term="Powershell" /><category term="SQLite" /><category term="database" /><summary type="html"><![CDATA[SQLite is a lightweight, file-based database that requires no server. Combined with PowerShell, it allows you to manage data quickly and easily – ideal for local projects, automation, or small datasets.]]></summary></entry><entry><title type="html">Managing Installed Applications with Homebrew on macOS</title><link href="https://danielschwensen.github.io/2025-06-27-managing_applications_homebrew_on_macOS/" rel="alternate" type="text/html" title="Managing Installed Applications with Homebrew on macOS" /><published>2025-06-27T00:00:00+00:00</published><updated>2025-06-27T00:00:00+00:00</updated><id>https://danielschwensen.github.io/managing_applications_homebrew_on_macOS</id><content type="html" xml:base="https://danielschwensen.github.io/2025-06-27-managing_applications_homebrew_on_macOS/"><![CDATA[<p>Homebrew is a powerful package manager for macOS that allows users to install and manage software efficiently. In this article, we’ll explore how to list installed applications and remove unnecessary ones using Homebrew.</p>

<p>Listing Installed Packages</p>

<p>To see what software is installed via Homebrew, run:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew list

</code></pre></div></div>
<p>This command displays all installed formulae (command-line tools and libraries). If you also want to see GUI applications installed via Homebrew Cask, use:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew list --cask

</code></pre></div></div>
<p>This will show a list of applications installed using Cask, such as web browsers, terminal emulators, and text editors.</p>

<p>Uninstalling Unnecessary Applications</p>

<p>To remove an installed package, use:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew uninstall &lt;package-name&gt;

</code></pre></div></div>
<p>For example, to remove Visual Studio Code:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew uninstall --cask visual-studio-code

</code></pre></div></div>
<p>If you want to remove multiple packages at once:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew uninstall --cask iterm2 kap keka

</code></pre></div></div>
<p>To remove all installed Cask applications:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew list --cask | xargs brew uninstall --cask

</code></pre></div></div>

<p>Cleaning Up</p>

<p>After uninstalling applications, it’s a good idea to free up disk space with:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew cleanup

</code></pre></div></div>
<p>This removes outdated versions and unnecessary files.
By following these steps, you can efficiently manage your macOS applications using Homebrew, ensuring your system stays clean and optimized.</p>]]></content><author><name>Daniel Schwensen</name></author><category term="blog" /><category term="Homebrew" /><category term="macOS" /><summary type="html"><![CDATA[Homebrew is a powerful package manager for macOS that allows users to install and manage software efficiently. In this article, we’ll explore how to list installed applications and remove unnecessary ones using Homebrew.]]></summary></entry><entry><title type="html">Resolving Windows Line Endings (CRLF) Issues in Shell Scripts</title><link href="https://danielschwensen.github.io/2025-05-25-Windows-Line-Endings/" rel="alternate" type="text/html" title="Resolving Windows Line Endings (CRLF) Issues in Shell Scripts" /><published>2025-05-25T00:00:00+00:00</published><updated>2025-05-25T00:00:00+00:00</updated><id>https://danielschwensen.github.io/Windows-Line-Endings</id><content type="html" xml:base="https://danielschwensen.github.io/2025-05-25-Windows-Line-Endings/"><![CDATA[<p>This note outlines three quick methods—using dos2unix, sed, or an editor conversion—to ensure the script runs without errors.</p>

<p>When you run a shell script on a Unix-like system and see an error like:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>zsh: ./script.sh: bad interpreter: /bin/bash^M: no such file or directory
</code></pre></div></div>
<p>this indicates that your script was saved with Windows line endings (CRLF) instead of Unix line endings (LF). The extra ^M character causes the interpreter path to be misread.</p>

<p>Why It Happens</p>

<ul>
  <li>Windows vs. Unix: Windows uses CRLF (\r\n) for line breaks, while Unix-like systems use LF (\n).</li>
  <li>Impact on Scripts: The extra carriage return (\r) is appended to the shebang line (e.g., /bin/bash^M), causing the system to fail in locating the correct interpreter.</li>
</ul>

<p>How to Fix It</p>

<ol>
  <li>Using dos2unix</li>
</ol>

<p>If you have dos2unix installed, simply run:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dos2unix script.sh
</code></pre></div></div>
<p>This command converts the file to Unix line endings.</p>

<ol>
  <li>Using sed</li>
</ol>

<p>You can also remove carriage returns using sed:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sed -i 's/\r$//' script.sh
</code></pre></div></div>
<p>This command edits the file in place, removing the \r at the end of each line.</p>

<ol>
  <li>Using a Text Editor</li>
</ol>

<p>Open the script in an editor that supports different line endings (e.g., VS Code, Sublime Text, or Notepad++), and convert the file format to Unix (LF). Save the file afterwards.</p>

<hr />
<p>By ensuring your shell scripts use Unix line endings, you can avoid interpreter errors and ensure smooth execution across different environments.</p>]]></content><author><name>Daniel Schwensen</name></author><category term="blog" /><category term="linux" /><category term="Linux" /><category term="grep" /><summary type="html"><![CDATA[This note outlines three quick methods—using dos2unix, sed, or an editor conversion—to ensure the script runs without errors.]]></summary></entry><entry><title type="html">Extracting a Subdirectory with Git Subtree Split</title><link href="https://danielschwensen.github.io/2025-04-06-Extracting_a_Subdirectory_with_Git_Subtree_Split/" rel="alternate" type="text/html" title="Extracting a Subdirectory with Git Subtree Split" /><published>2025-04-06T00:00:00+00:00</published><updated>2025-04-06T00:00:00+00:00</updated><id>https://danielschwensen.github.io/Extracting_a_Subdirectory_with_Git_Subtree_Split</id><content type="html" xml:base="https://danielschwensen.github.io/2025-04-06-Extracting_a_Subdirectory_with_Git_Subtree_Split/"><![CDATA[<p>When you need to split a subdirectory from a larger repository while keeping its commit history, Git Subtree Split is a simple built-in solution.</p>

<ol>
  <li>Update Your Local Repository</li>
</ol>

<p>Before starting, ensure your repository is up-to-date. If you have any pending changes, commit them and pull the latest updates:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git pull origin main

</code></pre></div></div>
<p>(Replace <code class="language-plaintext highlighter-rouge">main</code> with your branch name if needed.)</p>

<ol>
  <li>Create a New Branch for the Subdirectory</li>
</ol>

<p>Use the subtree split command to extract your subdirectory (e.g., <code class="language-plaintext highlighter-rouge">WizzadPlus2022</code>) into a new branch:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git subtree split --prefix=WizzadPlus2022 -b wizzadplus2022-only

</code></pre></div></div>
<ul>
  <li><code class="language-plaintext highlighter-rouge">--prefix=WizzadPlus2022</code>: Specifies the directory to extract.</li>
  <li><code class="language-plaintext highlighter-rouge">-b wizzadplus2022-only</code>: Creates a new branch containing only the commits affecting that directory.</li>
</ul>

<ol>
  <li>Set Up a New Repository</li>
</ol>

<p>Create a new, empty repository on your favorite Git hosting service (GitHub, GitLab, etc.). Note the repository URL (e.g., git@github.com:<code class="language-plaintext highlighter-rouge">yourUsername/WizzadPlus2022.git</code>).</p>

<ol>
  <li>Push the New Branch to the New Repository</li>
</ol>

<p>Add the new remote and push your branch:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git remote add wizzadplus2022 &lt;NEW_REPO_URL&gt;
git push wizzadplus2022 wizzadplus2022-only:main

</code></pre></div></div>
<p>This command pushes your new branch as the <code class="language-plaintext highlighter-rouge">main</code> branch in the new repository.</p>]]></content><author><name>Daniel Schwensen</name></author><category term="development" /><category term="Git" /><summary type="html"><![CDATA[When you need to split a subdirectory from a larger repository while keeping its commit history, Git Subtree Split is a simple built-in solution.]]></summary></entry><entry><title type="html">Install Homebrew on macOS Ventura</title><link href="https://danielschwensen.github.io/2025-03-16-install_homebrew_on_macOS/" rel="alternate" type="text/html" title="Install Homebrew on macOS Ventura" /><published>2025-03-16T00:00:00+00:00</published><updated>2025-03-16T00:00:00+00:00</updated><id>https://danielschwensen.github.io/install_homebrew_on_macOS</id><content type="html" xml:base="https://danielschwensen.github.io/2025-03-16-install_homebrew_on_macOS/"><![CDATA[<p>Homebrew is a free and open-source package manager that simplifies the installation of software on macOS and Linux.  It allows users to install, update, and manage software packages directly from the command line, making it easier to handle dependencies and maintain system cleanliness.</p>

<h1 id="installing-homebrew-on-macos-13-ventura">Installing Homebrew on macOS 13 Ventura</h1>

<p>To install Homebrew on macOS 13 Ventura, follow these steps:
Install Xcode Command Line Tools: Execute:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>xcode-select --install
</code></pre></div></div>
<p>A prompt will appear; click ‘Install’ to proceed.</p>

<p>Install Homebrew: Run:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
</code></pre></div></div>
<p>This script will download and install Homebrew.</p>

<p>Adding Homebrew to Your PATH
To ensure that Homebrew and its installed packages are accessible from the terminal, you need to add Homebrew to your shell’s PATH. This step is crucial for the proper functioning of Homebrew. Here’s how to do it: 
	1.	Determine Your Shell:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>echo $SHELL
</code></pre></div></div>

<p>If the output includes /bin/zsh, you’re using zsh. If it shows /bin/bash, you’re using bash.</p>

<p>Add Homebrew to the PATH:
For zsh Users:
Open (or create) your .zprofile file:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>nano ~/.zprofile
</code></pre></div></div>

<p>Add the following line to the file:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>eval "$(/opt/homebrew/bin/brew shellenv)"
</code></pre></div></div>

<p>For bash Users:
Open (or create) your .bash_profile file:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>nano ~/.bash_profile
</code></pre></div></div>

<p>Add the following line to the file:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>eval "$(/opt/homebrew/bin/brew shellenv)"
</code></pre></div></div>

<p>Apply the Changes:
To immediately apply the changes without restarting the terminal, run:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>source ~/.zprofile
</code></pre></div></div>
<p>or</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>source ~/.bash_profile
</code></pre></div></div>
<p>depending on your shell.</p>

<p>By following these steps, Homebrew will be added to your PATH, ensuring that you can use the brew command and access the software installed via Homebrew seamlessly.</p>

<h1 id="verify-installation">Verify Installation</h1>

<p>After installation, confirm that Homebrew is set up correctly by running:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>brew doctor
</code></pre></div></div>
<p>If everything is properly installed, you’ll see the message “Your system is ready to brew.”</p>

<h1 id="uninstalling-homebrew">Uninstalling Homebrew</h1>

<p>If you need to uninstall Homebrew, execute the following command in Terminal:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
</code></pre></div></div>
<p>This command will remove Homebrew and all installed packages from your system.</p>]]></content><author><name>Daniel Schwensen</name></author><category term="blog" /><category term="Homebrew" /><category term="macOS" /><summary type="html"><![CDATA[Homebrew is a free and open-source package manager that simplifies the installation of software on macOS and Linux. It allows users to install, update, and manage software packages directly from the command line, making it easier to handle dependencies and maintain system cleanliness.]]></summary></entry><entry><title type="html">Quick Linux Desktop Shutdown and Custom Alias Setup</title><link href="https://danielschwensen.github.io/2025-02-23-Quick-Linux-Desktop-Shutdown-and-Custom-Alias-Setup/" rel="alternate" type="text/html" title="Quick Linux Desktop Shutdown and Custom Alias Setup" /><published>2025-02-23T00:00:00+00:00</published><updated>2025-02-23T00:00:00+00:00</updated><id>https://danielschwensen.github.io/Quick-Linux-Desktop-Shutdown-and-Custom-Alias-Setup</id><content type="html" xml:base="https://danielschwensen.github.io/2025-02-23-Quick-Linux-Desktop-Shutdown-and-Custom-Alias-Setup/"><![CDATA[<p>Quick reference for shutting down Linux systems via terminal - both standard commands and how to create a custom shortcut (alias ‘sd’) for faster access. Added this because I always forget the exact shutdown commands and the alias setup steps.</p>

<p>The quickest ways to shut down your Linux system via terminal:</p>
<ul>
  <li>shutdown now - safest method, properly saves data</li>
  <li>poweroff - short command, similar to shutdown now</li>
  <li>init 0 - classic Unix command, works on all systems</li>
  <li>halt - stops all processes and system</li>
</ul>

<p>Create Custom Alias</p>

<p>To set up a convenient shutdown alias:</p>
<ol>
  <li>Open .bashrc:
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>nano ~/.bashrc
</code></pre></div>    </div>
  </li>
  <li>Add at the end:
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>alias sd='shutdown now'
</code></pre></div>    </div>
  </li>
  <li>Save file: CTRL + O, ENTER, CTRL + X</li>
  <li>Reload .bashrc:
    <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>source ~/.bashrc
</code></pre></div>    </div>
    <p>Now you can simply type sd to shutdown your system.
Pro tip: Consider using alias sd=’sudo shutdown now’ if you always need root privileges.</p>
  </li>
</ol>]]></content><author><name>Daniel Schwensen</name></author><category term="blog" /><category term="linux" /><category term="Linux" /><summary type="html"><![CDATA[Quick reference for shutting down Linux systems via terminal - both standard commands and how to create a custom shortcut (alias ‘sd’) for faster access. Added this because I always forget the exact shutdown commands and the alias setup steps.]]></summary></entry><entry><title type="html">Managing Packages with Chocolatey on Windows</title><link href="https://danielschwensen.github.io/2025-01-04-Managing-Packages-with-Chocolatey-on-Windows/" rel="alternate" type="text/html" title="Managing Packages with Chocolatey on Windows" /><published>2025-01-04T00:00:00+00:00</published><updated>2025-01-04T00:00:00+00:00</updated><id>https://danielschwensen.github.io/Managing-Packages-with-Chocolatey-on-Windows</id><content type="html" xml:base="https://danielschwensen.github.io/2025-01-04-Managing-Packages-with-Chocolatey-on-Windows/"><![CDATA[<p>Chocolatey is a powerful package manager for Windows that simplifies software installation and management.</p>

<p>Prerequisites</p>

<ul>
  <li>Run PowerShell or Command Prompt as Administrator</li>
  <li>Installation directory: <code class="language-plaintext highlighter-rouge">C:\ProgramData\chocolatey</code></li>
</ul>

<p>Essential Commands</p>

<p>Installation &amp; Updates</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Install a package
choco install &lt;package-name&gt;

# Update a specific package
choco upgrade &lt;package-name&gt;

# Update all packages
choco upgrade all -y
</code></pre></div></div>

<p>Package Management</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># List installed packages
choco list

# Check for outdated packages
choco outdated

# Search for packages
choco search &lt;package-name&gt;

# Get package information
choco info &lt;package-name&gt;

# Uninstall a package
choco uninstall &lt;package-name&gt;
</code></pre></div></div>

<p>Example: Managing Terraform</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Install Terraform
choco install terraform

# Check Terraform version
terraform --version

# or
choco list terraform

# Update Terraform
choco upgrade terraform
</code></pre></div></div>

<p>Tips</p>

<ol>
  <li>Use <code class="language-plaintext highlighter-rouge">-y</code> flag to automatically confirm actions</li>
  <li>Pin important packages to prevent automatic updates:</li>
  <li>Keep Chocolatey updated:</li>
  <li>Restart terminal after installing new packages</li>
  <li>Use <code class="language-plaintext highlighter-rouge">--what-if</code> to preview changes before execution</li>
</ol>

<p>Understanding Shims</p>

<p>Chocolatey uses shims to make command-line programs accessible globally. A shim is a small file that redirects to the actual executable of an installed program. They are automatically created in <code class="language-plaintext highlighter-rouge">C:\ProgramData\chocolatey\bin</code>.
Benefits of shims:</p>
<ul>
  <li>Makes commands available immediately in any terminal</li>
  <li>Allows running programs without knowing their exact installation path</li>
  <li>Enables seamless updates without changing PATH variables
Example: When you install Terraform via Chocolatey, it creates a shim that allows you to run terraform from any location, while the actual executable might be in C:\ProgramData\chocolatey\lib\terraform\tools.</li>
</ul>]]></content><author><name>Daniel Schwensen</name></author><category term="blog" /><category term="Windows" /><category term="Chocolatey" /><summary type="html"><![CDATA[Chocolatey is a powerful package manager for Windows that simplifies software installation and management.]]></summary></entry><entry><title type="html">Ubuntu Firewall Setup and Security Checks</title><link href="https://danielschwensen.github.io/2024-12-01-Ubuntu-Firewall-Setup-and-Security-Checks/" rel="alternate" type="text/html" title="Ubuntu Firewall Setup and Security Checks" /><published>2024-12-01T00:00:00+00:00</published><updated>2024-12-01T00:00:00+00:00</updated><id>https://danielschwensen.github.io/Ubuntu-Firewall-Setup-and-Security-Checks</id><content type="html" xml:base="https://danielschwensen.github.io/2024-12-01-Ubuntu-Firewall-Setup-and-Security-Checks/"><![CDATA[<p>Basic commands and steps for securing Ubuntu using UFW firewall, setting up automated security updates, and implementing daily security checks with log rotation.</p>

<h1 id="1-check-firewall-status">1. Check Firewall Status</h1>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo ufw status

sudo ufw status verbose

sudo ufw status numbered
</code></pre></div></div>

<h1 id="2-install-and-enable-ufw">2. Install and Enable UFW</h1>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Check if installed
dpkg -l | grep ufw
# or

which ufw

# Install if needed
sudo apt update
sudo apt install ufw

# Enable firewall
sudo ufw enable
</code></pre></div></div>

<h1 id="3-basic-ufw-configuration">3. Basic UFW Configuration</h1>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Default policies
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Common services
sudo ufw allow ssh        # Port 22
sudo ufw allow 80/tcp     # HTTP
sudo ufw allow 443/tcp    # HTTPS
</code></pre></div></div>

<h1 id="4-system-security-check-commands">4. System Security Check Commands</h1>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Check open ports
sudo ss -tulpn

# Check login attempts
sudo last
sudo grep "Failed password" /var/log/auth.log

# Check sudo usage
sudo grep "sudo" /var/log/auth.log
</code></pre></div></div>

<h1 id="5-enable-automatic-security-updates">5. Enable Automatic Security Updates</h1>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades
</code></pre></div></div>

<h1 id="6-daily-security-check-script">6. Daily Security Check Script</h1>

<p>Create a script in <code class="language-plaintext highlighter-rouge">/etc/cron.daily/security-check</code> that:</p>
<ul>
  <li>Monitors failed login attempts</li>
  <li>Checks network connections</li>
  <li>Tracks system resources</li>
  <li>Rotates logs (keeps last 10 backups)</li>
  <li>Creates daily reports in <code class="language-plaintext highlighter-rouge">/var/log/security-check.log</code></li>
</ul>

<h1 id="notes">Notes:</h1>

<ul>
  <li>Default Ubuntu installation doesn’t enable UFW by default</li>
  <li>Basic system is secure even without UFW if no services are installed</li>
  <li>Monitor auth.log for suspicious activities</li>
  <li>GUI configuration available through GUFW: <code class="language-plaintext highlighter-rouge">sudo apt install gufw</code>
<img src="https://danielschwensen.github.io/assets/2024/gufw.png" alt="GUFW" /></li>
  <li>Regularly check system logs</li>
  <li>Keep system updated: <code class="language-plaintext highlighter-rouge">sudo apt update &amp;&amp; sudo apt upgrade</code></li>
  <li>Monitor open ports and running services</li>
</ul>]]></content><author><name>Daniel Schwensen</name></author><category term="blog" /><category term="linux" /><category term="Linux" /><category term="Ubuntu" /><category term="firewall" /><category term="security" /><summary type="html"><![CDATA[Basic commands and steps for securing Ubuntu using UFW firewall, setting up automated security updates, and implementing daily security checks with log rotation.]]></summary></entry><entry><title type="html">Understanding Linux Shells and Configuration</title><link href="https://danielschwensen.github.io/2024-11-17-Understanding-Linux-Shells-and-Configuration/" rel="alternate" type="text/html" title="Understanding Linux Shells and Configuration" /><published>2024-11-17T00:00:00+00:00</published><updated>2024-11-17T00:00:00+00:00</updated><id>https://danielschwensen.github.io/Understanding-Linux-Shells-and-Configuration</id><content type="html" xml:base="https://danielschwensen.github.io/2024-11-17-Understanding-Linux-Shells-and-Configuration/"><![CDATA[<p>How to check which shell I’m using and where the important config files are located.</p>

<h1 id="which-shell-am-i-using">Which shell am I using?</h1>

<p>Check your current shell using any of these commands:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>echo $SHELL      # Shows path to default shell

echo $0         # Shows shell name

cat /etc/shells # Lists all available shells
</code></pre></div></div>

<h1 id="changing-your-shell">Changing your shell</h1>

<p>Change your default shell using:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>chsh -s /bin/zsh  # Change to ZSH

chsh -s /bin/bash # Change to Bash
</code></pre></div></div>
<p>Changes take effect after next login.</p>

<p>Shell Configuration Files</p>

<p>Key configuration files and their purposes:</p>
<ol>
  <li>~/.bashrc
    <ul>
      <li>For interactive non-login shells</li>
      <li>Contains: aliases, functions, prompt settings</li>
      <li>Used in most terminal windows you open</li>
    </ul>
  </li>
  <li>~/.profile
    <ul>
      <li>For login shells</li>
      <li>Contains: environment variables, PATH settings</li>
      <li>Read by multiple shells, not just bash</li>
    </ul>
  </li>
  <li>/etc/passwd
    <ul>
      <li>Stores default shell for each user</li>
      <li>Format: <code class="language-plaintext highlighter-rouge">username:x:uid:gid:comment:home:shell</code></li>
      <li>Don’t edit directly; use <code class="language-plaintext highlighter-rouge">chsh</code> instead</li>
    </ul>
  </li>
</ol>

<h1 id="loading-order">Loading Order</h1>

<p>Login Shell:</p>
<ol>
  <li>/etc/profile</li>
  <li>First found of: ~/.profile, ~/.bash_login, or ~/.bash_profile</li>
  <li>On exit: ~/.bash_logout</li>
</ol>

<p>Non-Login Shell (regular terminal):</p>
<ol>
  <li>/etc/bash.bashrc</li>
  <li>~/.bashrc</li>
</ol>

<p>On Ubuntu, ~/.bashrc is the main configuration file you’ll work with for most shell customizations.</p>]]></content><author><name>Daniel Schwensen</name></author><category term="blog" /><category term="linux" /><category term="Linux" /><category term="shell" /><category term="bash" /><summary type="html"><![CDATA[How to check which shell I’m using and where the important config files are located.]]></summary></entry><entry><title type="html">How to Change the Creation Timestamp of JPG Files with PowerShell?</title><link href="https://danielschwensen.github.io/2024-09-12-How-to-Change-the-Creation-Timestampwith-Powershell/" rel="alternate" type="text/html" title="How to Change the Creation Timestamp of JPG Files with PowerShell?" /><published>2024-09-12T00:00:00+00:00</published><updated>2024-09-12T00:00:00+00:00</updated><id>https://danielschwensen.github.io/How-to-Change-the-Creation-Timestampwith-Powershell</id><content type="html" xml:base="https://danielschwensen.github.io/2024-09-12-How-to-Change-the-Creation-Timestampwith-Powershell/"><![CDATA[<p>Do you need to change the creation timestamps of JPG files? 
PowerShell offers a quick and efficient way to do this.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$targetPath = "F:\Downloads\Target"

$newCreationTime = "2001-09-11 00:00:00"

Get-ChildItem -Path $targetPath -Filter *.jpg | ForEach-Object {
    $_.CreationTime = $newCreationTime
    Write-Host "CreationTime for file $($_.Name) was changed to $newCreationTime"
}
</code></pre></div></div>

<p>You can also change other timestamps like LastWriteTime or LastAccessTime by using the corresponding property:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$_.LastWriteTime = $newCreationTime
</code></pre></div></div>]]></content><author><name>Daniel Schwensen</name></author><category term="Scripting" /><category term="Powershell" /><summary type="html"><![CDATA[Do you need to change the creation timestamps of JPG files? PowerShell offers a quick and efficient way to do this.]]></summary></entry></feed>