<?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:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Bello's Technical Blog | Techstack Media Blog]]></title><description><![CDATA[YouTuber | Software Engineer | Freelancer | Tech Blogger | Online Instructor. Specialization: JavaScript Stack | Node Stack]]></description><link>https://techstack.hashnode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1641008910904/b3qYUHO-u.png</url><title>Bello&apos;s Technical Blog | Techstack Media Blog</title><link>https://techstack.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Nov 2026 23:31:48 GMT</lastBuildDate><atom:link href="https://techstack.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Git and GitHub CLI: A Complete Workflow Guide]]></title><description><![CDATA[Learn how to use Git and GitHub CLI, and fully clean up configurations, credentials, and SSH keys before reinstalling from scratch.]]></description><link>https://techstack.hashnode.dev/git-and-github-cli-a-complete-workflow-guide</link><guid isPermaLink="true">https://techstack.hashnode.dev/git-and-github-cli-a-complete-workflow-guide</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[cli]]></category><category><![CDATA[Homebrew]]></category><category><![CDATA[terminal]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Wed, 16 Apr 2025 20:14:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1744829897749/969722ca-0bd4-44ea-85cc-7490deb56226.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Learn how to fully clean up Git and GitHub CLI before reinstalling. This complete guide covers credential removal, SSH key management, Git initialization, Codespaces setup, Git configuration, and advanced terminal shortcuts.</p>
<h2 id="heading-cleaning-up-git-and-github-cli-before-reinstallation"><strong>Cleaning Up Git and GitHub CLI Before Reinstallation</strong></h2>
<p>Before reinstalling Git or GitHub CLI (<code>gh</code>), it’s a good practice to ensure all previous configurations and credentials are fully removed. Here's how to do a complete cleanup:</p>
<h3 id="heading-logout-from-github-cli">📉 Logout from GitHub CLI</h3>
<pre><code class="lang-bash">gh auth <span class="hljs-built_in">logout</span> -h github.com
</code></pre>
<p>This logs you out of GitHub via GitHub CLI.</p>
<h3 id="heading-remove-git-credentials-and-configurations">🔍 Remove Git Credentials and Configurations</h3>
<pre><code class="lang-bash">rm ~/.git-credentials           <span class="hljs-comment"># Deletes saved HTTPS credentials</span>
rm ~/.gitconfig                <span class="hljs-comment"># Removes global Git configuration file</span>
</code></pre>
<h3 id="heading-clear-ssh-keys-optional">🔐 Clear SSH Keys (Optional)</h3>
<pre><code class="lang-bash">rm -rf ~/.ssh/                 <span class="hljs-comment"># Removes all SSH keys and configurations</span>
</code></pre>
<p><strong>Note</strong>: Only do this if you're sure you want to delete all SSH keys.</p>
<h3 id="heading-clear-github-cli-config">🔢 Clear GitHub CLI Config</h3>
<pre><code class="lang-bash">rm -rf ~/.config/gh            <span class="hljs-comment"># Deletes GitHub CLI config directory</span>
</code></pre>
<h3 id="heading-reject-any-remaining-credentials">❌ Reject Any Remaining Credentials</h3>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"url=https://github.com"</span> | git credential reject
</code></pre>
<p>If that doesn't work:</p>
<pre><code class="lang-bash">git credential reject https://github.com
</code></pre>
<hr />
<h2 id="heading-1-github-cli-gh-and-authentication">1. GitHub CLI (gh) and Authentication</h2>
<p>The <code>gh</code> command-line tool allows you to interact with GitHub directly from your terminal. It simplifies repo management, pull requests, issues, and CI/CD workflows.</p>
<h3 id="heading-authenticate-github-cli">🔐 Authenticate GitHub CLI</h3>
<pre><code class="lang-bash">gh auth login
</code></pre>
<p>Once configured, you can see your Git global settings:</p>
<pre><code class="lang-bash">git config --list --global
</code></pre>
<hr />
<h2 id="heading-2-initializing-a-git-repository">2. Initializing a Git Repository</h2>
<h3 id="heading-git-initialization-git-init">⚖️ Git Initialization (<code>git init</code>)</h3>
<pre><code class="lang-bash">git init
ls -la            <span class="hljs-comment"># Lists all files including hidden ones</span>
ls -la .git        <span class="hljs-comment"># View the .git directory</span>
</code></pre>
<h3 id="heading-understanding-the-git-folder">🗂️ Understanding the <code>.git</code> Folder</h3>
<ul>
<li><p><code>HEAD</code>: Points to the current branch.</p>
</li>
<li><p><code>config</code>: Stores repository settings.</p>
</li>
<li><p><code>refs/</code>: Contains references to commits (branches and tags).</p>
</li>
<li><p><code>objects/</code>: Stores commit objects.</p>
</li>
<li><p><code>hooks/</code>: Scripts that trigger on Git events.</p>
</li>
</ul>
<p>View contents:</p>
<pre><code class="lang-bash">cat .git/HEAD
cat .git/config
ls -la .git/refs/heads/   <span class="hljs-comment"># See available branches</span>
ls -la .git/objects/
</code></pre>
<h3 id="heading-staging-git-add">✅ Staging (<code>git add &lt;file&gt;</code>)</h3>
<pre><code class="lang-bash">git add file.txt
</code></pre>
<p>Git updates:</p>
<pre><code class="lang-bash">.git/index  <span class="hljs-comment"># The Staging Area</span>
</code></pre>
<p>List staged files:</p>
<pre><code class="lang-bash">git ls-files --stage
</code></pre>
<h3 id="heading-committing-git-commit-m-message">📝 Committing (<code>git commit -m "message"</code>)</h3>
<pre><code class="lang-bash">git commit -m <span class="hljs-string">"Initial commit"</span>
</code></pre>
<p>Git writes data into:</p>
<pre><code class="lang-bash">.git/objects/
├── info/
├── pack/
├── 9f/2345abc...  <span class="hljs-comment"># Blob: actual file content</span>
├── 7a/6bcd123...  <span class="hljs-comment"># Tree: directory structure</span>
├── <span class="hljs-built_in">fc</span>/67de89...   <span class="hljs-comment"># Commit object with metadata</span>
</code></pre>
<p>Inspect commit object:</p>
<pre><code class="lang-bash">git cat-file -p &lt;commit-hash&gt;
</code></pre>
<h3 id="heading-connecting-remote-git-remote-add-origin">🔗 Connecting Remote (<code>git remote add origin &lt;url&gt;</code>)</h3>
<pre><code class="lang-bash">git remote add origin https://github.com/your/repo.git
</code></pre>
<p>This updates:</p>
<pre><code class="lang-bash">.git/config  <span class="hljs-comment"># Stores remote origin URL</span>
</code></pre>
<h3 id="heading-pushing-changes-git-push">↗️ Pushing Changes (<code>git push</code>)</h3>
<pre><code class="lang-bash">git push origin main
</code></pre>
<p>Push sends commits to the remote repository and updates:</p>
<pre><code class="lang-bash">.git/refs/remotes/  <span class="hljs-comment"># Tracks state of remotes</span>
</code></pre>
<p>If you're interested in understanding Git internals, refer to the <a target="_blank" href="https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain">Git Internals Documentation page</a>.</p>
<h3 id="heading-undoing-commits">⏪ Undoing Commits</h3>
<p>Undo the last commit (keep changes unstaged):</p>
<pre><code class="lang-bash">git reset --soft HEAD~1
</code></pre>
<p>Undo the last commit (discard changes):</p>
<pre><code class="lang-bash">git reset --hard HEAD~1
</code></pre>
<h3 id="heading-resolving-merge-conflicts">🧩 Resolving Merge Conflicts</h3>
<pre><code class="lang-bash">git status                  <span class="hljs-comment"># Check conflicts</span>
nano &lt;conflicted_file&gt;      <span class="hljs-comment"># Edit the file to resolve conflicts</span>
git add &lt;conflicted_file&gt;
git commit -m <span class="hljs-string">"Resolved merge conflict"</span>
</code></pre>
<hr />
<h2 id="heading-3-git-configuration-and-credential-management">3. Git Configuration and Credential Management</h2>
<h3 id="heading-checking-git-configuration">🔍 Checking Git Configuration</h3>
<pre><code class="lang-bash">git config --list --<span class="hljs-built_in">local</span>     <span class="hljs-comment"># Show local repository settings</span>
git config --global --list    <span class="hljs-comment"># Show global settings</span>
</code></pre>
<h3 id="heading-storing-credentials">🛡️ Storing Credentials</h3>
<ul>
<li><strong>macOS</strong>:</li>
</ul>
<pre><code class="lang-bash">git config --global credential.helper osxkeychain
</code></pre>
<ul>
<li><strong>Linux</strong>:</li>
</ul>
<pre><code class="lang-bash">git config --global credential.helper cache
</code></pre>
<h3 id="heading-changing-default-editor">📝 Changing Default Editor</h3>
<ul>
<li>Use Nano:</li>
</ul>
<pre><code class="lang-bash">git config --global core.editor nano
</code></pre>
<ul>
<li>Use VS Code:</li>
</ul>
<pre><code class="lang-bash">git config --global core.editor <span class="hljs-string">"code --wait"</span>
</code></pre>
<hr />
<h2 id="heading-4-working-in-github-codespaces">4. Working in GitHub Codespaces</h2>
<ol>
<li><p>Open your repository in GitHub.</p>
</li>
<li><p>Click <strong>Code &gt; Codespaces</strong>.</p>
</li>
<li><p>Click <strong>Continue Working in GitHub Codespace</strong>.</p>
</li>
<li><p>Select an instance type based on your project needs:</p>
<ul>
<li><p><strong>Basic</strong>: Suitable for lightweight projects.</p>
</li>
<li><p><strong>Standard</strong>: Recommended for most web and mobile development.</p>
</li>
<li><p><strong>Performance</strong>: For complex builds or heavy computation.</p>
</li>
</ul>
</li>
</ol>
<hr />
<h2 id="heading-5-github-ssh-key-setup">5. GitHub SSH Key Setup</h2>
<h3 id="heading-generate-a-new-ssh-key">🔑 Generate a New SSH Key</h3>
<pre><code class="lang-bash">ssh-keygen -t ed25519 -C <span class="hljs-string">"your_email@example.com"</span>
</code></pre>
<h3 id="heading-add-ssh-key-to-github">🔗 Add SSH Key to GitHub</h3>
<pre><code class="lang-bash">cat ~/.ssh/id_ed25519.pub
</code></pre>
<p>Then add it to GitHub: <strong>Settings &gt; SSH and GPG keys</strong>.</p>
<h3 id="heading-test-ssh-connection">✅ Test SSH Connection</h3>
<pre><code class="lang-bash">ssh -T git@github.com
</code></pre>
<hr />
<h2 id="heading-6-bonus-configure-terminal-for-quick-search-and-url-opening">6. Bonus: Configure Terminal for Quick Search and URL Opening</h2>
<p>Wouldn’t it be great if you could open websites or search Google directly from the terminal using a simple command like:</p>
<pre><code class="lang-bash">oh <span class="hljs-string">"github.com"</span>
<span class="hljs-comment"># (Opens https://github.com in your browser)</span>

oh <span class="hljs-string">"how to install python"</span>
<span class="hljs-comment"># (Searches Google for "how to install python")</span>
</code></pre>
<h3 id="heading-step-1-check-your-default-shell">📌 Step 1: Check Your Default Shell</h3>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-variable">$SHELL</span>
</code></pre>
<ul>
<li><p>If it contains <code>zsh</code>: edit <code>~/.zshrc</code></p>
</li>
<li><p>If it contains <code>bash</code>: edit <code>~/.bashrc</code></p>
</li>
</ul>
<h3 id="heading-step-2-add-the-function">📌 Step 2: Add the Function</h3>
<p><strong>For macOS (uses</strong> <code>open</code>)</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">oh</span></span>() {
  <span class="hljs-built_in">local</span> input=<span class="hljs-string">"$*"</span>
  <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"<span class="hljs-variable">$input</span>"</span> =~ ^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; <span class="hljs-keyword">then</span>
    open <span class="hljs-string">"https://<span class="hljs-variable">$input</span>"</span>
  <span class="hljs-keyword">else</span>
    open <span class="hljs-string">"https://www.google.com/search?q=<span class="hljs-subst">$(echo <span class="hljs-string">"<span class="hljs-variable">$input</span>"</span> | tr ' ' '+')</span>"</span>
  <span class="hljs-keyword">fi</span>
}
</code></pre>
<p><strong>For Linux (uses</strong> <code>xdg-open</code>)</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">oh</span></span>() {
  <span class="hljs-built_in">local</span> input=<span class="hljs-string">"$*"</span>
  <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"<span class="hljs-variable">$input</span>"</span> =~ ^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; <span class="hljs-keyword">then</span>
    xdg-open <span class="hljs-string">"https://<span class="hljs-variable">$input</span>"</span>
  <span class="hljs-keyword">else</span>
    xdg-open <span class="hljs-string">"https://www.google.com/search?q=<span class="hljs-subst">$(echo <span class="hljs-string">"<span class="hljs-variable">$input</span>"</span> | tr ' ' '+')</span>"</span>
  <span class="hljs-keyword">fi</span>
}
</code></pre>
<p><strong>For Windows (uses</strong> <code>start</code>)</p>
<pre><code class="lang-bash"><span class="hljs-function"><span class="hljs-title">oh</span></span>() {
  <span class="hljs-built_in">local</span> input=<span class="hljs-string">"$*"</span>
  <span class="hljs-keyword">if</span> [[ <span class="hljs-string">"<span class="hljs-variable">$input</span>"</span> =~ ^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; <span class="hljs-keyword">then</span>
    powershell -c <span class="hljs-string">"Start-Process 'https://<span class="hljs-variable">$input</span>'"</span>
  <span class="hljs-keyword">else</span>
    powershell -c <span class="hljs-string">"Start-Process 'https://www.google.com/search?q=<span class="hljs-subst">$(echo \"$input\" | tr ' ' '+')</span>'"</span>
  <span class="hljs-keyword">fi</span>
}
</code></pre>
<h3 id="heading-step-3-apply-the-changes">✅ Step 3: Apply the Changes</h3>
<pre><code class="lang-bash"><span class="hljs-built_in">source</span> ~/.zshrc  <span class="hljs-comment"># Or ~/.bashrc depending on your shell</span>
</code></pre>
<h3 id="heading-try-it-out">🚀 Try It Out!</h3>
<pre><code class="lang-bash">oh github.com
<span class="hljs-comment"># Opens https://github.com</span>

oh <span class="hljs-string">"best terminal commands for Mac"</span>
<span class="hljs-comment"># Opens Google search</span>
</code></pre>
<hr />
<p>🌍 Resources:</p>
<ul>
<li><p><a target="_blank" href="https://git-scm.com/docs">Git Documentation</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/techstackspace/developers-setting/tree/01-homebrew-installation-and-usage-guide?tab=readme-ov-file">GitHub Repository</a></p>
</li>
<li><p><a target="_blank" href="https://arc.net/folder/FBC776BF-BC29-48F4-B019-E3B969C326A3">Shared Arc Folders</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Getting Started with GitHub, Git, Homebrew, VS Code, Arc Browser, Amazon Q, and Warp]]></title><description><![CDATA[Learn how to set up and use GitHub, Git, Homebrew, VS Code, Arc Browser, Amazon Q, and Warp to enhance your development workflow. Step-by-step guide!]]></description><link>https://techstack.hashnode.dev/getting-started-with-github-git-homebrew-vs-code-arc-browser-amazon-q-and-warp</link><guid isPermaLink="true">https://techstack.hashnode.dev/getting-started-with-github-git-homebrew-vs-code-arc-browser-amazon-q-and-warp</guid><category><![CDATA[devsetup]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[Warp]]></category><category><![CDATA[brew]]></category><category><![CDATA[Git]]></category><category><![CDATA[Chocolatey]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Tue, 11 Mar 2025 17:15:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1741806778942/4cc1e571-9cf5-4fca-acce-7c8162a11cfb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This guide provides step-by-step instructions for setting up GitHub, Git, Homebrew (for macOS), and Chocolatey (for Windows). It also includes the installation of Amazon Q, Arc Browser, and Warp Terminal.</p>
<p>📌 Full Guide &amp; Commands Here 👉 <a target="_blank" href="https://bit.ly/primary-dev-setup">https://bit.ly/primary-dev-setup</a></p>
<hr />
<h2 id="heading-macos-setup">macOS Setup</h2>
<h3 id="heading-1-searching-github-from-mac-spotlight">1. Searching GitHub from Mac Spotlight</h3>
<p>Press <code>Cmd + Space</code> and type <a target="_blank" href="http://github.com"><code>github.com</code></a> to quickly open GitHub in your default browser.</p>
<h3 id="heading-2-signing-up-on-github">2. Signing Up on GitHub</h3>
<ol>
<li><p>Visit <a target="_blank" href="https://github.com/">GitHub</a> and click <strong>Sign Up</strong>.</p>
</li>
<li><p>Provide an email, username, and password.</p>
</li>
<li><p>Follow the verification steps.</p>
</li>
</ol>
<h4 id="heading-password-recommendations">Password Recommendations:</h4>
<ul>
<li><p>Use at least 10 characters.</p>
</li>
<li><p>Combine uppercase, lowercase, numbers, and special characters.</p>
</li>
</ul>
<h3 id="heading-3-creating-a-github-repository">3. Creating a GitHub Repository</h3>
<ol>
<li><p>Go to <a target="_blank" href="https://github.com/new">GitHub New Repository</a>.</p>
</li>
<li><p>Enter <strong>Repository Name</strong>: <code>osagiebello/test</code>.</p>
</li>
<li><p>Keep everything default and click <strong>Create Repository</strong>.</p>
</li>
<li><p>Copy the suggested Git commands for pushing to GitHub.</p>
</li>
</ol>
<h3 id="heading-4-opening-the-repository-in-github-web-editor">4. Opening the Repository in GitHub Web Editor</h3>
<p>Change <code>.com</code> to <code>.dev</code>: <a target="_blank" href="http://github.dev/osagiebello/test"><code>github.dev/osagiebello/test</code></a> to open a <strong>VS Code-like web editor</strong>.</p>
<h3 id="heading-5-setting-up-git-on-terminal">5. Setting Up Git on Terminal</h3>
<h4 id="heading-checking-git-installation">Checking Git Installation</h4>
<pre><code class="lang-sh">git --version
</code></pre>
<h4 id="heading-installing-git-optional">Installing Git (Optional)</h4>
<pre><code class="lang-sh">brew install git
</code></pre>
<h4 id="heading-checking-git-configuration">Checking Git Configuration</h4>
<pre><code class="lang-sh">git config --list
git config --global --list
</code></pre>
<h4 id="heading-configuring-git-user">Configuring Git User</h4>
<pre><code class="lang-sh">git config --global user.name <span class="hljs-string">"Your Name"</span>
git config --global user.email <span class="hljs-string">"Your Email"</span>
</code></pre>
<h4 id="heading-setting-default-branch-to-main">Setting Default Branch to <code>main</code></h4>
<pre><code class="lang-sh">git config --global init.defaultBranch main
</code></pre>
<h4 id="heading-setting-vs-code-as-default-editor">Setting VS Code as Default Editor</h4>
<pre><code class="lang-sh">git config --global core.editor <span class="hljs-string">"code --wait"</span>
</code></pre>
<h3 id="heading-6-initializing-a-git-repository-amp-pushing-to-github">6. Initializing a Git Repository &amp; Pushing to GitHub</h3>
<pre><code class="lang-sh">git init
git add README.md
git commit -m <span class="hljs-string">"first commit"</span>
git branch -M main
git remote add origin https://github.com/osagiebello/test.git
git push -u origin main
</code></pre>
<h4 id="heading-handling-github-account-conflicts">Handling GitHub Account Conflicts</h4>
<pre><code class="lang-sh">brew install gh
gh auth login
</code></pre>
<h3 id="heading-7-installing-homebrew">7. Installing Homebrew</h3>
<pre><code class="lang-sh">/bin/bash -c <span class="hljs-string">"<span class="hljs-subst">$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)</span>"</span>
</code></pre>
<h4 id="heading-verify-installation">Verify installation:</h4>
<pre><code class="lang-sh">brew <span class="hljs-built_in">help</span>
</code></pre>
<h3 id="heading-8-using-homebrew-commands">8. Using Homebrew Commands</h3>
<pre><code class="lang-sh">brew search &lt;package&gt;        <span class="hljs-comment"># Search for packages</span>
brew info &lt;package&gt;          <span class="hljs-comment"># Get package info</span>
brew install &lt;package&gt;       <span class="hljs-comment"># Install a package</span>
brew update                  <span class="hljs-comment"># Update Homebrew</span>
brew upgrade                 <span class="hljs-comment"># Upgrade installed packages</span>
brew list                    <span class="hljs-comment"># List installed packages</span>
brew uninstall &lt;package&gt;      <span class="hljs-comment"># Uninstall a package</span>
brew outdated                <span class="hljs-comment"># Find outdated packages</span>
brew uninstall --zap &lt;package&gt; <span class="hljs-comment"># Remove residual files</span>
brew install --dry-run &lt;package&gt; <span class="hljs-comment"># Test install before running</span>
brew <span class="hljs-built_in">help</span> &lt;<span class="hljs-built_in">command</span>&gt;          <span class="hljs-comment"># Get detailed help</span>
</code></pre>
<h3 id="heading-9-installing-and-using-arc-browser">9. Installing and Using Arc Browser</h3>
<pre><code class="lang-sh">brew search arc
brew install --cask arc
</code></pre>
<p>Sign up and log in to Arc.</p>
<h3 id="heading-10-installing-amazon-q">10. Installing Amazon Q</h3>
<pre><code class="lang-sh">brew install --cask amazon-q
</code></pre>
<h4 id="heading-useful-commands">Useful Commands:</h4>
<pre><code class="lang-sh">q <span class="hljs-built_in">help</span>
q restart
q inline <span class="hljs-built_in">enable</span>
q inline <span class="hljs-built_in">disable</span>
q login
q <span class="hljs-built_in">logout</span>
q ai <span class="hljs-string">"Explain git merge vs rebase"</span>
q translate <span class="hljs-string">"What is Homebrew?"</span>
q chat
</code></pre>
<h3 id="heading-11-installing-and-using-warp-terminal">11. Installing and Using Warp Terminal</h3>
<pre><code class="lang-sh">brew install --cask warp
</code></pre>
<p>Sign up/login.</p>
<hr />
<h2 id="heading-windows-setup-using-chocolatey">Windows Setup Using Chocolatey</h2>
<h3 id="heading-1-installing-chocolatey">1. Installing Chocolatey</h3>
<p>Run <strong>PowerShell as Administrator</strong> and execute:</p>
<pre><code class="lang-sh">Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(<span class="hljs-string">'https://community.chocolatey.org/install.ps1'</span>))
</code></pre>
<h4 id="heading-verify-installation-1">Verify installation:</h4>
<pre><code class="lang-sh">choco -?
</code></pre>
<h3 id="heading-2-installing-git-using-chocolatey">2. Installing Git Using Chocolatey</h3>
<pre><code class="lang-sh">choco install git -y
</code></pre>
<h4 id="heading-verify-installation-2">Verify installation:</h4>
<pre><code class="lang-sh">git --version
</code></pre>
<h3 id="heading-3-installing-vs-code">3. Installing VS Code</h3>
<pre><code class="lang-sh">choco install vscode -y
</code></pre>
<h3 id="heading-4-installing-amazon-q">4. Installing Amazon Q</h3>
<pre><code class="lang-sh">choco install amazon-q -y
</code></pre>
<h3 id="heading-5-installing-warp-terminal">5. Installing Warp Terminal</h3>
<pre><code class="lang-sh">choco install warp -y
</code></pre>
<h3 id="heading-6-installing-arc-browser">6. Installing Arc Browser</h3>
<p>Search for Arc in Chocolatey:</p>
<pre><code class="lang-sh">choco search arc
</code></pre>
<p>If unavailable, <a target="_blank" href="https://arc.net/">download it from the official website</a>.</p>
<hr />
<h2 id="heading-working-in-github-codespaces">Working in GitHub Codespaces</h2>
<ol>
<li><p>Open your repository in GitHub.</p>
</li>
<li><p>Click <strong>Code &gt; Codespaces</strong>.</p>
</li>
<li><p>Click <strong>Continue Working in GitHub Codespace</strong>.</p>
</li>
<li><p>Select an instance type based on your project needs:</p>
<ul>
<li><p><strong>Basic</strong>: Suitable for lightweight projects.</p>
</li>
<li><p><strong>Standard</strong>: Recommended for most web and mobile development.</p>
</li>
<li><p><strong>Performance</strong>: For complex builds or heavy computation.</p>
</li>
</ul>
</li>
</ol>
<hr />
<p>This guide ensures a smooth setup experience for GitHub, Git, Homebrew (macOS), Chocolatey (Windows), and essential development tools. 🚀</p>
<p>✅ <strong>Get all links</strong> 👉 <a target="_blank" href="https://bit.ly/primary-dev-setup">https://bit.ly/primary-dev-setup</a></p>
]]></content:encoded></item><item><title><![CDATA[Understanding Variables, Conditionals, Loops, and Arrays In C Programming]]></title><description><![CDATA[Learn the basics of C code: variables, conditionals, loops, and arrays. Step-by-step explanations for beginners. Get started now!]]></description><link>https://techstack.hashnode.dev/understanding-variables-conditionals-loops-and-arrays-in-c-programming</link><guid isPermaLink="true">https://techstack.hashnode.dev/understanding-variables-conditionals-loops-and-arrays-in-c-programming</guid><category><![CDATA[Beginner Developers]]></category><category><![CDATA[C]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sun, 16 Jul 2023 14:37:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1689518026902/a6df3bcc-bce2-4dff-9765-3bfa32e9f3e0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/17-understanding-variables-conditionals-loop-and-arrays-in-c"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>In this blog post, we'll go through the provided code in C step by step and explain each part in detail. This will help beginners understand the code and its logic. Let's get started!</p>
<h2 id="heading-code-snippet">Code Snippet</h2>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="5d16dcfe1cc0a94dd5f69a80196457b6"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/techstackmedia/5d16dcfe1cc0a94dd5f69a80196457b6" class="embed-card">https://gist.github.com/techstackmedia/5d16dcfe1cc0a94dd5f69a80196457b6</a></div><p> </p>
<h2 id="heading-understanding-variables-and-constants">Understanding Variables and Constants</h2>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> firstNumber = <span class="hljs-number">30</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> secondNumber = <span class="hljs-number">50</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> day = <span class="hljs-number">2</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> myNumbers[] = { <span class="hljs-number">4</span>, <span class="hljs-number">6</span>, <span class="hljs-number">9</span>, <span class="hljs-number">20</span>, <span class="hljs-number">5</span>, <span class="hljs-number">10</span> };
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span>* myLanguages[] = { <span class="hljs-string">"C"</span>, <span class="hljs-string">"C++"</span>, <span class="hljs-string">"Java"</span>, <span class="hljs-string">"C#"</span>, <span class="hljs-string">"PHP"</span>, <span class="hljs-string">"Python"</span>, <span class="hljs-string">"Ruby"</span>, <span class="hljs-string">"JavaScript"</span>, <span class="hljs-string">"Rust"</span>, <span class="hljs-string">"Go"</span>, <span class="hljs-string">"Swift"</span>, <span class="hljs-string">"R"</span>, <span class="hljs-string">"Kotlin"</span> };
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> numLanguages = <span class="hljs-keyword">sizeof</span>(myLanguages) / <span class="hljs-keyword">sizeof</span>(myLanguages[<span class="hljs-number">0</span>]);
<span class="hljs-keyword">int</span> counter = <span class="hljs-number">1</span>;
<span class="hljs-keyword">int</span> counterIndex = <span class="hljs-number">1</span>;
<span class="hljs-keyword">int</span> index = <span class="hljs-number">0</span>;
<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>;
</code></pre>
<p>In the above code snippet, we declare and initialize several variables and constants. Here's a breakdown:</p>
<ul>
<li><p><code>firstNumber</code> and <code>secondNumber</code> are constants representing integer values.</p>
</li>
<li><p><code>day</code> represents the current day as an integer.</p>
</li>
<li><p><code>myNumbers</code> is an array of integers that stores a collection of numbers.</p>
</li>
<li><p><code>myLanguages</code> is an array of strings (character pointers) that stores a collection of programming language names.</p>
</li>
<li><p><code>numLanguages</code> is an integer that represents the number of languages in the <code>myLanguages</code> array.</p>
</li>
<li><p><code>counter</code>, <code>counterIndex</code>, <code>index</code>, and <code>i</code> are integer variables used for looping and counting purposes.</p>
</li>
</ul>
<h2 id="heading-comparing-numbers-using-conditionals">Comparing Numbers using Conditionals</h2>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> firstNumber = <span class="hljs-number">30</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> secondNumber = <span class="hljs-number">50</span>;

<span class="hljs-keyword">if</span> (firstNumber &gt; secondNumber) {
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d is greater than secondNumber %d\n"</span>, firstNumber, secondNumber);
} <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (firstNumber &lt; secondNumber) {
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d is less than secondNumber %d\n"</span>, firstNumber, secondNumber);
} <span class="hljs-keyword">else</span> {
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d is equivalent to secondNumber %d\n"</span>, firstNumber, secondNumber);
}

(firstNumber &gt; secondNumber) ? <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d is greater than secondNumber %d\n"</span>, firstNumber, secondNumber) : 
(firstNumber &lt; secondNumber) ? <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d is less than secondNumber %d\n"</span>, firstNumber, secondNumber) :
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d is equivalent to secondNumber %d\n"</span>, firstNumber, secondNumber);

<span class="hljs-comment">/*
30 is less than secondNumber 50
30 is less than secondNumber 50
*/</span>
</code></pre>
<p>These code blocks demonstrate how to compare two numbers (<code>firstNumber</code> and <code>secondNumber</code>) using conditional statements (<code>if-else</code> and the ternary operator <code>? :</code>). The code checks if <code>firstNumber</code> is greater than <code>secondNumber</code>, less than <code>secondNumber</code>, or equivalent to <code>secondNumber</code>. The appropriate message is then printed based on the comparison.</p>
<h2 id="heading-using-a-switch-statement">Using a Switch Statement</h2>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> day = <span class="hljs-number">2</span>;

<span class="hljs-keyword">switch</span> (day){ 
  <span class="hljs-keyword">case</span> <span class="hljs-number">1</span>:
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Monday\n"</span>);
    <span class="hljs-keyword">break</span>;
  <span class="hljs-keyword">case</span> <span class="hljs-number">2</span>:
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Tuesday\n"</span>);
    <span class="hljs-keyword">break</span>;
  <span class="hljs-keyword">case</span> <span class="hljs-number">3</span>:
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Wednesday\n"</span>);
    <span class="hljs-keyword">break</span>;
  <span class="hljs-keyword">default</span>:
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Sunday\n"</span>);
}

<span class="hljs-comment">/*
Tuesday
*/</span>
</code></pre>
<p>This switch statement checks the value of the <code>day</code> variable and executes the corresponding code block. If <code>day</code> is equal to 1, "Monday" is printed. If it is 2, "Tuesday" is printed. If it is 3, "Wednesday" is printed. If none of these cases match, the <code>default</code> case is executed, and "Sunday" is printed.</p>
<h2 id="heading-looping-with-while-and-do-while">Looping with While and Do-While</h2>
<pre><code class="lang-c"><span class="hljs-keyword">while</span> (counter &lt; <span class="hljs-number">3</span>) {
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, counter);
  counter++;
}

<span class="hljs-built_in">printf</span>(<span class="hljs-string">"-----\n"</span>);

<span class="hljs-keyword">do</span> {
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, counterIndex);
  counterIndex++;
} <span class="hljs-keyword">while</span> (counterIndex &lt; <span class="hljs-number">3</span>);

<span class="hljs-comment">/*
1
2
-----
1
2
*/</span>
</code></pre>
<p>These code blocks demonstrate the usage of <code>while</code> and <code>do-while</code> loops. In the first block, the <code>while</code> loop executes as long as <code>counter</code> is less than 3. It prints the value of <code>counter</code> and increments it by 1 in each iteration. In the second block, the <code>do-while</code> loop executes at least once and continues until <code>counterIndex</code> is less than 3. It prints the value of <code>counterIndex</code> and increments it by 1 in each iteration.</p>
<h2 id="heading-looping-with-for">Looping with For</h2>
<pre><code class="lang-c"><span class="hljs-keyword">while</span> (index &lt; <span class="hljs-number">5</span>) {
  <span class="hljs-keyword">if</span> (index == <span class="hljs-number">2</span>) {
    index++;
    <span class="hljs-keyword">continue</span>;
  }

  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, index);
  index++;
}

<span class="hljs-built_in">printf</span>(<span class="hljs-string">"-----\n"</span>);

<span class="hljs-keyword">for</span> (; i &lt; <span class="hljs-number">5</span>; i++) {
  <span class="hljs-keyword">if</span> (i == <span class="hljs-number">2</span>) {
    <span class="hljs-keyword">continue</span>;
  }
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, i);
}

<span class="hljs-comment">/*
0
1
3
4
-----
0
1
3
4
*/</span>
</code></pre>
<p>These code blocks showcase the usage of <code>for</code> loops. In the first block, the <code>while</code> loop continues until <code>index</code> is less than 5. It skips the iteration when <code>index</code> is equal to 2 using the <code>continue</code> statement. In the second block, the <code>for</code> loop initializes <code>i</code> to 0, execute until <code>i</code> is less than 5, increments <code>i</code> by 1 in each iteration, and skips the iteration when <code>i</code> is equal to 2 using the <code>continue</code> statement. In both loops, the current value of the loop variable is printed.</p>
<h2 id="heading-array-manipulation">Array Manipulation</h2>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> myNumbers[] = { <span class="hljs-number">4</span>, <span class="hljs-number">6</span>, <span class="hljs-number">9</span>, <span class="hljs-number">20</span>, <span class="hljs-number">5</span>, <span class="hljs-number">10</span> };

<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, myNumbers[<span class="hljs-number">0</span>]);

<span class="hljs-built_in">printf</span>(<span class="hljs-string">"-----\n"</span>);

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> index = <span class="hljs-number">0</span>; index &lt; numLanguages; index++) {
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Language %d is %s\n"</span>, index + <span class="hljs-number">1</span>, myLanguages[index]);
}

<span class="hljs-built_in">printf</span>(<span class="hljs-string">"-----\n"</span>);

<span class="hljs-keyword">int</span> matrix[<span class="hljs-number">2</span>][<span class="hljs-number">3</span>] = { {<span class="hljs-number">1</span>, <span class="hljs-number">9</span>, <span class="hljs-number">2</span>}, {<span class="hljs-number">7</span>, <span class="hljs-number">6</span>, <span class="hljs-number">8</span>} };
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, matrix[<span class="hljs-number">0</span>][<span class="hljs-number">2</span>]);
matrix[<span class="hljs-number">0</span>][<span class="hljs-number">2</span>] = <span class="hljs-number">5</span>;
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, matrix[<span class="hljs-number">0</span>][<span class="hljs-number">2</span>]);

<span class="hljs-built_in">printf</span>(<span class="hljs-string">"-----\n"</span>);

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">2</span>; i++) {
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> j = <span class="hljs-number">0</span>; j &lt; <span class="hljs-number">3</span>; j++) {
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, matrix[i][j]);
  }
}

<span class="hljs-comment">/*
4
-----
Language 1 is C
Language 2 is C++
Language 3 is Java
Language 4 is C#
Language 5 is PHP
Language 6 is Python
Language 7 is Ruby
Language 8 is JavaScript
Language 9 is Rust
Language 10 is Go
Language 11 is Swift
Language 12 is R
Language 13 is Kotlin
-----
2
5
*/</span>
</code></pre>
<p>These code blocks demonstrate array manipulation. The first block prints the value of the first element in the <code>myNumbers</code> array. The second block uses a <code>for</code> loop to iterate over the <code>myLanguages</code> array and prints each language's name along with its corresponding index. The third block initializes a 2-dimensional array called <code>matrix</code> and prints the value at a specific index. It then modifies that value and prints it again. The final block uses nested <code>for</code> loops to iterate over the <code>matrix</code> array and print each element.</p>
<h2 id="heading-string-manipulation">String Manipulation</h2>
<pre><code class="lang-c"><span class="hljs-keyword">int</span> x = <span class="hljs-number">0</span>;
<span class="hljs-keyword">char</span>* name = <span class="hljs-string">"Osagie"</span>;

<span class="hljs-keyword">for</span> (; x &lt;= <span class="hljs-built_in">strlen</span>(name); x++) {
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">"%c\n"</span>, name[x]);
}

<span class="hljs-comment">/*
1
9
5
7
6
8
-----
O
s
a
g
i
e
*/</span>
</code></pre>
<p>This code block demonstrates string manipulation. It declares an integer variable <code>x</code> and a character pointer <code>name</code> pointing to the " Osagie " string. A <code>for</code> loop is used to iterate over the characters in the <code>name</code> string. It prints each character using the <code>%c</code> format specifier.</p>
<h2 id="heading-practice">Practice</h2>
<p>Assuming you <a target="_blank" href="https://replit.com/signup">have an account</a> or are already <a target="_blank" href="https://replit.com/login">logged in</a> on Replit.</p>
<ul>
<li><p><a target="_blank" href="https://replit.com/@OsagieNoah/advanced#advanced.c">Try the Replit</a> Editor online.</p>
</li>
<li><p>Click the Fork button.</p>
</li>
<li><p>Edit the current code.</p>
</li>
</ul>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://replit.com/@OsagieNoah/advanced#advanced.c">https://replit.com/@OsagieNoah/advanced#advanced.c</a></div>
<p> </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this blog post, we went through a C code snippet step by step, explaining each part and its logic for beginners. We covered variable declarations, comparisons, conditionals, loops, array manipulation, and string manipulation. Understanding these fundamental concepts will help you in your journey to becoming a proficient C programmer.</p>
<hr />
<h2 id="heading-references">References</h2>
<p>Here are some reference links that can provide additional information and explanations on the topics covered in the blog:</p>
<ol>
<li><p><strong>Variables and Constants</strong>:</p>
<ul>
<li><p>C Variable Types: <a target="_blank" href="https://www.geeksforgeeks.org/variables-in-c/">GeeksforGeeks</a></p>
</li>
<li><p>Understanding Constants in C: <a target="_blank" href="https://www.programiz.com/c-programming/c-variables-constants">Programiz</a></p>
</li>
</ul>
</li>
<li><p><strong>Conditionals</strong>:</p>
<ul>
<li><p>If-Else Statements: <a target="_blank" href="https://www.geeksforgeeks.org/decision-making-c-c-else-nested-else/">GeeksforGeeks</a></p>
</li>
<li><p>Ternary Operator: <a target="_blank" href="https://www.geeksforgeeks.org/conditional-or-ternary-operator-in-c/">GeeksforGeeks</a></p>
</li>
</ul>
</li>
<li><p><strong>Switch Statements</strong>:</p>
<ul>
<li>Switch Statement: <a target="_blank" href="https://www.geeksforgeeks.org/switch-statement-cc/">GeeksforGeeks</a></li>
</ul>
</li>
<li><p><strong>Loops</strong>:</p>
<ul>
<li><p>C Loops: <a target="_blank" href="https://www.geeksforgeeks.org/c-loops/">GeeksforGeeks</a></p>
</li>
<li><p>While Loop: <a target="_blank" href="https://www.geeksforgeeks.org/c-while-loop/?">GeeksforGeeks</a></p>
</li>
<li><p>C while and do...while Loop: <a target="_blank" href="https://www.programiz.com/c-programming/c-do-while-loops">GeeksforGeeks</a></p>
</li>
</ul>
</li>
<li><p><strong>Array Manipulation</strong>:</p>
<ul>
<li><p>Arrays in C: <a target="_blank" href="https://www.geeksforgeeks.org/arrays-in-c-cpp/">GeeksforGeeks</a></p>
</li>
<li><p>2D Arrays in C: <a target="_blank" href="https://www.geeksforgeeks.org/multidimensional-arrays-in-c/">GeeksforGeeks</a></p>
</li>
<li><p>2D Arrays in C: <a target="_blank" href="https://www.tutorialspoint.com/cprogramming/c_multi_dimensional_arrays.htm#:~:text=A%20two-dimensional%20array%20is%2C%20in%20essence%2C%20a%20list,type%20and%20arrayNamewill%20be%20a%20valid%20C%20identifier.">Tutorials point</a></p>
</li>
</ul>
</li>
<li><p><strong>String Manipulation</strong>:</p>
<ul>
<li><p>Strings in C: <a target="_blank" href="https://www.geeksforgeeks.org/strings-in-c-2/">GeeksforGeeks</a></p>
</li>
<li><p>String Functions: <a target="_blank" href="https://www.programiz.com/c-programming/c-strings">Programiz</a></p>
</li>
</ul>
</li>
</ol>
<p>These references should provide additional explanations and examples to enhance the understanding of the concepts covered in the blog post.</p>
<hr />
<p><strong>Happy Coding!</strong></p>
<hr />
]]></content:encoded></item><item><title><![CDATA[String Manipulation and User Input in C Programming]]></title><description><![CDATA[Learn String Manipulation, User Input in C | Code Snippet, Functions, Pointers]]></description><link>https://techstack.hashnode.dev/string-manipulation-and-user-input-in-c-programming</link><guid isPermaLink="true">https://techstack.hashnode.dev/string-manipulation-and-user-input-in-c-programming</guid><category><![CDATA[C]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sun, 25 Jun 2023 02:19:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687659231902/1ce0a7b2-5c3c-44a3-ad63-0e800cd69e39.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/16-string-manipulation-and-user-input"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>In C programming, the <code>string.h</code> library provides several functions for manipulating strings. This blog post will explore the usage of string manipulation functions in C, along with a detailed explanation of user input using <code>scanf</code> and <code>fgets</code>. We will analyze a code snippet that showcases these concepts and discuss each aspect of the code step by step.</p>
<h2 id="heading-code-snippet">Code Snippet</h2>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="4de8421cea83855053279bcf797500bf"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/techstackmedia/4de8421cea83855053279bcf797500bf" class="embed-card">https://gist.github.com/techstackmedia/4de8421cea83855053279bcf797500bf</a></div><p> </p>
<h2 id="heading-including-stringh">Including <code>string.h</code></h2>
<p>The first line of the code snippet <code>#include &lt;string.h&gt;</code> is a preprocessor directive that includes the <code>string.h</code> header file. This file contains function declarations for string manipulation, such as <code>strlen</code>, <code>strcpy</code>, <code>strcat</code>, and <code>strcmp</code>. By including this header file, we gain access to these functions, which we will utilize in the code snippet.</p>
<h2 id="heading-creating-a-directory">Creating a Directory</h2>
<p>To begin, let's create a file named <code>intermediate.c</code> using the command line. Follow the instructions below based on your operating system:</p>
<ul>
<li><p>Open the command prompt or PowerShell.</p>
</li>
<li><p>Run the following commands:</p>
</li>
</ul>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> basic-programming/c-programming
</code></pre>
<ul>
<li>Open the file in your favorite text editor.</li>
</ul>
<pre><code class="lang-sh">code intermediate.c
</code></pre>
<p>or</p>
<pre><code class="lang-sh">vim intermediate.c <span class="hljs-comment"># installed by default on macOS</span>
</code></pre>
<p>or</p>
<pre><code class="lang-sh">emacs -Q -nw intermediate.c
</code></pre>
<p>or</p>
<pre><code class="lang-sh">nano intermediate.c <span class="hljs-comment"># installed by default on Linux</span>
</code></pre>
<p><strong>Note</strong>: Make sure you save changes in the file.</p>
<h2 id="heading-string-manipulation-using-stringh-functions">String Manipulation using <code>string.h</code> Functions</h2>
<p>In this section, we'll analyze the code related to string manipulation functions provided by the <code>string.h</code> library.</p>
<pre><code class="lang-c"><span class="hljs-comment">// String Manipulation</span>
<span class="hljs-built_in">strcat</span>(firstText, secondText);
<span class="hljs-built_in">strcpy</span>(secondStr, thirdStr);
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> str13Cmp = <span class="hljs-built_in">strcmp</span>(firstStr, thirdStr);
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> str3greetingCmp = <span class="hljs-built_in">strcmp</span>(thirdStr, greeting);
</code></pre>
<p>In the code above, we perform various string manipulation operations:</p>
<ul>
<li><p><code>strcat(firstText, secondText);</code>: This line uses the<code>strcat</code>function to concatenate the<code>secondText</code>string at the end of the<code>firstText</code>string. The result is that the<code>firstText</code> string becomes "Hello World!".</p>
</li>
<li><p><code>strcpy(secondStr, thirdStr);</code>: Here, we use the <code>strcpy</code> function to copy the contents of the <code>thirdStr</code> string into the <code>secondStr</code> array. This operation creates an independent copy of the string.</p>
</li>
<li><p><code>const int str13Cmp = strcmp(firstStr, thirdStr);</code>: The <code>strcmp</code> function compares the contents of the <code>firstStr</code> and <code>thirdStr</code> strings. It returns an integer value indicating the result of the comparison. If the two strings are equal, it returns 0. If <code>firstStr</code> is lexicographically less than <code>thirdStr</code>, it returns a negative value. If <code>firstStr</code> is lexicographically greater than <code>thirdStr</code>, it returns a positive value. The result is stored in the <code>str13Cmp</code> variable.</p>
</li>
<li><p><code>const int str3greetingCmp = strcmp(thirdStr, greeting);</code>: Similarly, this line compares the <code>thirdStr</code> and <code>greeting</code> strings using <code>strcmp</code> and stores the result in the <code>str3greetingCmp</code> variable.</p>
</li>
</ul>
<h2 id="heading-user-input-using-scanf">User Input using <code>scanf</code></h2>
<p>Now, let's look at the code related to user input using the <code>scanf</code> function.</p>
<pre><code class="lang-c"><span class="hljs-comment">// User Input using scanf</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"Please type your age and grade: "</span>);
<span class="hljs-built_in">scanf</span>(<span class="hljs-string">"%d %c"</span>, &amp;myAge, &amp;myChar);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"Please enter your first name: "</span>);
<span class="hljs-built_in">scanf</span>(<span class="hljs-string">"%19s"</span>, myFirstName);
</code></pre>
<p>In the code above, we use <code>scanf</code> to retrieve user input:</p>
<ul>
<li><p><code>scanf("%d %c", &amp;myAge, &amp;myChar);</code>: This line prompts the user to enter their age and grade. The format string <code>"%d %c"</code> specifies that we expect an integer followed by a character as input. The <code>&amp;</code> operator is used to pass the memory addresses of <code>myAge</code> and <code>myChar</code> variables to store the values entered by the user.</p>
</li>
<li><p><code>scanf("%19s", myFirstName);</code>: This line prompts the user to enter their first name. The format string <code>"%19s"</code> specifies that we expect a string input with a maximum length of 19 characters (to avoid buffer overflow). The entered string is stored in the <code>myFirstName</code> character array.</p>
</li>
</ul>
<h2 id="heading-user-input-using-fgets">User Input using <code>fgets</code></h2>
<p>Here's the code that demonstrates user input using the <code>fgets</code> function.</p>
<pre><code class="lang-c"><span class="hljs-comment">// User Input using fgets</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"Please enter your full name: "</span>);
getchar();  <span class="hljs-comment">// Clear the newline character from the previous input</span>
fgets(myFullName, <span class="hljs-keyword">sizeof</span>(myFullName), <span class="hljs-built_in">stdin</span>);
myFullName[<span class="hljs-built_in">strcspn</span>(myFullName, <span class="hljs-string">"\n"</span>)] = <span class="hljs-string">'\0'</span>;
</code></pre>
<p>In the code above, we utilize <code>fgets</code> to obtain user input:</p>
<ul>
<li><p><code>fgets(myFullName, sizeof(myFullName), stdin);</code>: This line reads a line of input from the user, storing it in the <code>myFullName</code> character array. The <code>sizeof(myFullName)</code> argument specifies the maximum number of characters to read, preventing buffer overflow. The <code>stdin</code> stream indicates that the input is read from the standard input (keyboard).</p>
</li>
<li><p><code>myFullName[strcspn(myFullName, "\n")] = '\0';</code>: Since <code>fgets</code> captures the newline character (<code>\n</code>) when the user presses Enter, this line removes the newline character from the <code>myFullName</code> string by replacing it with a null character (<code>\0</code>). This step ensures that the string ends at the intended input and doesn't include the newline character.</p>
</li>
</ul>
<h2 id="heading-memory-address-and-pointers">Memory Address and Pointers</h2>
<p>This section focuses on memory addresses and pointers used in the code.</p>
<pre><code class="lang-c"><span class="hljs-comment">// Memory Address and Pointers</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"My age is: %d\n"</span>, myAge);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"My character is: %c\n"</span>, myChar);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"My first name is: %s\n"</span>, myFirstName);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"My full name is: %s\n"</span>, myFullName);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%p\n"</span>, (<span class="hljs-keyword">void</span>*)&amp;myAge);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%p\n"</span>, (<span class="hljs-keyword">void</span>*)ptr);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, *ptr);
</code></pre>
<p>In the code above, we work with memory addresses and pointers:</p>
<ul>
<li><p><code>printf("My age is: %d\n", myAge);</code>: This line displays the value of the <code>myAge</code> variable, representing the age entered by the user.</p>
</li>
<li><p><code>printf("My character is: %c\n", myChar);</code>: Here, we print the value of the <code>myChar</code> variable, which corresponds to the grade entered by the user.</p>
</li>
<li><p><code>printf("My first name is: %s\n", myFirstName);</code>: This line outputs the contents of the <code>myFirstName</code> character array, which contains the user's first name.</p>
</li>
<li><p><code>printf("My full name is: %s\n", myFullName);</code>: Similarly, we display the content of the <code>myFullName</code> character array, which holds the user's full name.</p>
</li>
<li><p><code>printf("%p\n", (void*)&amp;myAge);</code>: This line prints the memory address of the <code>myAge</code> variable using the <code>%p</code> format specifier. The <code>&amp;</code> operator retrieves the address of the variable.</p>
</li>
<li><p><code>printf("%p\n", (void*)ptr);</code>: Here, we print the memory address stored in the <code>ptr</code> pointer variable. The <code>(void*)</code> cast is used to ensure proper formatting of the memory address.</p>
</li>
<li><p><code>printf("%d\n", *ptr);</code>: This line dereferences the <code>ptr</code> pointer and prints the value stored at the memory address it points to. Since <code>ptr</code> points to <code>myAge</code>, it effectively displays the value of <code>myAge</code>.</p>
</li>
</ul>
<p><strong>Output</strong> Finally, the code snippet includes several <code>printf</code> statements to display the output.</p>
<pre><code class="lang-c"><span class="hljs-comment">// Output</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, alphabetLength);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, alphabetByte);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%s\n"</span>, firstText);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%s\n"</span>, secondStr);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, str13Cmp);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, str3greetingCmp);
</code></pre>
<p>The code above produces the following output:</p>
<ul>
<li><p><code>alphabetLength</code>: This line prints the length of the <code>alphabet</code> string, which is determined using the <code>strlen</code> function.</p>
</li>
<li><p><code>alphabetByte</code>: Similarly, this line displays the size (in bytes) of the <code>alphabet</code> array, obtained using the <code>sizeof</code> operator.</p>
</li>
<li><p><code>firstText</code>: This line outputs the contents of the <code>firstText</code> character array, which now contains the concatenated string "Hello World!".</p>
</li>
<li><p><code>secondStr</code>: Here, we print the contents of the <code>secondStr</code> character array, which was assigned the value of the <code>thirdStr</code> string using <code>strcpy</code>.</p>
</li>
<li><p><code>str13Cmp</code>: This line displays the result of comparing the <code>firstStr</code> and <code>thirdStr</code> strings using <code>strcmp</code>. It indicates whether the two strings are equal or different.</p>
</li>
<li><p><code>str3greetingCmp</code>: Similarly, this line shows the result of comparing the <code>thirdStr</code> and <code>greeting</code> strings using <code>strcmp</code>.</p>
</li>
</ul>
<h2 id="heading-practice">Practice</h2>
<p>Assuming you <a target="_blank" href="https://replit.com/signup">have an account</a> or are already <a target="_blank" href="https://replit.com/login">logged in</a> on Replit.</p>
<ul>
<li><p><a target="_blank" href="https://replit.com/@OsagieNoah/intermediate#intermediate.c">Try the Replit</a> Editor online.</p>
</li>
<li><p>Click the <strong>Fork</strong> button.</p>
</li>
<li><p>Edit the current code.</p>
</li>
</ul>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://replit.com/@OsagieNoah/intermediate#intermediate.c">https://replit.com/@OsagieNoah/intermediate#intermediate.c</a></div>
<p> </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this blog post, we explored the usage of string manipulation functions provided by the <code>string.h</code> library in C programming. We discussed functions such as <code>strlen</code>, <code>strcpy</code>, <code>strcat</code>, and <code>strcmp</code>, along with their purpose and how they are utilized in the code snippet. Additionally, we examined user input using <code>scanf</code> and <code>fgets</code>, which allow the program to receive input from the user. Finally, we covered memory addresses and pointers, highlighting their significance and demonstrating their usage in the code snippet.</p>
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://www.studytonight.com/c/string-and-character-array.php">String and Character Array</a></p>
</li>
<li><p><a target="_blank" href="https://www.studytonight.com/c/pointers-in-c.php">Introduction to C Pointers</a></p>
</li>
<li><p><a target="_blank" href="https://www.studytonight.com/c/declaring-and-initializing-pointer.php">Using Pointers in C</a></p>
</li>
<li><p><a target="_blank" href="https://www.geeksforgeeks.org/g-fact-11/?ref=lbp">What is return type of getchar(), fgetc() and getc()?</a></p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Basics of C Programming]]></title><description><![CDATA[Learn the basics of C programming, including compiling programs, understanding data types, constants, variables, and arrays.]]></description><link>https://techstack.hashnode.dev/basics-of-c-programming</link><guid isPermaLink="true">https://techstack.hashnode.dev/basics-of-c-programming</guid><category><![CDATA[C]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Computer Science]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Tue, 20 Jun 2023 16:39:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687278832481/7a2ffb81-48bb-498d-9c1b-6a828ffa32fe.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/15-basics-of-c-programming"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>Understanding the basics of C programming is essential for any aspiring programmer. In this blog post, we will explore the concept of data types and constants in C programming, taking a hands-on approach to deepen our understanding. We will compile and run the code snippets to observe the results firsthand. Let's get started!</p>
<h2 id="heading-code-snippet">Code Snippet</h2>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="10478de1608d3519e323c53f1a4f971a"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/techstackmedia/10478de1608d3519e323c53f1a4f971a" class="embed-card">https://gist.github.com/techstackmedia/10478de1608d3519e323c53f1a4f971a</a></div><p> </p>
<h2 id="heading-creating-a-directory">Creating a Directory</h2>
<p>To begin, let's create a file named <code>basics.c</code> using the command line. Follow the instructions below based on your operating system:</p>
<ul>
<li><p>Open the command prompt or PowerShell.</p>
</li>
<li><p>Run the following commands:</p>
</li>
</ul>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> basic-programming/c-programming
</code></pre>
<ul>
<li>Open the file in your favorite text editor.</li>
</ul>
<pre><code class="lang-sh">code basics.c
</code></pre>
<p>or</p>
<pre><code class="lang-sh">vim basics.c <span class="hljs-comment"># installed by default on macOS</span>
</code></pre>
<p>or</p>
<pre><code class="lang-sh">emacs -Q -nw basics.c
</code></pre>
<p>or</p>
<pre><code class="lang-bash">nano basics.c <span class="hljs-comment"># installed by default on Linux</span>
</code></pre>
<blockquote>
<p><strong>Note:</strong> Make sure you save changes in the file.</p>
</blockquote>
<h2 id="heading-entry-point-of-a-program">Entry Point of a Program</h2>
<p>In C programming, <code>int main()</code> or <code>int main(void)</code> is the entry point of a C program. It is the function where the execution of the program starts. Here's an explanation of each:</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span> </span>{
  <span class="hljs-comment">// Code goes here    </span>
}
</code></pre>
<ul>
<li><p><code>int main()</code>:</p>
<ul>
<li><p>This declaration of <code>main</code> specifies that the function takes an unspecified number of arguments.</p>
</li>
<li><p>In C, if no arguments are specified in the parentheses, it is assumed that the function can accept any number of arguments.</p>
</li>
<li><p>While this declaration is allowed by the C language, it is generally considered bad practice because it can lead to potential issues related to argument handling and type-checking.</p>
</li>
</ul>
</li>
<li><p><code>int main(void)</code>:</p>
<ul>
<li><p>This declaration of <code>main</code> specifies that the function takes no arguments.</p>
</li>
<li><p>By explicitly stating <code>(void)</code> in the parentheses, it conveys that the <code>main</code> function does not expect any input parameters.</p>
</li>
<li><p>This declaration is considered good practice and is recommended for clarity and to avoid potential issues with argument handling.</p>
</li>
</ul>
</li>
</ul>
<p>Using int <code>main(void)</code> is generally considered better practice because it clearly indicates that the <code>main</code> function does not accept any arguments. It helps in avoiding accidental mistakes related to argument passing and makes the code more readable and self-explanatory.</p>
<h2 id="heading-exit-point-of-a-program">Exit Point of a Program</h2>
<p>In C programming, the <code>return 0</code>; statement at the end of the <code>main</code> function is not required, but it is commonly used. Here's an explanation:</p>
<pre><code class="lang-c"><span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">(<span class="hljs-keyword">void</span>)</span> </span>{
  <span class="hljs-comment">// Code goes here </span>

  <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;   
}
</code></pre>
<ul>
<li><p>The <code>return</code> statement is used to indicate the exit status of the program to the operating system or the program's caller.</p>
</li>
<li><p>By convention, a return value of <code>0</code> typically indicates successful execution or termination of the program.</p>
</li>
<li><p>If the <code>return</code> statement is omitted in the <code>main</code> function, the C language automatically inserts an implicit <code>return 0</code>; at the end of the function.</p>
</li>
<li><p>Including an explicit <code>return 0;</code> at the end of the <code>main</code> function is considered good practice for the following reasons:</p>
<ul>
<li><p>It makes the code more readable and explicit, clearly indicating the intended termination of the program.</p>
</li>
<li><p>It allows for consistency with other functions that may have non-zero return values to indicate specific error conditions.</p>
</li>
<li><p>It ensures compatibility with some programming environments that may expect a return value from the <code>main</code> function.</p>
</li>
</ul>
</li>
</ul>
<p>While <code>return 0;</code> is not strictly required, it is widely used and considered a best practice. It helps in writing clear and maintainable code, especially when working on larger projects or collaborating with other developers.</p>
<h2 id="heading-data-types-defining-the-nature-of-data">Data Types: Defining the Nature of Data</h2>
<p>Data types are used to define the type of data that a variable can hold. C provides several built-in data types, including integers, characters, booleans, and arrays. Let's explore these data types by examining the code snippet provided.</p>
<pre><code class="lang-c"><span class="hljs-comment">/* Data Types */</span>

<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> numb = <span class="hljs-number">89</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *str = <span class="hljs-string">"Bello Osagie"</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">bool</span> isTrue = <span class="hljs-number">5</span> &gt; <span class="hljs-number">3</span>;
</code></pre>
<p>In the above code, we can identify three different data types being used:</p>
<ul>
<li><p><code>int</code> is used to store integer values. Here, <code>numb</code> represents the number 89.</p>
</li>
<li><p><code>char*</code> (character pointer) is used to store strings. In this case, <code>str</code> points to the string <code>Bello Osagie</code>.</p>
</li>
<li><p><code>bool</code> represents boolean values (<code>true</code> or <code>false</code>). The variable <code>isTrue</code> is assigned the value <code>true</code> because the expression <code>5 &gt; 3</code> evaluates to <code>true</code>.</p>
</li>
</ul>
<p>By utilizing different data types, we can handle various kinds of information in our programs.</p>
<blockquote>
<p><strong>Note:</strong> These are not all the data types we have in C. We will explore others later.</p>
</blockquote>
<h2 id="heading-array-list-of-characters-as-a-string">Array: List of Characters as a String</h2>
<p>The code <code>char text[] = "This is a text";</code> represents a character array, which is commonly used to store strings in C. In this case, the array <code>text</code> is initialized with the string "This is a text".</p>
<pre><code class="lang-c"><span class="hljs-keyword">char</span> text[] = <span class="hljs-string">"This is a text"</span>;
</code></pre>
<p>Although it is common to use character arrays to store strings in C, it's important to note that there is no separate data type specifically for strings. Instead, strings are represented as arrays of characters terminated by a null character (<code>'\0'</code>), indicating the end of the string.</p>
<h3 id="heading-modification-of-a-character-at-a-specific-index">Modification of a Character at a specific index</h3>
<p>Let's visually represent the interpretation of the given code below and explain the zero-indexed string, modification of the character at index 8, and the memory addresses before and after the modification:</p>
<pre><code class="lang-c"><span class="hljs-keyword">char</span> text[] = <span class="hljs-string">"This is a text"</span>;
text[<span class="hljs-number">8</span>] = <span class="hljs-string">'1'</span>;
</code></pre>
<ol>
<li>Declaration and Initialization of the Character Array (String):</li>
</ol>
<pre><code class="lang-c"><span class="hljs-keyword">char</span> text[] = <span class="hljs-string">"This is a text"</span>;
</code></pre>
<p>This code declares and initializes a character array <code>text</code> with the string "This is a text". The characters of the string are stored in sequential memory locations.</p>
<p>Visual representation:</p>
<pre><code class="lang-c">Memory:
-----------------------------------------------------
| Address |   Value   |          Variable           |
-----------------------------------------------------
|  <span class="hljs-number">1000</span>   |    <span class="hljs-string">'T'</span>    |    text[<span class="hljs-number">0</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'T'</span>)      |
|  <span class="hljs-number">1001</span>   |    <span class="hljs-string">'h'</span>    |    text[<span class="hljs-number">1</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'h'</span>)      |
|  <span class="hljs-number">1002</span>   |    <span class="hljs-string">'i'</span>    |    text[<span class="hljs-number">2</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'i'</span>)      |
|  <span class="hljs-number">1003</span>   |    <span class="hljs-string">'s'</span>    |    text[<span class="hljs-number">3</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'s'</span>)      |
|  <span class="hljs-number">1004</span>   |    <span class="hljs-string">' '</span>    |    text[<span class="hljs-number">4</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">' '</span>)      |
|  <span class="hljs-number">1005</span>   |    <span class="hljs-string">'i'</span>    |    text[<span class="hljs-number">5</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'i'</span>)      |
|  <span class="hljs-number">1006</span>   |    <span class="hljs-string">'s'</span>    |    text[<span class="hljs-number">6</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'s'</span>)      |
|  <span class="hljs-number">1007</span>   |    <span class="hljs-string">' '</span>    |    text[<span class="hljs-number">7</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">' '</span>)      |
|  <span class="hljs-number">1008</span>   |    <span class="hljs-string">'a'</span>    |    text[<span class="hljs-number">8</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'a'</span>)      |
|  <span class="hljs-number">1009</span>   |    <span class="hljs-string">' '</span>    |    text[<span class="hljs-number">9</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">' '</span>)      |
|  <span class="hljs-number">1010</span>   |    <span class="hljs-string">'t'</span>    |    text[<span class="hljs-number">10</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'t'</span>)     |
|  <span class="hljs-number">1011</span>   |    <span class="hljs-string">'e'</span>    |    text[<span class="hljs-number">11</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'e'</span>)     |
|  <span class="hljs-number">1012</span>   |    <span class="hljs-string">'x'</span>    |    text[<span class="hljs-number">12</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'x'</span>)     |
|  <span class="hljs-number">1013</span>   |    <span class="hljs-string">'t'</span>    |    text[<span class="hljs-number">13</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'t'</span>)     |
|  <span class="hljs-number">1014</span>   |   <span class="hljs-string">'\0'</span>    |    text[<span class="hljs-number">14</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'\0'</span>)    |
-----------------------------------------------------
</code></pre>
<ol>
<li>Modification of Character at Index 8:</li>
</ol>
<pre><code class="lang-c">text[<span class="hljs-number">8</span>] = <span class="hljs-string">'1'</span>;
</code></pre>
<p>This code replaces the character at index 8 (zero-indexed) of <code>text</code> with the character '1'.</p>
<p>Visual representation (after modification):</p>
<pre><code class="lang-c">Memory:
-----------------------------------------------------
| Address |   Value   |          Variable           |
-----------------------------------------------------
|  <span class="hljs-number">1000</span>   |    <span class="hljs-string">'T'</span>    |    text[<span class="hljs-number">0</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'T'</span>)      |
|  <span class="hljs-number">1001</span>   |    <span class="hljs-string">'h'</span>    |    text[<span class="hljs-number">1</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'h'</span>)      |
|  <span class="hljs-number">1002</span>   |    <span class="hljs-string">'i'</span>    |    text[<span class="hljs-number">2</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'i'</span>)      |
|  <span class="hljs-number">1003</span>   |    <span class="hljs-string">'s'</span>    |    text[<span class="hljs-number">3</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'s'</span>)      |
|  <span class="hljs-number">1004</span>   |    <span class="hljs-string">' '</span>    |    text[<span class="hljs-number">4</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">' '</span>)      |
|  <span class="hljs-number">1005</span>   |    <span class="hljs-string">'i'</span>    |    text[<span class="hljs-number">5</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'i'</span>)      |
|  <span class="hljs-number">1006</span>   |   <span class="hljs-string">'s'</span>     |    text[<span class="hljs-number">6</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'s'</span>)      |
|  <span class="hljs-number">1007</span>   |    <span class="hljs-string">' '</span>    |    text[<span class="hljs-number">7</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">' '</span>)      |
|  <span class="hljs-number">1008</span>   |    <span class="hljs-string">'1'</span>    |    text[<span class="hljs-number">8</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'1'</span>)      |
|  <span class="hljs-number">1009</span>   |    <span class="hljs-string">' '</span>    |    text[<span class="hljs-number">9</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">' '</span>)      |
|  <span class="hljs-number">1010</span>   |    <span class="hljs-string">'t'</span>    |    text[<span class="hljs-number">10</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'t'</span>)     |
|  <span class="hljs-number">1011</span>   |    <span class="hljs-string">'e'</span>    |    text[<span class="hljs-number">11</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'e'</span>)     |
|  <span class="hljs-number">1012</span>   |    <span class="hljs-string">'x'</span>    |    text[<span class="hljs-number">12</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'x'</span>)     |
|  <span class="hljs-number">1013</span>   |    <span class="hljs-string">'t'</span>    |    text[<span class="hljs-number">13</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'t'</span>)     |
|  <span class="hljs-number">1014</span>   |   <span class="hljs-string">'\0'</span>    |    text[<span class="hljs-number">14</span>] (<span class="hljs-keyword">char</span>, <span class="hljs-string">'\0'</span>)    |
-----------------------------------------------------
</code></pre>
<p>In a zero-indexed string or array, the first element is accessed using index 0. So, in the given code, <code>text[8]</code> represents the character at the ninth position in the string. By assigning <code>'1'</code> to <code>text[8]</code>, the original character <code>'a'</code> at index 8 is replaced with <code>'1'</code>.</p>
<p>The memory addresses before and after the modification remain the same, only the values stored at those addresses are changed. This is because the array <code>text</code> is mutable, allowing us to modify its elements even if it is declared as a character array (string) or a constant.</p>
<h2 id="heading-arrays-storing-multiple-values">Arrays: Storing Multiple Values</h2>
<p>Arrays allow for the storage of multiple values of the same data type. They provide a convenient way to group related data together. Let's analyze the usage of arrays in the code snippet.</p>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> myNumbers[] = { <span class="hljs-number">4</span>, <span class="hljs-number">8</span>, <span class="hljs-number">1</span>, <span class="hljs-number">9</span>, <span class="hljs-number">7</span> }; <span class="hljs-comment">// array</span>
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *myString[] = { <span class="hljs-string">"money"</span>, <span class="hljs-string">"people"</span>, <span class="hljs-string">"love"</span> }; <span class="hljs-comment">// array</span>
</code></pre>
<p>The code snippet demonstrates the declaration and initialization of two arrays, <code>myNumbers</code> and <code>myString</code>. <code>myNumbers</code> is an array of integers, while <code>myString</code> is an array of character pointers (strings).</p>
<h3 id="heading-visual-representation-of-array">Visual Representation of Array</h3>
<p>Let's visually represent the given code and explain the concept of zero-based indexing in arrays and strings:</p>
<ol>
<li>Declaration and Initialization of Integer Array:</li>
</ol>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> myNumbers[] = { <span class="hljs-number">4</span>, <span class="hljs-number">8</span>, <span class="hljs-number">1</span>, <span class="hljs-number">9</span>, <span class="hljs-number">7</span> };
</code></pre>
<p>This code declares and initializes an integer array <code>myNumbers</code> with 5 elements. The elements are initialized with the provided values.</p>
<p>Visual representation:</p>
<pre><code class="lang-c">myNumbers:
| <span class="hljs-keyword">int</span> | index
--------------
|  <span class="hljs-number">4</span>  | <span class="hljs-number">0</span>
--------------
|  <span class="hljs-number">8</span>  | <span class="hljs-number">1</span>
--------------
|  <span class="hljs-number">1</span>  | <span class="hljs-number">2</span>
--------------
|  <span class="hljs-number">9</span>  | <span class="hljs-number">3</span>
--------------
|  <span class="hljs-number">7</span>  | <span class="hljs-number">4</span>
--------------
</code></pre>
<p>In C and many programming languages, arrays are zero-based indexed. It means that the index of the first element in the array is 0, the second element is 1, and so on. In the <code>myNumbers</code> array, the values are accessed as follows:</p>
<pre><code class="lang-c">myNumbers[<span class="hljs-number">0</span>] = <span class="hljs-number">4</span>
myNumbers[<span class="hljs-number">1</span>] = <span class="hljs-number">8</span>
myNumbers[<span class="hljs-number">2</span>] = <span class="hljs-number">1</span>
myNumbers[<span class="hljs-number">3</span>] = <span class="hljs-number">9</span>
myNumbers[<span class="hljs-number">4</span>] = <span class="hljs-number">7</span>
</code></pre>
<ol>
<li>Declaration and Initialization of String Array:</li>
</ol>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *myString[] = { <span class="hljs-string">"money"</span>, <span class="hljs-string">"people"</span>, <span class="hljs-string">"love"</span> };
</code></pre>
<p>This code declares and initializes a string array <code>myString</code> with 3 elements. Each element is a pointer to a string literal.</p>
<p>Visual representation:</p>
<pre><code class="lang-c">myString:
| str      | index
--------------
| <span class="hljs-string">"money"</span>  | <span class="hljs-number">0</span>
--------------
| <span class="hljs-string">"people"</span> | <span class="hljs-number">1</span>
--------------
|  <span class="hljs-string">"love"</span>  | <span class="hljs-number">2</span>
--------------
</code></pre>
<p>Similarly, in C, strings are also represented as arrays of characters. Each character in a string has its index starting from 0. In the <code>myString</code> array, the values are accessed as follows:</p>
<pre><code class="lang-c">myString[<span class="hljs-number">0</span>] = <span class="hljs-string">"money"</span>
myString[<span class="hljs-number">1</span>] = <span class="hljs-string">"people"</span>
myString[<span class="hljs-number">2</span>] = <span class="hljs-string">"love"</span>
</code></pre>
<p>Remember that the index represents the position of an element in the array or a character in a string, starting from 0.</p>
<p>Zero-based indexing is a convention used in programming languages, and it provides a consistent and efficient way to access elements in arrays and strings. Starting the index at 0 aligns with the underlying memory representation and allows for simple arithmetic operations when working with array elements.</p>
<h2 id="heading-constants-immutable-values">Constants: Immutable Values</h2>
<p>In C programming, constants are fixed values that cannot be modified during the execution of a program. They are declared using the <code>const</code> keyword. Let's examine the usage of constants in our code.</p>
<pre><code class="lang-c"><span class="hljs-comment">/* Constants */</span>

<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> numb = <span class="hljs-number">89</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *str = <span class="hljs-string">"Bello Osagie"</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">bool</span> isTrue = <span class="hljs-number">5</span> &gt; <span class="hljs-number">3</span>;
<span class="hljs-keyword">char</span> text[] = <span class="hljs-string">"This is a text"</span>;
text[<span class="hljs-number">8</span>] = <span class="hljs-string">'1'</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> greetings[] = { <span class="hljs-string">'H'</span>, <span class="hljs-string">'e'</span>, <span class="hljs-string">'l'</span>, <span class="hljs-string">'l'</span>, <span class="hljs-string">'o'</span>, <span class="hljs-string">' '</span>, <span class="hljs-string">'W'</span>, <span class="hljs-string">'o'</span>, <span class="hljs-string">'r'</span>, <span class="hljs-string">'l'</span>, <span class="hljs-string">'d'</span>, <span class="hljs-string">'\0'</span> };
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> myNumbers[] = { <span class="hljs-number">4</span>, <span class="hljs-number">8</span>, <span class="hljs-number">1</span>, <span class="hljs-number">9</span>, <span class="hljs-number">7</span> }; <span class="hljs-comment">// array</span>
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *myString[] = { <span class="hljs-string">"money"</span>, <span class="hljs-string">"people"</span>, <span class="hljs-string">"love"</span> }; <span class="hljs-comment">// array</span>
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> indexNumb = myNumbers[<span class="hljs-number">2</span>];
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *indexStr = myString[<span class="hljs-number">1</span>];
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> myNumbers2D[<span class="hljs-number">2</span>][<span class="hljs-number">3</span>] = { {<span class="hljs-number">3</span>, <span class="hljs-number">5</span>, <span class="hljs-number">8</span> }, {<span class="hljs-number">3</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>} };
<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> indexMyNumber2D = myNumbers2D[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>];
<span class="hljs-keyword">int</span> replaceIndexMyNumber2D = myNumbers2D[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>];
replaceIndexMyNumber2D = <span class="hljs-number">10</span>;
</code></pre>
<p>The constant <code>numb</code> is declared as an integer with the value 89. Since it is defined as a constant, its value cannot be changed later in the program. Similarly, <code>str</code> is declared as a constant character pointer pointing to the string <code>Bello Osagie</code>.</p>
<p>The boolean constant <code>isTrue</code> is assigned the result of the expression <code>5 &gt; 3</code>, which evaluates to <code>true</code>. Again, as a constant, its value remains unchanged.</p>
<p>The array <code>greetings</code> is initialized with the characters <code>'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'</code>, and <code>'\0'</code>, representing a null-terminated string constant.</p>
<p><code>myNumbers</code> and <code>myString</code> are arrays of integers and character pointers, respectively. These arrays are initialized with fixed values and cannot be modified later.</p>
<p>Next, we have the 2D array <code>myNumbers2D</code>, which is initialized with two rows and three columns of integers.</p>
<p>We have variables such as <code>indexNumb</code> and <code>indexStr</code>, which store specific elements from the constant arrays.</p>
<p>Finally, we have the variable <code>replaceIndexMyNumber2D</code> which initially holds the value of <code>myNumbers2D[1][0]</code> and later gets reassigned to the value <code>10</code>.</p>
<h3 id="heading-constants-in-array">Constants in Array</h3>
<p>Let's visually represent the interpretation of the given code and the output after the modification. Then, I will explain why the changes in the array elements are possible despite using <code>const</code>.</p>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> indexMyNumber2D = myNumbers2D[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>];
<span class="hljs-keyword">int</span> replaceIndexMyNumber2D = indexMyNumber2D;
replaceIndexMyNumber2D = <span class="hljs-number">10</span>;
</code></pre>
<ol>
<li>Declaration and Initialization of 2D Array:</li>
</ol>
<pre><code class="lang-bash">const int myNumbers2D[2][3] = { 
    {3, 5, 8},
    {3, 0, 1}
};
</code></pre>
<p>This code declares and initializes a 2D array <code>myNumbers2D</code> with 2 rows and 3 columns. The array elements are initialized with the provided values.</p>
<p>Visual representation:</p>
<pre><code class="lang-bash">myNumbers2D:
--------------
| 3 | 5 | 8 |
--------------
| 3 | 0 | 1 |
--------------
</code></pre>
<ol>
<li>Accessing Element of the 2D Array:</li>
</ol>
<pre><code class="lang-bash">const int indexMyNumber2D = myNumbers2D[1][0];
</code></pre>
<p>This code assigns the value at the index <code>[1][0]</code> of <code>myNumbers2D</code> to the constant variable <code>indexMyNumber2D</code>.</p>
<p>Visual representation (after this step):</p>
<pre><code class="lang-bash">myNumbers2D:
--------------
| 3 | 5 | 8 |
--------------
| 3 | 0 | 1 |
--------------
indexMyNumber2D: 3
</code></pre>
<ol>
<li>Assignment of Element to a Non-constant Variable:</li>
</ol>
<pre><code class="lang-bash">int replaceIndexMyNumber2D = myNumbers2D[1][0];
replaceIndexMyNumber2D = 10;
</code></pre>
<p>This code assigns the value at the index <code>[1][0]</code> of <code>myNumbers2D</code> to the variable <code>replaceIndexMyNumber2D</code>. Then, it reassigns the value of <code>replaceIndexMyNumber2D</code> to <code>10</code>.</p>
<p>Visual representation (after this step):</p>
<pre><code class="lang-bash">myNumbers2D:
--------------
| 3 | 5 | 8 |
--------------
| 3 | 0 | 1 |
--------------
indexMyNumber2D: 3
replaceIndexMyNumber2D: 10
</code></pre>
<p>Even though the array <code>myNumbers2D</code> is declared as <code>const</code>, the changes in the array elements are possible because the <code>const</code> qualifier applies to the elements themselves, not to the variables that hold them. The <code>const</code> keyword ensures that the elements cannot be modified through the array variable <code>myNumbers2D</code>.</p>
<p>In memory, the array <code>myNumbers2D</code> is stored as a contiguous block. Each element in the array has its address. When you assign an element to a non-constant variable, like <code>replaceIndexMyNumber2D</code>, the value of that element is copied to the variable, including its address. The variable <code>replaceIndexMyNumber2D</code> now holds the value and the address of the element.</p>
<p>When you modify the value of <code>replaceIndexMyNumber2D</code>, you are changing the value stored at the address held by the variable. However, the original array elements in <code>myNumbers2D</code> remains unchanged. The modification only affects the variable <code>replaceIndexMyNumber2D</code> and its associated memory location.</p>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> indexMyNumber2D = myNumbers2D[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>];
<span class="hljs-keyword">int</span> replaceIndexMyNumber2D = indexMyNumber2D; <span class="hljs-comment">// myNumbers2D[1][0];</span>
replaceIndexMyNumber2D = <span class="hljs-number">10</span>;
</code></pre>
<p>Visual representation (address illustration):</p>
<pre><code class="lang-c">Memory:
---------------------------------------------------
| Address |  Value  |           Variable          |
---------------------------------------------------
|  <span class="hljs-number">1000</span>   |    <span class="hljs-number">3</span>    | myNumbers2D[<span class="hljs-number">0</span>][<span class="hljs-number">0</span>] (<span class="hljs-keyword">const</span>)   |
|  <span class="hljs-number">1004</span>   |    <span class="hljs-number">5</span>    | myNumbers2D[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>] (<span class="hljs-keyword">const</span>)   |
|  <span class="hljs-number">1008</span>   |    <span class="hljs-number">8</span>    | myNumbers2D[<span class="hljs-number">0</span>][<span class="hljs-number">2</span>] (<span class="hljs-keyword">const</span>)   |
|  <span class="hljs-number">1012</span>   |    <span class="hljs-number">3</span>    | myNumbers2D[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>] (<span class="hljs-keyword">const</span>)   |
|  <span class="hljs-number">1016</span>   |    <span class="hljs-number">0</span>    | myNumbers2D[<span class="hljs-number">1</span>][<span class="hljs-number">1</span>] (<span class="hljs-keyword">const</span>)   |
|  <span class="hljs-number">1020</span>   |    <span class="hljs-number">1</span>    | myNumbers2D[<span class="hljs-number">1</span>][<span class="hljs-number">2</span>] (<span class="hljs-keyword">const</span>)   |
|  <span class="hljs-number">1024</span>   |    <span class="hljs-number">3</span>    | indexMyNumber2D (<span class="hljs-keyword">const</span>)     |
|  <span class="hljs-number">1028</span>   |   <span class="hljs-number">10</span>    | replaceIndexMyNumber2D      |
---------------------------------------------------
</code></pre>
<p>In this illustration, the addresses and values of the variables are shown in memory. The <code>const</code> variables (<code>myNumbers2D</code>, <code>indexMyNumber2D</code>) hold the original values without any modifications. The non-constant variable <code>replaceIndexMyNumber2D</code> holds the modified value.</p>
<pre><code class="lang-c"><span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> indexMyNumber2D = myNumbers2D[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>];
<span class="hljs-keyword">int</span> replaceIndexMyNumber2D = indexMyNumber2D; <span class="hljs-comment">// myNumbers2D[1][0];</span>
replaceIndexMyNumber2D = <span class="hljs-number">10</span>;
</code></pre>
<h2 id="heading-printing-the-values-printing-formatted-output">Printing the Values: Printing Formatted Output</h2>
<p>To observe the values of the variables and constants in our code, we use the <code>printf</code> function to print them to the console (terminal). Here's how the values are printed:</p>
<pre><code class="lang-c"><span class="hljs-comment">/* Printing Values */</span>

<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, numb); <span class="hljs-comment">// Print the value of numb</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%s\n"</span>, text); <span class="hljs-comment">// Print the value of text</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%s\n"</span>, str); <span class="hljs-comment">// Print the value of str</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%s\n"</span>, text); <span class="hljs-comment">// Print the value of text</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, isTrue); <span class="hljs-comment">// Print the value of isTrue</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, indexNumb); <span class="hljs-comment">// Print the value of indexNumb</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%s\n"</span>, greetings); <span class="hljs-comment">// Print the value of greetings</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%s\n"</span>, indexStr); <span class="hljs-comment">// Print the value of indexStr</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, indexMyNumber2D); <span class="hljs-comment">// Print the value of indexMyNumber2D</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">"%d\n"</span>, replaceIndexMyNumber2D); <span class="hljs-comment">// Print the value of replaceIndexMyNumber2D</span>
</code></pre>
<p>Each <code>printf</code> statement specifies a format specifier to indicate the data type of the variable or constant being printed. For example, <code>%d</code> is used to print integers, <code>%s</code> is used to print strings, and <code>%d</code> is also used for booleans (where <code>true</code> is printed as <code>1</code> and <code>false</code> is printed as <code>0</code>).</p>
<h3 id="heading-note">Note</h3>
<ul>
<li><p><code>%d</code> is the same as <code>%i</code>.</p>
</li>
<li><p>The format specifier <code>%c</code> is used to print a single character in C. However, the value representing the character must be enclosed in single quotes (' '), not backticks. Below is an example:</p>
</li>
</ul>
<pre><code class="lang-c"><span class="hljs-built_in">printf</span>(<span class="hljs-string">"%c\n"</span>, <span class="hljs-string">'J'</span>); <span class="hljs-comment">// A char</span>
</code></pre>
<p>This will print the character <code>'J'</code> to the console followed by a newline character (<code>'\n'</code>).</p>
<h2 id="heading-comments-documenting-your-code">Comments: Documenting Your Code</h2>
<p>Comments are essential for code documentation. They provide information about the code's functionality, purpose, and any other relevant details. In the given code snippet, we can see the usage of comments to document the code. Let's take a look:</p>
<pre><code class="lang-c"><span class="hljs-comment">// This is a single-line comment</span>
<span class="hljs-comment">/* 
   This is a multi-line comment
   It can span multiple lines
*/</span>

<span class="hljs-comment">// Code snippet starts here</span>

<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> numb = <span class="hljs-number">89</span>; <span class="hljs-comment">// Variable to store a number</span>
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *str = <span class="hljs-string">"Bello Osagie"</span>; <span class="hljs-comment">// Variable to store a string</span>
<span class="hljs-keyword">const</span> <span class="hljs-keyword">bool</span> isTrue = <span class="hljs-number">5</span> &gt; <span class="hljs-number">3</span>; <span class="hljs-comment">// Variable to store a boolean value</span>

<span class="hljs-keyword">char</span> text[] = <span class="hljs-string">"This is a text"</span>; <span class="hljs-comment">// Variable to store a character array</span>

<span class="hljs-comment">// Code snippet ends here</span>
</code></pre>
<p>In the code snippet, we can see the use of single-line comments and multi-line comments. Single-line comments start with <code>//</code> and continue until the end of the line. They are used to provide brief explanations or comments on a specific line of code.</p>
<p>Multi-line comments start with <code>/*</code> and end with <code>*/</code>. They can span multiple lines and are useful for providing detailed explanations or commenting out a block of code.</p>
<p>Comments are not executed as part of the program and do not affect the program's functionality. They are solely meant for human readability and understanding.</p>
<h2 id="heading-variables-storing-data">Variables: Storing Data</h2>
<p>Variables are used to store and manipulate data in C programming. They act as containers that hold values of different types. In the given code snippet, we can see the usage of variables like <code>numb</code>, <code>str</code>, <code>isTrue</code>, <code>text</code>, and more. Let's explore their significance and how they are utilized.</p>
<pre><code class="lang-c"><span class="hljs-comment">/* variables */</span>

<span class="hljs-keyword">const</span> <span class="hljs-keyword">int</span> numb = <span class="hljs-number">89</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">char</span> *str = <span class="hljs-string">"Bello Osagie"</span>;
<span class="hljs-keyword">const</span> <span class="hljs-keyword">bool</span> isTrue = <span class="hljs-number">5</span> &gt; <span class="hljs-number">3</span>;
<span class="hljs-keyword">char</span> text[] = <span class="hljs-string">"This is a text"</span>;
}
</code></pre>
<p>In this code, <code>numb</code> is an integer variable assigned a constant value of <code>89</code>. We use the <code>const</code> keyword to indicate that the value is constant and cannot be modified.</p>
<p>Similarly, <code>str</code> is a character pointer variable storing the address of the string <code>Bello Osagie</code>. The <code>const</code> keyword ensures that the pointer itself is constant and cannot be used to modify the string.</p>
<p><code>isTrue</code> is a boolean variable assigned the result of the expression <code>5 &gt; 3</code>. It will hold the value <code>true</code> since the expression is true.</p>
<p><code>text</code> is a character array initialized with the string <code>"This is a text."</code> It allows for the manipulation of individual characters within the array.</p>
<h2 id="heading-modifying-variables-adding-and-replacing-values">Modifying Variables: Adding and Replacing Values</h2>
<p>Variables can be modified by assigning new values to them. In the code snippet, we can see examples of modifying variables:</p>
<pre><code class="lang-c">text[<span class="hljs-number">8</span>] = <span class="hljs-string">'1'</span>;
replaceIndexMyNumber2D = <span class="hljs-number">10</span>;
</code></pre>
<p>The statement <code>text[8] = '1'</code> replaces the character at index 8 in the text array with the character <code>'1'</code>. Similarly, <code>replaceIndexMyNumber2D = 10</code> assigns the value 10 to the variable <code>replaceIndexMyNumber2D</code>.</p>
<h2 id="heading-compiling-and-running-the-code">Compiling and Running the Code</h2>
<p>When compiling a C program using the GCC compiler, you can pass various options and flags to modify the behavior of the compilation process. Let's break down the options used in the commands you mentioned:</p>
<pre><code class="lang-c"><span class="hljs-comment">/*
 * Run:
 * gcc -Wall -pedantic -Werror -Wextra -std=c99 basics.c -o basics
 * gcc basics.c -o basics
 * ./basics
 */</span>
</code></pre>
<p>Let's discuss each option:</p>
<ul>
<li><p><code>-Wall</code>: Enables compiler warnings for potential issues in the code. It stands for <strong>all warnings</strong>. When this option is used, the compiler will display a comprehensive set of warning messages to help identify possible problems in the code.</p>
</li>
<li><p><code>-pedantic</code>: Enforces strict adherence to the C language standards. It instructs the compiler to be pedantic and only allows code that strictly follows the C standard. It disables certain language extensions and non-standard features.</p>
</li>
<li><p><code>-Werror</code>: Treats all warnings as errors. When this option is enabled, any warning generated by the compiler will be treated as an error, causing the compilation to fail. This ensures that the code is warning-free and encourages developers to write clean and error-free code.</p>
</li>
<li><p><code>-Wextra</code>: Enables additional warning messages beyond those enabled by <code>-Wall</code>. It provides extra warnings for potentially suspicious code constructs or common programming mistakes.</p>
</li>
<li><p><code>-std=c99</code>: Specifies the C language standard to be used. In this case, it specifies the C99 standard. C99 is an ANSI/ISO standard for the C programming language, introduced in 1999. It adds several new features and improvements to the language.</p>
</li>
</ul>
<p>The first command (<code>gcc -Wall -pedantic -Werror -Wextra -std=c99 basics.c -o basics</code>) enables strict warnings, treats warnings as errors, and enforces adherence to the <strong>C99 standard</strong>. It is advisable to use this command during development or when aiming for strict code quality and adherence to standards. It helps catch potential issues and encourages cleaner code.</p>
<p>The second command (<code>gcc basics.c -o basics</code>) is a simpler command that compiles the <code>basics.c</code> file without any specific warning options or standard enforcement. It can be used for quick compilation without strict warning checks. However, it's generally recommended to use the first command during development or in projects where code quality and adherence to standards are crucial.</p>
<p>By using the first command, you can catch and address potential issues early in the development process, leading to more robust and maintainable code.</p>
<h2 id="heading-preprocessor-directives">Preprocessor Directives</h2>
<p>In the code below, <code>#include &lt;stdio.h&gt;</code> and <code>#include &lt;stdbool.h&gt;</code> are preprocessor directives that include the standard C library headers <code>stdio.h</code> and <code>stdbool.h</code>, respectively. Here's an explanation of each:</p>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdbool.h&gt;</span></span>
</code></pre>
<ul>
<li><p><code>#include &lt;stdio.h&gt;</code>:</p>
<ul>
<li><p>This directive includes the standard input/output library header. It provides functions for input and output operations, such as reading from or writing to the console or files.</p>
</li>
<li><p>It allows you to use functions like <code>printf()</code> and <code>scanf()</code> for formatted output and input operations, respectively.</p>
</li>
<li><p>In the given code, <code>printf()</code> function is used to print values to the console.</p>
</li>
</ul>
</li>
<li><p><code>#include &lt;stdbool.h&gt;</code>:</p>
<ul>
<li><p>This directive includes the header for the C99 standard's Boolean type support.</p>
</li>
<li><p>It defines the <code>bool</code> type, which represents boolean values (<code>true</code> and <code>false</code>).</p>
</li>
<li><p>In the given code, <code>bool</code> is used to declare the variable isTrue and store a boolean value (true or false).</p>
</li>
</ul>
</li>
</ul>
<p>Including these headers is necessary to access the functions and definitions provided by the respective libraries. Without including <code>stdio.h</code>, you wouldn't be able to use functions like <code>printf()</code>, and without including <code>stdbool.h</code>, you wouldn't be able to use the <code>bool</code> data type.</p>
<h2 id="heading-practice">Practice</h2>
<p>Assuming you <a target="_blank" href="https://replit.com/signup">have an account</a> or are already <a target="_blank" href="https://replit.com/login">logged in</a> on Replit.</p>
<ul>
<li><p><a target="_blank" href="https://replit.com/@OsagieNoah/Basics#basics.c">Try the Replit</a> Editor online.</p>
</li>
<li><p>Click the <strong>Fork</strong> button.</p>
</li>
<li><p>Edit the current code.</p>
</li>
</ul>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://replit.com/@OsagieNoah/Basics#basics.c">https://replit.com/@OsagieNoah/Basics#basics.c</a></div>
<p> </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this blog post, we explored the basics of C programming by examining data types and constants. We learned how to declare and initialize variables and constants of various data types, including integers, characters, booleans, and arrays. We also observed the results by printing the values using <code>printf</code>. Understanding these fundamental concepts is crucial for building more complex C programs. Stay tuned for future blog posts where we will delve deeper into C programming.</p>
<hr />
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://www.learn-c.org/data-types">C Data Types</a></p>
</li>
<li><p><a target="_blank" href="https://www.learn-c.org/constants">C Constants</a></p>
</li>
<li><p><a target="_blank" href="https://www.learn-c.org/arrays">C Arrays</a></p>
</li>
<li><p><a target="_blank" href="https://www.learn-c.org/boolean">C Boolean Data Type</a></p>
</li>
<li><p><a target="_blank" href="https://www.learn-c.org/printf">C printf Function</a></p>
</li>
</ul>
<hr />
<p><strong>Happy Coding!!!</strong></p>
]]></content:encoded></item><item><title><![CDATA[Getting Started with C Programming]]></title><description><![CDATA[Learn how to get started with C programming by compiling programs. This guide covers creating directories, checking for C installation, installing C, etc.]]></description><link>https://techstack.hashnode.dev/getting-started-with-c-programming</link><guid isPermaLink="true">https://techstack.hashnode.dev/getting-started-with-c-programming</guid><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[C]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Beginner Developers]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sun, 18 Jun 2023 19:17:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687115588259/46caf176-d8f2-4de1-bb51-7da000bf9153.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/14-getting-started-with-c-programming"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>C programming is a versatile language that allows you to build a wide range of applications. Whether you're a beginner or an experienced programmer, you must know how to set up your development environment and start with basic programming tasks. In this guide, we'll walk you through the process of creating directories and checking for the installation of C on different operating systems. We'll also cover the steps to install C if it's not already available. Finally, we'll demonstrate how to write and compile a simple <code>Hello, World!</code> program in C. Let's get started!</p>
<h2 id="heading-code-snippet">Code Snippet</h2>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="34430b174cdaee1e6681371aa85c4529"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/techstackmedia/34430b174cdaee1e6681371aa85c4529" class="embed-card">https://gist.github.com/techstackmedia/34430b174cdaee1e6681371aa85c4529</a></div><p> </p>
<h2 id="heading-installing-choco">Installing Choco</h2>
<p>If this is not your first time using Chocolatey or Chocolatey is already installed on your Windows Operating System skip this section.</p>
<p>To install Chocolatey, follow these steps:</p>
<ol>
<li><p>Search for PowerShell and run it as an administrator on Windows.</p>
</li>
<li><p>Go to the Chocolatey <a target="_blank" href="https://chocolatey.org/install">installation page</a>.</p>
</li>
<li><p>If this is your first time installing Chocolatey on your operating system, execute the following command in your terminal, based on the instructions provided on the installation page:</p>
</li>
</ol>
<pre><code class="lang-powershell"><span class="hljs-built_in">Get-ExecutionPolicy</span>
</code></pre>
<ul>
<li>If the output is "Restricted", enter one of the commands below:</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> AllSigned
</code></pre>
<p>or</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span>
</code></pre>
<ul>
<li>Regardless of whether "Restricted" was the previous output or not, run the following command (copy and paste it into your terminal):</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span> <span class="hljs-literal">-Force</span>; [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol = [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol <span class="hljs-operator">-bor</span> <span class="hljs-number">3072</span>; <span class="hljs-built_in">iex</span> ((<span class="hljs-built_in">New-Object</span> System.Net.WebClient).DownloadString(<span class="hljs-string">'https://community.chocolatey.org/install.ps1'</span>))
</code></pre>
<ul>
<li>If there are no errors, check if Chocolatey was successfully installed by running the following command:</li>
</ul>
<pre><code class="lang-powershell">choco
</code></pre>
<p>If the output displays the version of Chocolatey you are using, it means the installation was successful.</p>
<h2 id="heading-creating-a-directory">Creating a Directory</h2>
<p>To begin, let's create a directory named <code>c-programming</code> using the command line. Follow the instructions below based on your operating system:</p>
<ul>
<li><p>Open the command prompt or PowerShell.</p>
</li>
<li><p>Run the following commands:</p>
</li>
</ul>
<pre><code class="lang-sh">mkdir basic-programming
</code></pre>
<pre><code class="lang-sh">mkdir basic-programming/c-programming
</code></pre>
<ul>
<li>change directory to <code>c-programming</code></li>
</ul>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> basic-programming/c-programming
</code></pre>
<h2 id="heading-checking-if-c-is-installed">Checking if C is Installed</h2>
<p>Before you start writing C programs, it's important to check if C is installed on your system. You can verify this by using the <code>gcc</code> or <code>cc</code> command, a popular C compiler. Follow the steps below:</p>
<ul>
<li><p>Open the terminal.</p>
</li>
<li><p>Run the following command:</p>
</li>
</ul>
<pre><code class="lang-sh">gcc --version
</code></pre>
<blockquote>
<p><strong>Note:</strong> You may also include the extension to <code>gcc</code>. That is <code>gcc</code> is the same as <code>gcc.exe</code>.</p>
</blockquote>
<pre><code class="lang-sh">gcc.exe --version
gcc.exe input.c -o output.exe <span class="hljs-comment"># optionally omit the .exe</span>
</code></pre>
<p>If C is installed, the version information will be displayed. Otherwise, you may be prompted to install the necessary tools or package. For example, for Linux, if <code>gcc</code> is not installed, running <code>gcc --version</code> in the terminal typically results in an error message like this:</p>
<pre><code class="lang-sh">The program <span class="hljs-string">'gcc'</span> is currently not installed. You can install it by typing:
sudo apt install gcc
</code></pre>
<p>For Windows, the error may look like this shown below:</p>
<pre><code class="lang-sh"><span class="hljs-string">'gcc'</span> is not recognized as an internal or external <span class="hljs-built_in">command</span>, operable program or batch file.
</code></pre>
<p>For macOS, the error may look like this shown below:</p>
<pre><code class="lang-sh">-bash: gcc: <span class="hljs-built_in">command</span> not found
</code></pre>
<h3 id="heading-gcc-or-cc"><code>gcc</code> or <code>cc</code></h3>
<ul>
<li><p>In the article, the <code>gcc</code> command will be primarily used for checking the version of the C compiler and compiling C programs. However, it is worth noting that <code>cc</code> can be used as an alternative to <code>gcc</code> for the same purposes.</p>
</li>
<li><p>While <code>gcc</code> is commonly used as the command-line interface to the GNU Compiler Collection, including the C compiler, <code>cc</code> is often set as a symbolic link or alias to <code>gcc</code>. Therefore, both commands essentially serve the same purpose and can be used interchangeably in most cases.</p>
</li>
</ul>
<p>The choice between using <code>gcc</code> or <code>cc</code> may depend on personal preference or specific system configurations. However, in the context of the article, it is safe to assume that the <code>gcc</code> command will be predominantly used while acknowledging that the cc command could be used as an alternative.</p>
<h2 id="heading-installing-c">Installing C</h2>
<p>If C is not installed on your system, follow the appropriate instructions based on your operating system:</p>
<h3 id="heading-general-installation-vscode">General Installation (VSCode)</h3>
<ul>
<li><p>If you prefer to use VSCode, you can <a target="_blank" href="https://code.visualstudio.com/">install it</a> by using a package manager specific to your operating system. For Windows, you can use Chocolatey by running the command <code>choco install vscode</code>. macOS users can use brew with the command <code>brew install --cask visual-studio-code</code>. Ubuntu users can use sudo with the command <code>sudo apt install code</code>.</p>
</li>
<li><p>After installing VSCode, you should install the following extensions: <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools-extension-pack">C/C++ Extension Pack</a> and <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner">Code Runner</a>.</p>
</li>
<li><p>After the installation is complete, you can launch Visual Studio Code by searching for it in the applications menu or by running the <code>code</code> command in the terminal (<code>code</code> and click <code>Enter</code> or <code>Return</code>). Once Code Runner is installed, you will see a play icon beside which is a dropdown.</p>
</li>
<li><p>Click on the play dropdown icon. See the image below:</p>
</li>
</ul>
<p><a target="_blank" href="https://cdn.hashnode.com/res/hashnode/image/upload/v1687227787422/0bbf08f3-aac1-43ad-af49-42f60e1ed76c.png?auto=compress,format&amp;format=webp"><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m12c6oozcs2ynaeaxtrg.png" alt="A Snapshot Showing How to Run C with VSCode Code Runner Extension" /></a></p>
<ul>
<li><p>Open the terminal by pressing <code>Ctrl + J</code>.</p>
</li>
<li><p>Click the option that says <strong>Run C/C++</strong>.</p>
</li>
</ul>
<p><a target="_blank" href="https://cdn.hashnode.com/res/hashnode/image/upload/v1687358890481/be5f2e23-8491-4fb2-81dc-6b3368be189b.png?auto=compress,format&amp;format=webp"><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqv66p5pt8c9duecuuog.png" alt="run C with VSCode Code runner extension" /></a></p>
<ul>
<li>From the debug configuration options, select the option to build and debug an active file.</li>
</ul>
<p><a target="_blank" href="https://cdn.hashnode.com/res/hashnode/image/upload/v1687357930679/b02832aa-953f-4eaa-bdd0-ddacc4c73e7a.png?auto=compress,format&amp;format=webp"><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0kp20mgbcy78ounke5ls.png" alt="build and run in C" /></a></p>
<p>You will see the result <code>Hello, World!</code> In your terminal. Notice the new executable file created during execution - <code>hello.exe</code></p>
<blockquote>
<p><strong>Note:</strong> that the Keyboard shortcut is <code>Ctrl + Shift + B</code>.</p>
</blockquote>
<p><a target="_blank" href="https://cdn.hashnode.com/res/hashnode/image/upload/v1687359230393/93476ad3-5fc3-4367-a40b-24f25da03c54.png?auto=compress,format&amp;format=webp"><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/enivsygnbmx4jykexu1q.png" alt="C executable file in vscode" /></a></p>
<p>Now that you have done the configuration, the next time you want to run a C program just click on the play button or use the keyboard shortcut <code>Ctrl + Alt + N</code>.</p>
<p><a target="_blank" href="https://cdn.hashnode.com/res/hashnode/image/upload/v1687363385861/34253899-48e6-420f-8cb8-93e1cbb63bdf.png?auto=compress,format&amp;format=webp"><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13pfq91ln5vjf9ofs2lm.png" alt="run executable file using the play button" /></a></p>
<h3 id="heading-issue">Issue</h3>
<ul>
<li><p>If the installation doesn't work for you, go to the <a target="_blank" href="https://code.visualstudio.com/download">VS Code download page</a> and click the download button based on your operating system - macOS, Linux, Windows and install (click on the executable file after download - accept all default settings).</p>
</li>
<li><p>If the problem persists, <a target="_blank" href="https://www.codeblocks.org/downloads/">download and install Codeblocks</a>. You may navigate to the <a target="_blank" href="https://www.codeblocks.org/downloads/binaries/">Binary releases page</a> and download based on your operating system.</p>
</li>
<li><p>Alternatively, use the <a target="_blank" href="https://replit.com/@OsagieNoah/getting-started#main.c">online Replit text editor</a>.</p>
</li>
</ul>
<blockquote>
<p>Note**:** You can also <a target="_blank" href="https://vscode.dev">try VSCode in the browser</a> and still follow along the course.</p>
</blockquote>
<h3 id="heading-macos">macOS</h3>
<p>On macOS, Homebrew can be used to install C-related tools and libraries. However, Homebrew itself is not specifically used to install the C language since macOS already includes the Clang compiler, which supports C. Here's how you can install Homebrew and verify the availability of Clang:</p>
<ul>
<li><p>Open the terminal.</p>
</li>
<li><p>Install Homebrew by running the following command.</p>
</li>
</ul>
<p>On macOS, <code>brew</code> might be pre-installed on your system, verify by running the command below:</p>
<pre><code class="lang-bash">brew -v
</code></pre>
<p>If it is not installed or it shows an error, run the command below:</p>
<pre><code class="lang-sh">/bin/bash -c <span class="hljs-string">"<span class="hljs-subst">$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)</span>"</span>
</code></pre>
<ul>
<li>After Homebrew is installed, you can install additional C-related tools and libraries if needed by using Homebrew commands. For example, to install the GNU Compiler Collection (GCC), you can run the following command:</li>
</ul>
<pre><code class="lang-sh">brew install gcc
</code></pre>
<ul>
<li>To verify the availability of Clang, which comes preinstalled on macOS, run the following command:</li>
</ul>
<pre><code class="lang-sh">clang --version
</code></pre>
<p>Remember, on macOS, the default compiler is Clang, which supports C and other programming languages. If you install GCC using Homebrew, you can use it as an alternative to Clang.</p>
<h4 id="heading-alternative-installation-on-macos">Alternative installation on macOS</h4>
<ul>
<li><p>Install Xcode from the App Store.</p>
</li>
<li><p>Open Xcode and navigate to Preferences.</p>
</li>
<li><p>In the <strong>Downloads</strong> tab, install the Command Line Tools.</p>
</li>
</ul>
<h3 id="heading-ubuntu">Ubuntu</h3>
<ul>
<li><p>Open the terminal.</p>
</li>
<li><p>Run the following commands</p>
</li>
</ul>
<pre><code class="lang-sh">sudo apt-get update
sudo apt-get install build-essential
</code></pre>
<blockquote>
<p><strong>Note:</strong> The <code>sudo</code> command is used to run the subsequent commands with administrative privileges, which may require you to enter your password.</p>
</blockquote>
<h3 id="heading-windows">Windows</h3>
<p>To install C on Windows, we'll use the MinGW-w64 development environment, which provides a Windows port of GCC. Follow these steps:</p>
<p>On Windows, you can use Chocolatey to install the MinGW-w64 development environment, which provides a Windows port of GCC. Here's how you can do it:</p>
<ul>
<li><p>Open the command prompt or PowerShell with administrative privileges.</p>
</li>
<li><p>Install Chocolatey by <a target="_blank" href="https://chocolatey.org/install">following the instructions on the official Chocolatey website</a>.</p>
</li>
<li><p>Once Chocolatey is installed, run the following command to install MinGW-w64:</p>
</li>
</ul>
<pre><code class="lang-powershell">choco install mingw
</code></pre>
<ul>
<li>During the installation, make sure to select the appropriate options as prompted.</li>
</ul>
<p>For example, if asked to run the script, type <code>a</code> or <code>all</code>. It means you want to run all scripts.</p>
<pre><code class="lang-powershell"><span class="hljs-keyword">Do</span> you want to run the script?([<span class="hljs-type">Y</span>]es/[<span class="hljs-type">A</span>]ll - yes to all/[<span class="hljs-type">N</span>]o/[<span class="hljs-type">P</span>]rint): a
</code></pre>
<ul>
<li>After the installation is complete, you should have the GCC compiler available on your system. You can verify the installation by running the command <code>gcc --version</code> in the command prompt or PowerShell.</li>
</ul>
<h4 id="heading-alternative-installation-on-windows-os">Alternative installation on Windows OS</h4>
<ul>
<li><p>Visit the <a target="_blank" href="https://www.mingw-w64.org/downloads/">MinGW-w64 website and download the installer</a> for your system architecture (32-bit or 64-bit).</p>
</li>
<li><p>Run the installer and ensure you select the <strong>Add to PATH</strong> option during installation.</p>
</li>
<li><p>After installation, open the command prompt or PowerShell.</p>
</li>
<li><p>Run the following command to verify the installation:</p>
</li>
</ul>
<pre><code class="lang-sh">gcc --version
</code></pre>
<blockquote>
<p><strong>Note:</strong> <code>printf</code> is used to output (print) the result in the terminal.</p>
</blockquote>
<h2 id="heading-writing-and-compiling-a-c-program">Writing and Compiling a C Program</h2>
<p>Now that you have C installed, let's write a simple <code>Hello, World!</code> program and compile it. Follow the steps below:</p>
<ul>
<li>Create a file named <code>hello.c</code> and paste (right click) the following code into it and save (based on the editor):</li>
</ul>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;stdio.h&gt;</span></span>

<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">main</span><span class="hljs-params">()</span> </span>{
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Hello, World!\n"</span>);
    <span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
</code></pre>
<pre><code class="lang-sh">vim hello.c
</code></pre>
<p>Save file:</p>
<ul>
<li><p><code>:wq</code></p>
</li>
<li><p><code>Enter</code> or <code>Return</code></p>
</li>
</ul>
<p>or</p>
<pre><code class="lang-sh">nano hello.c
</code></pre>
<p>Save file:</p>
<ul>
<li><p><code>Ctrl + O Ctrl + C Ctrl + X</code></p>
</li>
<li><p><code>Y</code></p>
</li>
<li><p><code>Enter</code> or <code>Return</code></p>
</li>
</ul>
<p>or</p>
<pre><code class="lang-sh">emacs -Q -nw hello.c
</code></pre>
<p>It is the same as <code>emacs hello.c</code> except that it might open the GNU graphical interface:</p>
<pre><code class="lang-sh">emacs hello.c
</code></pre>
<p>Save file:</p>
<ul>
<li><p><code>Ctrl + X Ctrl + S</code></p>
</li>
<li><p><code>Ctrl + X Ctrl + C</code></p>
</li>
<li><p>Open the terminal or command prompt and navigate to the directory where the <code>hello.c</code> file is located.</p>
</li>
<li><p>Use the <code>gcc</code> command to compile the program and generate an executable file:</p>
</li>
</ul>
<pre><code class="lang-sh">gcc hello.c -o hello
</code></pre>
<p>or</p>
<pre><code class="lang-sh">gcc hello.c -o hello.exe
</code></pre>
<p>The <code>-o</code> option specifies the output file name (in this case, <code>hello</code>).</p>
<ul>
<li>Run the program by executing the generated executable file:</li>
</ul>
<pre><code class="lang-sh">./hello
</code></pre>
<p>or</p>
<pre><code class="lang-sh">./hello.exe
</code></pre>
<p>You should see the output <code>Hello, World!</code> displayed in the terminal or command prompt.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7jkz5iqhp6gj8q2wglq.png" alt="executing a c program" /></p>
<h2 id="heading-practice">Practice</h2>
<p>Assuming you <a target="_blank" href="https://replit.com/signup">have an account</a> or are already <a target="_blank" href="https://replit.com/login">logged in</a> on Replit.</p>
<ul>
<li><p><a target="_blank" href="https://replit.com/@OsagieNoah/helloWorldC#hello.c">Try the Replit</a> Editor online.</p>
</li>
<li><p>Click the <strong>Fork</strong> button.</p>
</li>
<li><p>Edit the current code.</p>
</li>
</ul>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://replit.com/@OsagieNoah/helloWorldC#hello.c">https://replit.com/@OsagieNoah/helloWorldC#hello.c</a></div>
<p> </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Congratulations! You've learned how to create directories, check if C is installed, install C if needed, and write a simple C program. This knowledge forms the foundation for your C programming journey. As you progress, you can explore more complex programs and dive deeper into the language's capabilities. Have fun coding and building amazing software with C! If you have any further questions, feel free to ask.</p>
<hr />
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://www.learn-c.org/">Learn C - Free Interactive C Tutorial</a></p>
</li>
<li><p><a target="_blank" href="https://www.tutorialspoint.com/cprogramming/">Learn C Programming - Tutorialspoint</a></p>
</li>
<li><p><a target="_blank" href="https://www.geeksforgeeks.org/c-programming-language/">C Programming - GeeksforGeeks</a></p>
</li>
<li><p><a target="_blank" href="https://www.codecademy.com/learn/learn-c">C Programming - Codecademy</a></p>
</li>
</ul>
<hr />
<p><strong>Happy Coding!!!</strong></p>
]]></content:encoded></item><item><title><![CDATA[Essential Linux Command Cheat Sheet]]></title><description><![CDATA[Learn essential Linux commands for beginners with this comprehensive cheat sheet. Set up a virtual machine using Vagrant and VirtualBox.]]></description><link>https://techstack.hashnode.dev/essential-linux-command-cheat-sheet</link><guid isPermaLink="true">https://techstack.hashnode.dev/essential-linux-command-cheat-sheet</guid><category><![CDATA[Linux]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Ubuntu]]></category><category><![CDATA[virtual machine]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Mon, 12 Jun 2023 11:18:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1686568582503/c9be097e-7e68-4ee6-8e69-e098dbe9de0e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/12-vagrant-and-virtualbox-with-aws-and-azure"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-vagrant-and-virtual-installation">Vagrant and Virtual Installation</h2>
<p>To practice and execute these common commands, you can <a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/11-getting-started-to-vagrant-and-virtualbox">set up a virtual machine using Vagrant and VirtualBox</a>. Here's a step-by-step guide on how to proceed:</p>
<ol>
<li><p>Install Vagrant and VirtualBox on your machine. You can find the installation instructions for your operating system on the respective websites:</p>
<ul>
<li><p>Vagrant: <a target="_blank" href="http://vagrantup.com">vagrantup.com</a></p>
</li>
<li><p>VirtualBox: <a target="_blank" href="http://virtualbox.org">virtualbox.org</a></p>
</li>
</ul>
</li>
<li><p>Open a terminal or command prompt on your machine.</p>
</li>
<li><p>Create a new directory where you want to set up the Vagrant project, e.g., <code>/home/user/vagrant-project</code>.</p>
</li>
<li><p>Change to the newly created directory:</p>
<pre><code class="lang-sh"> <span class="hljs-built_in">cd</span> /home/user/vagrant-project
</code></pre>
</li>
<li><p>Initialize the Vagrant project by creating a <code>Vagrantfile</code></p>
<pre><code class="lang-sh"> vagrant init ubuntu/focal64
</code></pre>
</li>
<li><p>Edit the <code>Vagrantfile</code> using a text editor of your choice and configure the virtual machine settings. For example, you can specify the base box, CPU and memory allocation, network settings, etc.</p>
</li>
<li><p>Save the changes to the <code>Vagrantfile</code> and exit the text editor.</p>
</li>
<li><p>Start the virtual machine:</p>
<pre><code class="lang-sh"> vagrant up
</code></pre>
</li>
<li><p>Once the virtual machine is up and running, you can connect to it using SSH:</p>
<pre><code class="lang-sh"> vagrant ssh
</code></pre>
</li>
<li><p>You are now inside the virtual machine, and you can run the Linux commands mentioned below:</p>
<blockquote>
<p><strong>Note</strong>: If you want more help or information about a command use the <code>man</code> or <code>--help</code> command:</p>
</blockquote>
<pre><code class="lang-sh">man [<span class="hljs-built_in">command</span>]
</code></pre>
<pre><code class="lang-sh">[<span class="hljs-built_in">command</span>] --<span class="hljs-built_in">help</span>
</code></pre>
</li>
</ol>
<p><strong>Navigation:</strong></p>
<ul>
<li><p>Change directory:</p>
<ul>
<li><code>cd /home/user/Documents</code></li>
</ul>
</li>
<li><p>List files and directories:</p>
<ul>
<li><code>ls</code> or <code>ls -l</code></li>
</ul>
</li>
<li><p>Print working directory:</p>
<ul>
<li><code>pwd</code></li>
</ul>
</li>
<li><p>Make directory:</p>
<ul>
<li><code>mkdir mydir</code></li>
</ul>
</li>
<li><p>Remove files and directories:</p>
<ul>
<li><code>rm myfile.txt</code> or <code>rm -r mydir</code></li>
</ul>
</li>
<li><p>Copy files and directories:</p>
<ul>
<li><code>cp file1.txt file2.txt</code> or <code>cp -r dir1 dir2</code></li>
</ul>
</li>
<li><p>Move or rename files and directories:</p>
<ul>
<li><code>mv file1.txt file2.txt</code> or <code>mv myfile.txt newdir/myfile.txt</code></li>
</ul>
</li>
<li><p>Search for files and directories:</p>
<ul>
<li><code>find /home/user -name myfile.txt</code></li>
</ul>
</li>
<li><p>Search for patterns in files:</p>
<ul>
<li><code>grep "keyword" myfile.txt</code></li>
</ul>
</li>
<li><p>Concatenate and display file content:</p>
<ul>
<li><code>cat myfile.txt</code></li>
</ul>
</li>
<li><p>View file content with pagination:</p>
<ul>
<li><code>less myfile.txt</code></li>
</ul>
</li>
<li><p>Output the beginning of a file:</p>
<ul>
<li><code>head myfile.txt</code></li>
</ul>
</li>
<li><p>Output the end of a file:</p>
<ul>
<li><code>tail myfile.txt</code></li>
</ul>
</li>
<li><p>Create links between files:</p>
<ul>
<li><code>ln -s myfile.txt mylink</code></li>
</ul>
</li>
<li><p>Change file permissions:</p>
<ul>
<li><code>chmod 644 myfile.txt</code></li>
</ul>
</li>
</ul>
<p><strong>File Manipulation:</strong></p>
<ul>
<li><p>Create an empty file:</p>
<ul>
<li><code>touch myfile.txt</code></li>
</ul>
</li>
<li><p>Text editor (nano):</p>
<ul>
<li><code>nano myfile.txt</code></li>
</ul>
</li>
<li><p>Text editor (vi/vim):</p>
<ul>
<li><code>vim myfile.txt</code></li>
</ul>
</li>
<li><p>Determine file type:</p>
<ul>
<li><code>file myfile.txt</code></li>
</ul>
</li>
<li><p>Word, line, character, and byte count:</p>
<ul>
<li><code>wc myfile.txt</code></li>
</ul>
</li>
<li><p>Archive files:</p>
<ul>
<li><code>tar -cvf archive.tar file1.txt file2.txt</code></li>
</ul>
</li>
<li><p>Compress files:</p>
<ul>
<li><code>gzip myfile.txt</code></li>
</ul>
</li>
<li><p>Decompress files:</p>
<ul>
<li><code>gunzip myfile.txt.gz</code></li>
</ul>
</li>
<li><p>Package and compress files:</p>
<ul>
<li><code>zip</code> <a target="_blank" href="http://archive.zip"><code>archive.zip</code></a> <code>file1.txt file2.txt</code></li>
</ul>
</li>
<li><p>Extract files from a zip archive:</p>
<ul>
<li><code>unzip</code> <a target="_blank" href="http://archive.zip"><code>archive.zip</code></a></li>
</ul>
</li>
</ul>
<p><strong>Process Management:</strong></p>
<ul>
<li><p>Display running processes:</p>
<ul>
<li><code>ps aux</code></li>
</ul>
</li>
<li><p>Monitor system activity and processes:</p>
<ul>
<li><code>top</code></li>
</ul>
</li>
<li><p>Terminate processes:</p>
<ul>
<li><code>kill PID</code></li>
</ul>
</li>
<li><p>Run a process in the background:</p>
<ul>
<li><code>command &amp;</code></li>
</ul>
</li>
<li><p>Bring a background process to the foreground:</p>
<ul>
<li><code>fg</code></li>
</ul>
</li>
<li><p>Display current jobs:</p>
<ul>
<li><code>jobs</code></li>
</ul>
</li>
</ul>
<p><strong>System Information:</strong></p>
<ul>
<li><p>Print system information:</p>
<ul>
<li><code>uname -a</code></li>
</ul>
</li>
<li><p>Print the current user:</p>
<ul>
<li><code>whoami</code></li>
</ul>
</li>
<li><p>Print the hostname:</p>
<ul>
<li><code>hostname</code></li>
</ul>
</li>
<li><p>Disk space usage:</p>
<ul>
<li><code>df -h</code></li>
</ul>
</li>
<li><p>Estimate file and directory space usage:</p>
<ul>
<li><code>du -sh /path/to/directory</code></li>
</ul>
</li>
<li><p>Display memory usage:</p>
<ul>
<li><code>free -m</code></li>
</ul>
</li>
<li><p>System uptime:</p>
<ul>
<li><code>uptime</code></li>
</ul>
</li>
<li><p>Network configuration:</p>
<ul>
<li><code>ifconfig</code> or <code>ip addr show</code></li>
</ul>
</li>
</ul>
<p><strong>Package Management:</strong></p>
<ul>
<li><p>Package handling utility (Debian-based systems):</p>
<ul>
<li><code>sudo apt-get install package_name</code></li>
</ul>
</li>
<li><p>Package manager (RHEL-based systems):</p>
<ul>
<li><code>sudo yum install package_name</code></li>
</ul>
</li>
<li><p>Package manager (Arch Linux):</p>
<ul>
<li><code>sudo pacman -S package_name</code></li>
</ul>
</li>
</ul>
<p><strong>Networking:</strong></p>
<ul>
<li><p>Send ICMP echo requests to a network host:</p>
<ul>
<li><code>ping</code> <a target="_blank" href="http://www.example.com"><code>www.example.com</code></a></li>
</ul>
</li>
<li><p>Download files from the web:</p>
<ul>
<li><code>wget</code> <a target="_blank" href="https://example.com/file.txt"><code>https://example.com/file.txt</code></a></li>
</ul>
</li>
<li><p>Transfer data using various protocols:</p>
<ul>
<li><code>curl</code> <a target="_blank" href="https://example.com"><code>https://example.com</code></a></li>
</ul>
</li>
<li><p>Secure shell client:</p>
<ul>
<li><code>ssh user@hostname</code></li>
</ul>
</li>
<li><p>Securely copy files between hosts:</p>
<ul>
<li><code>scp myfile.txt user@hostname:/path/to/destination</code></li>
</ul>
</li>
<li><p>File Transfer Protocol (FTP) client:</p>
<ul>
<li><code>ftp hostname</code></li>
</ul>
</li>
<li><p>Secure FTP client:</p>
<ul>
<li><code>sftp user@hostname</code></li>
</ul>
</li>
<li><p>Network configuration:</p>
<ul>
<li><code>ifconfig</code> or <code>ip addr show</code></li>
</ul>
</li>
<li><p>Network statistics:</p>
<ul>
<li><code>netstat</code></li>
</ul>
</li>
</ul>
<p><strong>User Management:</strong></p>
<ul>
<li><p>Create a new user:</p>
<ul>
<li><code>sudo adduser newuser</code></li>
</ul>
</li>
<li><p>Delete a user:</p>
<ul>
<li><code>sudo deluser username</code></li>
</ul>
</li>
<li><p>Change user password:</p>
<ul>
<li><code>sudo passwd username</code></li>
</ul>
</li>
<li><p>Switch to another user:</p>
<ul>
<li><code>su username</code></li>
</ul>
</li>
<li><p>Grant administrative privileges:</p>
<ul>
<li><code>sudo usermod -aG sudo username</code></li>
</ul>
</li>
</ul>
<p><strong>System Maintenance:</strong></p>
<ul>
<li><p>Update package lists and upgrade installed packages:</p>
<ul>
<li><code>sudo apt-get update &amp;&amp; sudo apt-get upgrade</code></li>
</ul>
</li>
<li><p>Restart the system:</p>
<ul>
<li><code>sudo reboot</code></li>
</ul>
</li>
<li><p>Shutdown the system:</p>
<ul>
<li><code>sudo shutdown now</code></li>
</ul>
</li>
<li><p>View system logs:</p>
<ul>
<li><code>tail /var/log/syslog</code></li>
</ul>
</li>
<li><p>Check system disk usage:</p>
<ul>
<li><code>df -h</code></li>
</ul>
</li>
<li><p>Check system memory usage:</p>
<ul>
<li><code>free -m</code></li>
</ul>
</li>
<li><p>Monitor system resources and processes:</p>
<ul>
<li><code>top</code></li>
</ul>
</li>
</ul>
<p>These are just a few examples of commonly used Linux commands. There are many more commands available with various options and functionalities. It's always a good idea to refer to the documentation or online resources for more detailed information about specific commands.</p>
<hr />
<h2 id="heading-references">References</h2>
<p><a target="_blank" href="https://www.youtube.com/watch?v=ZtqBQ68cfJc">The 50 Most Popular Linux &amp; Terminal Commands</a></p>
]]></content:encoded></item><item><title><![CDATA[Vagrant and VirtualBox with AWS and Azure]]></title><description><![CDATA[Configure Vagrant with AWS and Azure for cloud-based providers. Step-by-step instructions for Vagrant and VirtualBox integration.]]></description><link>https://techstack.hashnode.dev/vagrant-and-virtualbox-with-aws-and-azure</link><guid isPermaLink="true">https://techstack.hashnode.dev/vagrant-and-virtualbox-with-aws-and-azure</guid><category><![CDATA[Azure]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sun, 11 Jun 2023 20:38:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1686517742379/7dd3bb1e-a83b-458b-afce-0c92ecf03fed.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/12-vagrant-and-virtualbox-with-aws-and-azura"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>To use cloud-based providers like AWS and Azure with Vagrant and VirtualBox, you need to configure Vagrant to work with the chosen cloud provider. Here are step-by-step instructions for using AWS and Azure with Vagrant and VirtualBox:</p>
<p>Using AWS with Vagrant and VirtualBox:</p>
<ol>
<li><p>Install the necessary dependencies:</p>
<ul>
<li><p>Install VirtualBox: Download and install VirtualBox from the official website (choco - Windows or brew - macOS).</p>
</li>
<li><p>Install Vagrant: Download and install Vagrant from the official website (choco - Windows or brew - macOS).</p>
</li>
</ul>
</li>
<li><p>Install the AWS plugin for Vagrant:</p>
<ul>
<li><p>Open a command prompt or terminal.</p>
</li>
<li><p>Run the following command to install the AWS plugin: <code>vagrant plugin install vagrant-aws</code>.</p>
</li>
</ul>
</li>
<li><p>Set up AWS credentials:</p>
<ul>
<li><p>Create an AWS account if you don't have one already.</p>
</li>
<li><p>Generate an access key and secret key from the AWS Management Console.</p>
</li>
<li><p>Configure your AWS credentials locally by running the following command: <code>aws configure</code>. Enter your access key, secret key, default region, and output format.</p>
</li>
</ul>
</li>
<li><p>Create a Vagrantfile:</p>
<ul>
<li><p>Create a new directory for your Vagrant project.</p>
</li>
<li><p>Navigate to the project directory using the command prompt or terminal.</p>
</li>
<li><p>Run the following command to initialize a new Vagrantfile: <code>vagrant init</code>.</p>
</li>
<li><p>Open the generated Vagrantfile in a text editor and configure it according to your requirements. Refer to the Vagrant AWS plugin documentation for specific configuration options.</p>
</li>
</ul>
</li>
<li><p>Specify the AWS provider in the Vagrantfile:</p>
<ul>
<li><p>Add the following lines to your Vagrantfile to configure the AWS provider:</p>
<pre><code class="lang-sh">  Vagrant.configure(<span class="hljs-string">"2"</span>) <span class="hljs-keyword">do</span> |config|
    config.vm.provider :aws <span class="hljs-keyword">do</span> |aws, override|
      aws.access_key_id = <span class="hljs-string">"YOUR_ACCESS_KEY"</span>
      aws.secret_access_key = <span class="hljs-string">"YOUR_SECRET_KEY"</span>
      aws.region = <span class="hljs-string">"YOUR_REGION"</span>
      aws.instance_type = <span class="hljs-string">"INSTANCE_TYPE"</span>
      aws.ami = <span class="hljs-string">"AMI_ID"</span>
    end
  end
</code></pre>
</li>
</ul>
</li>
<li><p>Launch the AWS instance:</p>
<ul>
<li><p>In the command prompt or terminal, navigate to the project directory.</p>
</li>
<li><p>Run the command <code>vagrant up --provider=aws</code> to launch the AWS instance.</p>
</li>
</ul>
</li>
</ol>
<p>Using Azure with Vagrant and VirtualBox:</p>
<ol>
<li><p>Install the necessary dependencies:</p>
<ul>
<li><p>Install VirtualBox: Download and install VirtualBox from the official website (choco - Windows or brew - macOS).</p>
</li>
<li><p>Install Vagrant: Download and install Vagrant from the official website (choco - Windows or brew - macOS).</p>
</li>
</ul>
</li>
<li><p>Install the Azure plugin for Vagrant:</p>
<ul>
<li><p>Open a command prompt or terminal.</p>
</li>
<li><p>Run the following command to install the Azure plugin: <code>vagrant plugin install vagrant-azure</code>.</p>
</li>
</ul>
</li>
<li><p>Set up Azure credentials:</p>
<ul>
<li><p>Create an Azure account if you don't have one already.</p>
</li>
<li><p>Generate a service principal and obtain the client ID, client secret, tenant ID, and subscription ID.</p>
</li>
<li><p>Configure your Azure credentials locally by running the following command: <code>az login</code>.</p>
</li>
</ul>
</li>
<li><p>Create a Vagrantfile:</p>
<ul>
<li><p>Create a new directory for your Vagrant project.</p>
</li>
<li><p>Navigate to the project directory using the command prompt or terminal.</p>
</li>
<li><p>Run the following command to initialize a new Vagrantfile: <code>vagrant init</code>.</p>
</li>
<li><p>Open the generated Vagrantfile in a text editor and configure it according to your requirements. Refer to the Vagrant Azure plugin documentation for specific configuration options.</p>
</li>
</ul>
</li>
</ol>
<h2 id="heading-specify-the-azure-provider-in-the-vagrantfile">Specify the Azure provider in the Vagrantfile</h2>
<ul>
<li><p>Add the following lines to your Vagrantfile to configure the Azure provider:</p>
<pre><code class="lang-sh">  Vagrant.configure(<span class="hljs-string">"2"</span>) <span class="hljs-keyword">do</span> |config|
    config.vm.provider :azure <span class="hljs-keyword">do</span> |azure, override|
      azure.tenant_id = <span class="hljs-string">"YOUR_TENANT_ID"</span>
      azure.client_id = <span class="hljs-string">"YOUR_CLIENT_ID"</span>
      azure.client_secret = <span class="hljs-string">"YOUR_CLIENT_SECRET"</span>
      azure.subscription_id = <span class="hljs-string">"YOUR_SUBSCRIPTION_ID"</span>
      azure.location = <span class="hljs-string">"YOUR_LOCATION"</span>
      azure.vm_image_urn = <span class="hljs-string">"PUBLISHER:OFFER:SKU:VERSION"</span>
    end
  end
</code></pre>
</li>
</ul>
<h2 id="heading-launch-the-azure-instance">Launch the Azure instance</h2>
<ul>
<li><p>In the command prompt or terminal, navigate to the project directory.</p>
</li>
<li><p>Run the command <code>vagrant up --provider=azure</code> to launch the Azure instance.</p>
</li>
</ul>
<p>Please note that the specific configuration options and commands may vary based on the versions of Vagrant, VirtualBox, and the respective cloud provider plugins you are using. Refer to the documentation and resources provided by the cloud provider and the Vagrant plugins for detailed instructions and up-to-date information.</p>
<p>Remember to consider any costs associated with using cloud-based instances, as you may be billed based on the usage and resources consumed.</p>
<hr />
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://github.com/mitchellh/vagrant-aws">Vagrant AWS plugin</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/azure/vagrant-azure">Vagrant Azure plugin</a></p>
</li>
<li><p><a target="_blank" href="https://aws.amazon.com/documentation/">AWS Documentation</a></p>
</li>
<li><p><a target="_blank" href="https://docs.microsoft.com/azure/">Azure Documentation</a></p>
</li>
</ul>
<p>Remember to explore these resources to ensure accurate and up-to-date information.</p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Getting Started with Vagrant and VirtualBox]]></title><description><![CDATA[Simplifying Development with Vagrant and VirtualBox: A Comprehensive Guide - Installation, Setup, and Workflow]]></description><link>https://techstack.hashnode.dev/getting-started-with-vagrant-and-virtualbox</link><guid isPermaLink="true">https://techstack.hashnode.dev/getting-started-with-vagrant-and-virtualbox</guid><category><![CDATA[Devops]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[linux for beginners]]></category><category><![CDATA[Ubuntu]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sat, 10 Jun 2023 16:39:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1686414759030/19b2c44d-3372-424f-b644-cfa5b5c3f47f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/11-getting-started-to-vagrant-and-virtualbox"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>Developers often face challenges when setting up and managing development environments across different machines. However, tools like Vagrant and VirtualBox offer a seamless solution by providing a way to create and manage virtual environments effortlessly. In this blog post, we will walk you through the installation process of Vagrant and VirtualBox on Windows and macOS using two popular package managers: Choco and Brew. We'll also highlight commands that work specifically with Vagrant and VirtualBox, showcasing their unique benefits and demonstrating how they outperform commands on Git Bash for Windows users.</p>
<h2 id="heading-installations">Installations</h2>
<h3 id="heading-installing-choco-windows-and-brew-macos">Installing Choco (Windows) and Brew (macOS)</h3>
<p>If this is not your first time using Chocolatey or Chocolatey is already installed on your Windows Operating System skip this section.</p>
<p>Choco is a powerful package manager for Windows that simplifies software installation.</p>
<p>To install Chocolatey, follow these steps:</p>
<ol>
<li><p>Search for PowerShell and run it as an administrator on Windows.</p>
</li>
<li><p>Go to the Chocolatey <a target="_blank" href="https://chocolatey.org/install">installation page</a>.</p>
</li>
<li><p>If this is your first time installing Chocolatey on your operating system, execute the following command in your terminal, based on the instructions provided on the installation page:</p>
</li>
</ol>
<pre><code class="lang-powershell"><span class="hljs-built_in">Get-ExecutionPolicy</span>
</code></pre>
<ul>
<li>If the output is "Restricted", enter one of the commands below:</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> AllSigned
</code></pre>
<p>or</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span>
</code></pre>
<ul>
<li>Regardless of whether "Restricted" was the previous output or not, run the following command (copy and paste it into your terminal):</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span> <span class="hljs-literal">-Force</span>; [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol = [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol <span class="hljs-operator">-bor</span> <span class="hljs-number">3072</span>; <span class="hljs-built_in">iex</span> ((<span class="hljs-built_in">New-Object</span> System.Net.WebClient).DownloadString(<span class="hljs-string">'https://community.chocolatey.org/install.ps1'</span>))
</code></pre>
<ul>
<li>If there are no errors, check if Chocolatey was successfully installed by running the following command:</li>
</ul>
<pre><code class="lang-powershell">choco
</code></pre>
<p>If the output displays the version of Chocolatey you are using, it means the installation was successful.</p>
<p>Now you can install any package you want or upgrade an already existing package:</p>
<pre><code class="lang-powershell">choco install &lt;package&gt;
</code></pre>
<pre><code class="lang-powershell">choco upgrade &lt;package&gt;
</code></pre>
<p>For example:</p>
<pre><code class="lang-powershell">choco install git
</code></pre>
<pre><code class="lang-powershell">choco upgrade chocolatey
</code></pre>
<blockquote>
<p><strong>Note:</strong> Anytime asked <strong>Do you want to run the script?</strong>, type <strong>a</strong> (or <strong>all</strong>) more often rather than <strong>y</strong> (or <strong>yes</strong>) and click enter.</p>
</blockquote>
<pre><code class="lang-powershell"><span class="hljs-keyword">Do</span> you want to run the script?([<span class="hljs-type">Y</span>]es/[<span class="hljs-type">A</span>]ll - yes to all/[<span class="hljs-type">N</span>]o/[<span class="hljs-type">P</span>]rint): a
</code></pre>
<h3 id="heading-installing-vagrant-and-virtualbox-with-choco">Installing Vagrant and VirtualBox with Choco</h3>
<p>With Choco installed, let's proceed to install Vagrant and VirtualBox on Windows using Choco.</p>
<ol>
<li><p>Installing Vagrant:</p>
<ul>
<li><p>Open PowerShell or Command Prompt.</p>
</li>
<li><p>Execute the following command to install Vagrant using Choco:</p>
<pre><code class="lang-sh">  choco install vagrant
</code></pre>
</li>
</ul>
</li>
<li><p>Installing VirtualBox:</p>
<ul>
<li><p>Open PowerShell or Command Prompt.</p>
</li>
<li><p>Run the following command to install VirtualBox using Choco:</p>
<pre><code class="lang-sh">  choco install virtualbox
</code></pre>
</li>
</ul>
</li>
</ol>
<h3 id="heading-installing-vagrant-and-virtualbox-with-brew">Installing Vagrant and VirtualBox with Brew</h3>
<p>Before we proceed, Check if Homebrew is already installed.</p>
<pre><code class="lang-sh">brew -v
</code></pre>
<p>If you don't get the version, run the command below:</p>
<pre><code class="lang-sh">/bin/bash -c <span class="hljs-string">"<span class="hljs-subst">$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)</span>"</span>
</code></pre>
<p>Normally Homebrew will provide further installation commands on the terminal to execute, make sure you execute them. For example, you might be requested to run the commands below. Run the following two commands in your terminal to add Homebrew to your PATH:</p>
<pre><code class="lang-sh">(<span class="hljs-built_in">echo</span>; <span class="hljs-built_in">echo</span> <span class="hljs-string">'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'</span>) &gt;&gt; /home/vagrant/.profile
   <span class="hljs-built_in">eval</span> <span class="hljs-string">"<span class="hljs-subst">$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)</span>"</span>
</code></pre>
<p>These commands will add the necessary configuration to your profile so that Homebrew can be accessed from your terminal.</p>
<p>Now check again if it is installed successfully:</p>
<pre><code class="lang-sh">brew -v
</code></pre>
<ol>
<li><p>Installing Vagrant:</p>
<ul>
<li><p>Open Terminal.</p>
</li>
<li><p>Execute the following command to install Vagrant using <code>brew</code>:</p>
<pre><code class="lang-sh">  brew install vagrant
</code></pre>
</li>
</ul>
</li>
<li><p>Installing VirtualBox:</p>
<ul>
<li><p>Open Terminal.</p>
</li>
<li><p>Execute the following command to install VirtualBox (VM) using <code>brew</code>:</p>
<pre><code class="lang-sh">  brew install --cask virtualbox
</code></pre>
</li>
</ul>
</li>
</ol>
<h2 id="heading-using-vagrant-and-virtualbox">Using Vagrant and VirtualBox</h2>
<p>Now that we have Vagrant and VirtualBox installed, let's explore their functionalities and see how they simplify development workflows.</p>
<h3 id="heading-box-names">Box Names</h3>
<p>When using the <code>vagrant init</code> command, the box name represents the base image or template from which Vagrant will create your virtual machine. The box name determines the operating system, pre-installed software, and configurations available for your development environment. Here are a few commonly used box names and their uses:</p>
<ol>
<li><p><code>hashicorp/bionic64</code>:</p>
<ul>
<li><p>Ubuntu 18.04 LTS (Bionic Beaver) 64-bit base box provided by HashiCorp.</p>
</li>
<li><p>Suitable for general-purpose development and testing on Ubuntu.</p>
</li>
</ul>
</li>
<li><p><code>ubuntu/focal64</code>:</p>
<ul>
<li><p>Ubuntu 20.04 LTS (Focal Fossa) 64-bit base box provided by Ubuntu.</p>
</li>
<li><p>Similar to <code>hashicorp/bionic64</code>, but with the newer Ubuntu 20.04 LTS release.</p>
</li>
</ul>
</li>
<li><p><code>centos/8</code>:</p>
<ul>
<li><p>CentOS 8 64-bit base box provided by CentOS.</p>
</li>
<li><p>Ideal for working with CentOS-specific software and configurations.</p>
</li>
</ul>
</li>
<li><p><code>debian/buster64</code>:</p>
<ul>
<li><p>Debian 10 (Buster) 64-bit base box provided by the Debian project.</p>
</li>
<li><p>Useful for Debian-based development and testing.</p>
</li>
</ul>
</li>
<li><p><code>fedora/33-cloud-base</code>:</p>
<ul>
<li><p>Fedora 33 Cloud Base 64-bit base box provided by the Fedora project.</p>
</li>
<li><p>Suitable for Fedora-specific development and testing.</p>
</li>
</ul>
</li>
<li><p><code>windows-server-2019</code>:</p>
<ul>
<li><p>Windows Server 2019 base box provided by Microsoft.</p>
</li>
<li><p>Enables Windows-based development and testing environments.</p>
</li>
</ul>
</li>
<li><p>Custom Boxes:</p>
<ul>
<li><p>Apart from the official boxes, you can also use custom boxes created by the community or yourself.</p>
</li>
<li><p>Custom boxes allow you to tailor the virtual machine to your specific requirements, including pre-installed software, configurations, and provisioning scripts.</p>
</li>
</ul>
</li>
</ol>
<p>It's important to choose a box that aligns with your development needs and matches the desired operating system and software stack. Official boxes are typically reliable and regularly updated, but custom boxes can provide more flexibility if you have specific requirements.</p>
<p>When selecting a box, consider factors such as the operating system version, software compatibility, available support, and the community around the box. Reading the documentation and reviews for each box can help you make an informed decision based on your specific use case.</p>
<ol>
<li><p>Creating and Starting a Vagrant Virtual Machine:</p>
<ul>
<li><p>Open PowerShell or Command Prompt.</p>
</li>
<li><p>Navigate to your project directory.</p>
</li>
<li><p>Execute the following commands to initialize and start a Vagrant virtual machine:</p>
<pre><code class="lang-sh">  vagrant init &lt;box-name&gt;
  vagrant up
</code></pre>
</li>
</ul>
</li>
<li><p>Accessing the Vagrant Virtual Machine:</p>
<ul>
<li><p>To SSH into the virtual machine, use the following command:</p>
<pre><code class="lang-sh">  vagrant ssh
</code></pre>
</li>
</ul>
</li>
<li><p>Managing Vagrant Virtual Machines:</p>
<p> Run outside of the virtual machine environment (e.g., default OS terminal).</p>
<ul>
<li><p>To stop a running virtual machine, use:</p>
<pre><code class="lang-sh">  vagrant halt
</code></pre>
</li>
<li><p>To destroy a virtual machine, use:</p>
<pre><code class="lang-sh">  vagrant destroy
</code></pre>
</li>
</ul>
</li>
<li><p>Creating and Managing VirtualBox Virtual Machines:</p>
<ul>
<li>Open VirtualBox Manager to create and manage virtual machines using a graphical interface.</li>
</ul>
</li>
</ol>
<ul>
<li>Alternatively, you can utilize the <code>VBoxManage</code> command-line tool for advanced management and automation.</li>
</ul>
<p>Harnessing the Power of Vagrant and VirtualBox: Vagrant and VirtualBox provide a streamlined approach to managing development environments, allowing developers to work in isolated, reproducible setups. These tools offer the following benefits:</p>
<ol>
<li><p>Consistency: Vagrant and VirtualBox ensure that every team member has an identical development environment, reducing compatibility issues.</p>
</li>
<li><p>Reproducibility: By defining project dependencies and configurations within Vagrant, developers can recreate the same environment across different machines.</p>
</li>
<li><p>Collaboration: With Vagrant, teams can easily share development environments, making it effortless to collaborate on projects.</p>
</li>
<li><p>Scalability: Vagrant simplifies the process of scaling environments by allowing the provisioning of multiple virtual machines.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this blog post, we explored the installation and utilization of Vagrant and VirtualBox on Windows using Choco and Brew. We highlighted the advantages of these tools and provided commands that enhance the development experience for Windows users. With Vagrant and VirtualBox, you can effortlessly create and manage consistent and reproducible virtual environments, simplifying the development process and boosting collaboration within teams. Embrace the power of Vagrant and VirtualBox to enhance your development workflow and take your projects to new heights.</p>
<hr />
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://www.vagrantup.com/docs">Vagrant Documentation</a></p>
</li>
<li><p><a target="_blank" href="https://www.virtualbox.org/wiki/Documentation">VirtualBox Documentation</a></p>
</li>
<li><p><a target="_blank" href="https://docs.chocolatey.org/en-us/">Choco Documentation</a></p>
</li>
<li><p><a target="_blank" href="https://docs.brew.sh/">Brew Documentation</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/hashicorp/vagrant">HashiCorp Vagrant GitHub Repository</a></p>
</li>
<li><p><a target="_blank" href="https://app.vagrantup.com/boxes/search">Vagrant Cloud</a></p>
</li>
</ul>
<p>Remember to explore these resources and refer to the official website of <a target="_blank" href="https://www.vagrantup.com/">Vagrant</a> and <a target="_blank" href="https://www.virtualbox.org/">Virtual Box</a> or head over to their documentation to ensure accurate and up-to-date information.</p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Linux Commands for File Permissions]]></title><description><![CDATA[Master essential Linux commands for efficient system administration and file management, along with file permissions and related commands.]]></description><link>https://techstack.hashnode.dev/linux-commands-for-file-permissions</link><guid isPermaLink="true">https://techstack.hashnode.dev/linux-commands-for-file-permissions</guid><category><![CDATA[Linux]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[file-permission]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Thu, 08 Jun 2023 21:21:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1686258944367/fe36b992-7f98-474b-9e8e-081921a42b7a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/10-linux-commands-for-file-permissions"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>In the Linux ecosystem, familiarity with essential commands and an understanding of file permissions are fundamental for efficient system administration and file management. In this blog post, we will explore a set of essential commands, including <code>cd</code>, <code>ls</code>, <code>pwd</code>, <code>less</code>, <code>file</code>, <code>ln</code>, <code>cp</code>, <code>mv</code>, <code>rm</code>, <code>mkdir</code>, <code>type</code>, <code>which</code>, <code>help</code>, and <code>man</code>. Additionally, we will delve into the concept of file permissions and cover related commands such as <code>chmod</code>, <code>sudo</code>, <code>su</code>, <code>chown</code>, <code>chgrp</code>, <code>id</code>, <code>groups</code>, <code>whoami</code>, <code>adduser</code>, <code>useradd</code>, and <code>addgroup</code>. By the end of this article, you will have a comprehensive understanding of these commands and their practical applications.</p>
<h2 id="heading-basic-linux-commands">Basic Linux Commands</h2>
<p>Linux provides a wide range of commands that are essential for efficient system administration and file management. Let's explore some of the basic Linux commands:</p>
<h3 id="heading-cd-change-directory">cd - Change Directory</h3>
<p>The <code>cd</code> command allows you to navigate between directories. Use it followed by the directory name to switch to a different directory. For example, to change to the <code>/home/user/documents</code> directory:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> /home/user/documents
</code></pre>
<h3 id="heading-ls-list-files-and-directories">ls - List Files and Directories</h3>
<p>The <code>ls</code> command lists the contents of a directory. Use it to view files and directories within the current directory. For example, to list the files and directories in the current directory:</p>
<pre><code class="lang-sh">ls
</code></pre>
<h3 id="heading-pwd-print-working-directory">pwd - Print Working Directory</h3>
<p>The <code>pwd</code> command displays the current working directory's absolute path. Use it to identify your current location within the file system. For example, to print the current working directory:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">pwd</span>
</code></pre>
<h3 id="heading-less-view-file-content">less - View File Content</h3>
<p>The <code>less</code> command allows you to view the contents of a file. It provides a pager interface for easy navigation within large files. For example, to view the content of a file named <code>example.txt</code>:</p>
<pre><code class="lang-sh">less example.txt
</code></pre>
<h3 id="heading-file-determine-file-type">file - Determine File Type</h3>
<p>The <code>file</code> command determines the file type of a given file. It examines the file's contents and provides information about its format. For example, to determine the file type of a file named <a target="_blank" href="http://script.sh"><code>script.sh</code></a>:</p>
<pre><code class="lang-sh">file script.sh
</code></pre>
<h3 id="heading-ln-create-links">ln - Create Links</h3>
<p>The <code>ln</code> command is used to create links between files. It can create hard links and symbolic (soft) links. For example, to create a symbolic link named <code>link</code> pointing to a file named <code>target</code>:</p>
<pre><code class="lang-sh">ln -s target link
</code></pre>
<h3 id="heading-cp-copy-files-and-directories">cp - Copy Files and Directories</h3>
<p>The <code>cp</code> command copies files and directories. It allows you to duplicate files and directories with different names or in different locations. For example, to copy a file named <code>source.txt</code> to a new file named <code>destination.txt</code>:</p>
<pre><code class="lang-sh">cp source.txt destination.txt
</code></pre>
<h3 id="heading-mv-moverename-files-and-directories">mv - Move/Rename Files and Directories</h3>
<p>The <code>mv</code> command moves or renames files and directories. It can be used to change the name of a file or move it to a different location. For example, to move a file named <code>file.txt</code> to a different directory:</p>
<pre><code class="lang-sh">mv file.txt /path/to/directory/
</code></pre>
<h3 id="heading-rm-remove-files-and-directories">rm - Remove Files and Directories</h3>
<p>The <code>rm</code> command removes files and directories. Use it with caution, as it permanently deletes files from the file system. For example, to remove a file named <code>unwanted.txt</code>:</p>
<pre><code class="lang-sh">rm unwanted.txt
</code></pre>
<h3 id="heading-mkdir-create-directories">mkdir - Create Directories</h3>
<p>The <code>mkdir</code> command creates directories (folders) in the file system. Use it to create new directories. For example, to create a directory named <code>docs</code>:</p>
<pre><code class="lang-sh">mkdir docs
</code></pre>
<h3 id="heading-type">type</h3>
<ul>
<li>Display Command Type:</li>
</ul>
<p>The <code>type</code> command displays the type of a command. It indicates whether a command is a shell built-in, an alias, a function, or an executable file. For example, to display the type of the <code>ls</code> command:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">type</span> ls
</code></pre>
<h3 id="heading-which-locate-command">which - Locate Command</h3>
<p>The <code>which</code> command locates the executable file associated with a given command. It displays the absolute path to the command's binary file. For example, to locate the executable for the <code>python</code> command:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">which</span> python
</code></pre>
<h3 id="heading-help-get-help-for-shell-built-in-commands">help - Get Help for Shell Built-in Commands</h3>
<p>The <code>help</code> command provides help and documentation for shell built-in commands. It displays information about the usage and options of a specific command. For example, to get help for the <code>cd</code> command:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">help</span> <span class="hljs-built_in">cd</span>
</code></pre>
<h3 id="heading-man-manual-pages">man - Manual Pages</h3>
<p>The <code>man</code> command displays the manual pages for a given command. It provides detailed information about command usage, options, and examples. For example, to view the manual page for the <code>ls</code> command:</p>
<pre><code class="lang-sh">man ls
</code></pre>
<h2 id="heading-file-permissions-and-related-commands">File Permissions and Related Commands</h2>
<p>File permissions play a crucial role in controlling access to files and directories. Let's explore some commands related to file permissions:</p>
<h3 id="heading-chmod-change-file-permissions">chmod - Change File Permissions</h3>
<p>The <code>chmod</code> command is used to change the permissions of a file or directory. It allows you to grant or revoke read, write, and execute permissions for users, groups, and others. For example, to add execute permission for the owner of a file named <a target="_blank" href="http://script.sh"><code>script.sh</code></a>:</p>
<pre><code class="lang-sh">chmod +x script.sh
</code></pre>
<h3 id="heading-sudo-execute-a-command-with-superuser-privileges">sudo - Execute a Command with Superuser Privileges</h3>
<p>The <code>sudo</code> command allows you to execute a command with superuser (root) privileges. It provides temporary administrative access for authorized users. For example, to install a package using <code>sudo</code>:</p>
<pre><code class="lang-sh">sudo apt-get install package_name
</code></pre>
<h3 id="heading-su-switch-user">su - Switch User</h3>
<p>The <code>su</code> command is used to switch to another user account. It enables you to execute commands with the privileges of the specified user. For example, to switch to the root user:</p>
<pre><code class="lang-sh">su -
</code></pre>
<h3 id="heading-chown-change-file-owner">chown - Change File Owner</h3>
<p>The <code>chown</code> command changes the owner of a file or directory. It allows you to transfer ownership to another user. For example, to change the owner of a file named <code>file.txt</code> to the user <code>newowner</code>:</p>
<pre><code class="lang-sh">chown newowner file.txt
</code></pre>
<h3 id="heading-chgrp-change-group-ownership">chgrp - Change Group Ownership</h3>
<p>The <code>chgrp</code> command changes the group ownership of a file or directory. It allows you to assign a different group to the file. For example, to change the group ownership of a file named <code>file.txt</code> to the group <code>newgroup</code>:</p>
<pre><code class="lang-sh">chgrp newgroup file.txt
</code></pre>
<h3 id="heading-id-display-user-and-group-information">id - Display User and Group Information</h3>
<p>The <code>id</code> command displays information about the current user and associated groups. It provides the user's UID (user ID) and GID (group ID). For example, to display user and group information:</p>
<pre><code class="lang-sh">id
</code></pre>
<h3 id="heading-groups-display-group-membership">groups - Display Group Membership</h3>
<p>The <code>groups</code> command shows the groups to which a user belongs. It lists the group names associated with the current user. For example, to display group membership:</p>
<pre><code class="lang-sh">groups
</code></pre>
<h3 id="heading-whoami-display-current-user">whoami - Display Current User</h3>
<p>The <code>whoami</code> command displays the username of the current user. It provides a quick way to identify the currently logged-in user. For example, to display the current user:</p>
<pre><code class="lang-sh">whoami
</code></pre>
<h3 id="heading-adduser-add-a-user">adduser - Add a User</h3>
<p>The <code>adduser</code> command is used to add a new user to the system. It creates a user account with the specified username and assigns a home directory. For example, to add a user named <code>newuser</code>:</p>
<pre><code class="lang-sh">adduser newuser
</code></pre>
<h3 id="heading-useradd-create-a-user-account">useradd - Create a User Account</h3>
<p>The <code>useradd</code> command creates a new user account. It allows you to specify various options, such as user ID, home directory, and login shell. For example, to create a user account named <code>newuser</code> with a home directory and the <code>/bin/bash</code> login shell:</p>
<pre><code class="lang-sh">useradd -m -s /bin/bash newuser
</code></pre>
<h3 id="heading-addgroup-add-a-group">addgroup - Add a Group</h3>
<p>The <code>addgroup</code> command adds a new group to the system. It creates a group with the specified group name and assigns a GID (group ID). For example, to add a group named <code>newgroup</code>:</p>
<pre><code class="lang-sh">addgroup newgroup
</code></pre>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this blog post, we have explored essential Linux commands for file management and system administration. We covered commands such as <code>cd</code>, <code>ls</code>, <code>pwd</code>, <code>less</code>, <code>file</code>, <code>ln</code>, <code>cp</code>, <code>mv</code>, <code>rm</code>, <code>mkdir</code>, <code>type</code>, <code>which</code>, <code>help</code>, and <code>man</code>. Additionally, we discussed the concept of file permissions and related commands such as <code>chmod</code>, <code>sudo</code>, <code>su</code>, <code>chown</code>, <code>chgrp</code>, <code>id</code>, <code>groups</code>, <code>whoami</code>, <code>adduser</code>, <code>useradd</code>, and <code>addgroup</code>. Mastering these commands and understanding file permissions will give you a solid foundation for effective Linux system management.</p>
<hr />
<h2 id="heading-references">References</h2>
<p>Here are some references you can explore to learn more about Linux commands and file permissions:</p>
<ol>
<li><p>Linux Documentation Project (TLDP): <a target="_blank" href="https://tldp.org/">https://tldp.org/</a></p>
<ul>
<li>The TLDP provides a comprehensive collection of Linux documentation, including guides, how-tos, and tutorials on various topics.</li>
</ul>
</li>
<li><p>GNU Core Utilities Manual: <a target="_blank" href="https://www.gnu.org/software/coreutils/manual/">https://www.gnu.org/software/coreutils/manual/</a></p>
<ul>
<li>The GNU Core Utilities manual provides detailed documentation on essential Linux commands, including <code>cd</code>, <code>ls</code>, <code>pwd</code>, <code>less</code>, <code>file</code>, <code>ln</code>, <code>cp</code>, <code>mv</code>, <code>rm</code>, <code>mkdir</code>, <code>type</code>, <code>which</code>, <code>help</code>, and <code>man</code>.</li>
</ul>
</li>
<li><p>Linux man pages: <a target="_blank" href="https://man7.org/linux/man-pages/">https://man7.org/linux/man-pages/</a></p>
<ul>
<li>The Linux man pages offer in-depth documentation for Linux commands. You can search for specific commands and explore their options, usage examples, and related information.</li>
</ul>
</li>
<li><p>Linux File Permission Tutorial: <a target="_blank" href="https://www.guru99.com/file-permissions.html">https://www.guru99.com/file-permissions.html</a></p>
<ul>
<li>This tutorial from Guru99 provides an overview of Linux file permissions, explaining the concepts of read, write, and execute permissions. It covers <code>chmod</code>, <code>chown</code>, and <code>chgrp</code> commands in detail.</li>
</ul>
</li>
<li><p>Linux File System/Structure Explained: <a target="_blank" href="https://linuxhandbook.com/linux-file-system-structure/">https://linuxhandbook.com/linux-file-system-structure/</a></p>
<ul>
<li>This article on Linux Handbook explains the Linux file system structure, including directories, files, and their relationships. Understanding the file system structure is essential for effective file management.</li>
</ul>
</li>
<li><p>Linux User and Group Management: <a target="_blank" href="https://www.tecmint.com/manage-users-and-groups-in-linux/">https://www.tecmint.com/manage-users-and-groups-in-linux/</a></p>
<ul>
<li>Tecmint provides a tutorial on managing users and groups in Linux. It covers commands like <code>adduser</code>, <code>useradd</code>, <code>addgroup</code>, and explains user and group administration concepts.</li>
</ul>
</li>
</ol>
<p>Remember to explore these resources and refer to the official documentation for your specific Linux distribution to ensure accurate and up-to-date information.</p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Mastering Basic Vim Commands]]></title><description><![CDATA[Discover essential Vim commands and shortcuts to enhance your productivity and streamline your workflow. Learn basic and advanced features in Vim]]></description><link>https://techstack.hashnode.dev/mastering-basic-vim-commands</link><guid isPermaLink="true">https://techstack.hashnode.dev/mastering-basic-vim-commands</guid><category><![CDATA[Linux]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[vim]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Mon, 05 Jun 2023 14:59:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685976735871/53e01cbc-7710-4085-9df8-c4cb63e6da6b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/09-mastering-the-basic-of-vim-commands"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>Vim is a powerful and efficient text editor that has gained popularity among programmers and developers due to its speed and versatility. With its extensive collection of commands and customizable features, Vim provides a seamless editing experience. In this blog post, we will explore some essential Vim commands and shortcuts that will enhance your productivity and help you streamline your workflow. From basic navigation to advanced functionalities, we will cover a range of commands to help you master Vim and become a more proficient software engineer.</p>
<h2 id="heading-installation">Installation</h2>
<p>To install Vim on your system, follow the steps below:</p>
<h3 id="heading-windows">Windows</h3>
<ol>
<li><p>Visit the <a target="_blank" href="https://www.vim.org/download.php">Vim for Windows website</a> and download the latest version of the installer.</p>
</li>
<li><p>Run the installer and follow the on-screen instructions to complete the installation process.</p>
</li>
<li><p>Once the installation is complete, you can open Vim by searching for "Vim" in the Start menu or by running it from the command prompt.</p>
</li>
</ol>
<p>I prefer using Chocolatey (<strong>choco</strong>) to install packages, so check out the installation steps below:</p>
<h3 id="heading-steps">Steps</h3>
<p>To install Chocolatey and use it to install Vim, follow these steps:</p>
<ol>
<li><p>Search for PowerShell and run it as an administrator on Windows.</p>
</li>
<li><p>Go to the Chocolatey <a target="_blank" href="https://chocolatey.org/install">installation page</a>.</p>
</li>
<li><p>If this is your first time installing Chocolatey on your operating system, execute the following command in your terminal, based on the instructions provided on the installation page:</p>
</li>
</ol>
<pre><code class="lang-powershell"><span class="hljs-built_in">Get-ExecutionPolicy</span>
</code></pre>
<ul>
<li>If the output is "Restricted", enter one of the commands below:</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> AllSigned
</code></pre>
<p>or</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span>
</code></pre>
<ul>
<li>Regardless of whether "Restricted" was the previous output or not, run the following command (copy and paste it into your terminal):</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span> <span class="hljs-literal">-Force</span>; [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol = [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol <span class="hljs-operator">-bor</span> <span class="hljs-number">3072</span>; <span class="hljs-built_in">iex</span> ((<span class="hljs-built_in">New-Object</span> System.Net.WebClient).DownloadString(<span class="hljs-string">'https://community.chocolatey.org/install.ps1'</span>))
</code></pre>
<ul>
<li>If there are no errors, check if Chocolatey was successfully installed by running the following command:</li>
</ul>
<pre><code class="lang-powershell">choco
</code></pre>
<p>If the output displays the version of Chocolatey you are using, it means the installation was successful.</p>
<ul>
<li>Now, search for the package you need (in this case, Vim) by visiting the <a target="_blank" href="https://community.chocolatey.org/packages">package search page</a>. Once you find the Vim package, execute the following command:</li>
</ul>
<pre><code class="lang-powershell">choco install vim
</code></pre>
<ul>
<li>Open any terminal of your choice and type <code>vim</code> to start using Vim:</li>
</ul>
<pre><code class="lang-powershell">vim
</code></pre>
<p>Opening files and directories in Vim is a straightforward process. To open a specific file, you can use the following command:</p>
<pre><code class="lang-sh">vim &lt;filename&gt;
</code></pre>
<p>For example, if you want to open the file named "<a target="_blank" href="http://README.md">README.md</a>," you would use the command:</p>
<pre><code class="lang-sh">vim README.md
</code></pre>
<p>On the other hand, if you wish to open a directory, use the following command:</p>
<pre><code class="lang-sh">vim &lt;directory&gt;
</code></pre>
<p>For instance, let's say you have a directory called "myProject," and you want to open it in Vim. You would execute the command:</p>
<pre><code class="lang-sh">vim myProject
</code></pre>
<p>By following these steps, you will be able to install Vim on your Windows system and begin using it for your text editing needs.</p>
<h3 id="heading-macos">macOS</h3>
<ol>
<li><p>Open the Terminal application.</p>
</li>
<li><p>Install Vim using Homebrew by executing the following command:</p>
</li>
</ol>
<pre><code class="lang-sh">brew install vim
</code></pre>
<h3 id="heading-linux-ubuntu">Linux (Ubuntu)</h3>
<ol>
<li><p>Open the Terminal application.</p>
</li>
<li><p>Install Vim using the package manager by executing the following command:</p>
</li>
</ol>
<pre><code class="lang-sh">sudo apt-get update
sudo apt-get install vim
</code></pre>
<p>Now that you have Vim installed on your system, let's dive into the basic commands and shortcuts that will help you get started.</p>
<h2 id="heading-getting-started-with-vim">Getting Started with Vim</h2>
<p>To open a file in Vim, use the following command:</p>
<pre><code class="lang-sh">vim &lt;filename&gt;
</code></pre>
<p>For example, to open a file named "example.txt," you would use the command:</p>
<pre><code class="lang-sh">vim example.txt
</code></pre>
<p>Once you have a file open in Vim, you'll be in normal mode, where you can navigate, edit, and execute commands.</p>
<h2 id="heading-navigating-and-editing">Navigating and Editing</h2>
<p>In the commands below make sure you press the <code>ESC</code> key before typing or pressing any of the commands.</p>
<h3 id="heading-moving-within-the-document">Moving within the Document</h3>
<ul>
<li><p><code>h</code> moves the cursor one character to the left.</p>
</li>
<li><p><code>j</code> moves the cursor one line down.</p>
</li>
<li><p><code>k</code> moves the cursor one line up.</p>
</li>
<li><p><code>l</code> moves the cursor one character to the right.</p>
</li>
<li><p><code>w</code> moves the cursor to the beginning of the next word.</p>
</li>
<li><p><code>b</code> moves the cursor to the beginning of the previous word.</p>
</li>
<li><p><code>0</code> (zero) moves the cursor to the beginning of the current line.</p>
</li>
<li><p><code>$</code> moves the cursor to the end of the current line.</p>
</li>
<li><p><code>gg</code> moves the cursor to the first line of the document.</p>
</li>
<li><p><code>G</code> moves the cursor to the last line of the document.</p>
</li>
<li><p><code>&lt;line-number&gt;G</code> moves the cursor to a specific line number.</p>
</li>
</ul>
<h3 id="heading-copying-cutting-and-pasting">Copying, Cutting, and Pasting</h3>
<ul>
<li><p><code>v</code> enters visual mode, allowing you to select text.</p>
</li>
<li><p><code>y</code> copies the selected text (yank).</p>
</li>
<li><p><code>d</code> cuts the selected text (delete).</p>
</li>
<li><p><code>p</code> pastes the copied or cut text after the cursor.</p>
</li>
<li><p><code>P</code> pastes the copied or cut text before the cursor.</p>
</li>
</ul>
<h3 id="heading-undoing-changes-and-quitting">Undoing Changes and Quitting</h3>
<ul>
<li><p><code>u</code> undoes the last change.</p>
</li>
<li><p><code>Ctrl + r</code> redo the last undone change.</p>
</li>
<li><p><code>:q</code> quits Vim (closes the current file).</p>
</li>
<li><p><code>:q!</code> quits Vim without saving changes.</p>
</li>
<li><p><code>:w</code> saves the changes to the current file.</p>
</li>
<li><p><code>:wq</code> saves the changes and quits Vim.</p>
</li>
</ul>
<h3 id="heading-searching-and-replacing">Searching and Replacing</h3>
<ul>
<li><p><code>/</code> enters search mode.</p>
</li>
<li><p>Type the search term and press Enter to search forward</p>
</li>
<li><p><code>?</code> enters backward search mode.</p>
</li>
<li><p>Type the search term and press Enter to search backward.</p>
</li>
<li><p><code>n</code> jumps to the next occurrence of the search term.</p>
</li>
<li><p><code>N</code> jumps to the previous occurrence of the search term.</p>
</li>
<li><p><code>:s/search-term/replacement</code> replaces the first occurrence of "search-term" with "replacement" in the current line.</p>
</li>
<li><p><code>:s/search-term/replacement/g</code> replaces all occurrences of "search-term" with "replacement" in the current line.</p>
</li>
<li><p><code>:%s/search-term/replacement/g</code> replaces all occurrences of "search-term" with "replacement" in the entire file.</p>
</li>
</ul>
<h2 id="heading-buffers-and-windows">Buffers and Windows</h2>
<p>Vim allows you to work with multiple files simultaneously using buffers and windows.</p>
<h3 id="heading-buffers">Buffers</h3>
<ul>
<li><p><code>:e &lt;filename&gt;</code> opens a file in a new buffer.</p>
</li>
<li><p><code>:ls</code> lists all open buffers.</p>
</li>
<li><p><code>:b &lt;buffer-number&gt;</code> switches to a specific buffer.</p>
</li>
<li><p><code>:bd</code> closes the current buffer.</p>
</li>
<li><p><code>:q</code> quits Vim if no other buffers are open.</p>
</li>
</ul>
<h3 id="heading-windows-1">Windows</h3>
<ul>
<li><p><code>:sp &lt;filename&gt;</code> splits the current window horizontally and opens the file in the new window.</p>
</li>
<li><p><code>:vsp &lt;filename&gt;</code> splits the current window vertically and opens the file in the new window.</p>
</li>
<li><p><code>Ctrl + w + w</code> switches between open windows.</p>
</li>
<li><p><code>Ctrl + w + h/j/k/l</code> moves the cursor to the window in the corresponding direction.</p>
</li>
<li><p><code>Ctrl + w + c</code> closes the current window.</p>
</li>
</ul>
<h2 id="heading-advanced-features">Advanced Features</h2>
<h3 id="heading-macros">Macros</h3>
<p>Macros allow you to record a sequence of commands and replay them.</p>
<ul>
<li><p><code>q&lt;register&gt;</code> starts recording a macro in the specified register (e.g., <code>qa</code> starts recording in register <code>a</code>).</p>
</li>
<li><p>Perform the desired commands.</p>
</li>
<li><p><code>q</code> stops recording the macro.</p>
</li>
<li><p><code>@&lt;register&gt;</code> replays the macro stored in the specified register (e.g., <code>@a</code> replays the macro stored in register <code>a</code>).</p>
</li>
</ul>
<h3 id="heading-marks">Marks</h3>
<p>Marks allow you to quickly navigate to specific locations within a file.</p>
<ul>
<li><p><code>m&lt;letter&gt;</code> sets a mark at the current cursor position (e.g., <code>ma</code> sets a mark named <code>a</code>).</p>
</li>
<li><p><code>'</code> followed by the mark letter jumps to the line where the mark is set (e.g., <code>'a</code> jumps to the line of mark <code>a</code>).</p>
</li>
<li><p><strong>followed by the mark letter jumps to the exact cursor position where the mark is set</strong> (e.g.,<code>a</code> jumps to the cursor position of mark <code>a</code>).</p>
</li>
</ul>
<h3 id="heading-plugins">Plugins</h3>
<p>Vim supports a vast ecosystem of plugins that extend its functionality. Here are a few popular plugins:</p>
<ul>
<li><p><a target="_blank" href="https://github.com/VundleVim/Vundle.vim">Vundle</a>: A plugin manager for Vim.</p>
</li>
<li><p><a target="_blank" href="https://github.com/preservim/nerdtree">NERDTree</a>: A file explorer plugin for Vim.</p>
</li>
<li><p><a target="_blank" href="https://github.com/ctrlpvim/ctrlp.vim">CtrlP</a>: A fuzzy file finder plugin for Vim.</p>
</li>
<li><p><a target="_blank" href="https://github.com/ycm-core/YouCompleteMe">YouCompleteMe</a>: A code completion plugin for Vim.</p>
</li>
</ul>
<p>These plugins can be installed and managed using plugin managers such as Vundle or Vim-Plug.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Vim is a powerful text editor with a steep learning curve, but mastering its commands and shortcuts can greatly enhance your productivity as a software engineer. We have covered some essential commands and functionalities in this blog post, including navigation, editing, searching, and advanced features like macros and marks. By exploring and practicing these commands, you'll become more proficient in Vim and be able to edit text efficiently and effectively.</p>
<p><em>Happy Vim editing!</em></p>
<hr />
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://www.vim.org/">Vim Official Website</a></p>
</li>
<li><p><a target="_blank" href="https://vimhelp.org/">Vim Documentation</a></p>
</li>
<li><p><a target="_blank" href="https://vim.rtorr.com/">Vim Cheat Sheet</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/vim/vim">Vim GitHub Repository</a></p>
</li>
</ul>
<hr />
]]></content:encoded></item><item><title><![CDATA[Mastering Basic Emacs Commands]]></title><description><![CDATA[Boost productivity with Emacs commands and shortcuts. Navigate, edit, search, and manage efficiently. Master Emacs for software engineering success.]]></description><link>https://techstack.hashnode.dev/mastering-basic-emacs-commands</link><guid isPermaLink="true">https://techstack.hashnode.dev/mastering-basic-emacs-commands</guid><category><![CDATA[Linux]]></category><category><![CDATA[Emacs]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sun, 04 Jun 2023 21:14:27 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685912530500/291e53e4-2e98-40f1-b5be-27870d3f94fe.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/08-mastering-the-basic-of-emacs-commands"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>Emacs is a versatile and highly customizable text editor that has been a favorite among programmers and writers for decades. With its extensive collection of commands and shortcuts, Emacs provides an efficient and powerful editing experience. This blog post will explore some essential Emacs commands and shortcuts that can significantly enhance your productivity. From basic navigation to advanced features, we will cover a range of commands to help you master Emacs and streamline your workflow.</p>
<h2 id="heading-installation">Installation</h2>
<p>For detailed instructions on installing Emacs, please refer to the <a target="_blank" href="https://www.gnu.org/software/emacs/download.html">official Emacs website</a>. However, if you're a Windows user, I'll provide you with a few commands to help you install Emacs.</p>
<h3 id="heading-steps">Steps</h3>
<p>To install Chocolatey and use it to install Emacs, follow these steps:</p>
<ol>
<li><p>Search for PowerShell and run it as an administrator on Windows.</p>
</li>
<li><p>Go to the Chocolatey <a target="_blank" href="https://chocolatey.org/install">installation page</a>.</p>
</li>
<li><p>If this is your first time installing Chocolatey on your operating system, execute the following command in your terminal, based on the instructions provided on the installation page:</p>
</li>
</ol>
<pre><code class="lang-powershell"><span class="hljs-built_in">Get-ExecutionPolicy</span>
</code></pre>
<ul>
<li>If the output is "Restricted", enter one of the commands below:</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> AllSigned
</code></pre>
<p>or</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span>
</code></pre>
<ul>
<li>Regardless of whether "Restricted" was the previous output or not, run the following command (copy and paste it into your terminal):</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span> <span class="hljs-literal">-Force</span>; [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol = [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol <span class="hljs-operator">-bor</span> <span class="hljs-number">3072</span>; <span class="hljs-built_in">iex</span> ((<span class="hljs-built_in">New-Object</span> System.Net.WebClient).DownloadString(<span class="hljs-string">'https://community.chocolatey.org/install.ps1'</span>))
</code></pre>
<ul>
<li>If there are no errors, check if Chocolatey was successfully installed by running the following command:</li>
</ul>
<pre><code class="lang-powershell">choco
</code></pre>
<p>If the output displays the version of Chocolatey you are using, it means the installation was successful.</p>
<ul>
<li>Now, search for the package you need (in this case, Emacs) by visiting the <a target="_blank" href="https://community.chocolatey.org/packages">package search page</a>. Once you find the Emacs package, execute the following command:</li>
</ul>
<pre><code class="lang-powershell">choco install emacs
</code></pre>
<ul>
<li>Open any terminal of your choice and type <code>emacs</code> to start using Emacs:</li>
</ul>
<pre><code class="lang-powershell">emacs
</code></pre>
<p>Opening files and directories in Emacs is a straightforward process. To open a specific file, you can use the following command:</p>
<pre><code class="lang-sh">emacs &lt;filename&gt;
</code></pre>
<p>For example, if you want to open the file named "<a target="_blank" href="http://README.md">README.md</a>," you would use the command:</p>
<pre><code class="lang-sh">emacs README.md
</code></pre>
<p>On the other hand, if you wish to open a directory, use the following command:</p>
<pre><code class="lang-sh">emacs &lt;directory&gt;
</code></pre>
<p>For instance, let's say you have a directory called "myProject," and you want to open it in Emacs. You would execute the command:</p>
<pre><code class="lang-sh">emacs myProject
</code></pre>
<p>By following these steps, you will be able to install Emacs on your Windows system and begin using it for your text editing needs.</p>
<h2 id="heading-getting-started-with-emacs">Getting Started with Emacs</h2>
<p>To open Emacs in the terminal, use the <code>emacs -Q -nw</code> command, and then use <code>Ctrl + x Ctrl + f</code> to open a file by typing the file name at the bottom of the terminal. The command <code>emacs -Q -nw</code> starts Emacs in the terminal without loading any configuration files, ensuring a clean environment. Once Emacs is running, you can access the drop-down menu by pressing <code>F10</code>.</p>
<blockquote>
<p><strong>Note:</strong> To save changes on Emacs use <code>Ctrl + x Ctrl + s</code>.</p>
</blockquote>
<h2 id="heading-navigating-and-editing">Navigating and Editing</h2>
<h3 id="heading-moving-within-the-document">Moving within the Document</h3>
<ul>
<li><p><code>Ctrl + f</code> moves the cursor forward one character.</p>
</li>
<li><p><code>Ctrl + p</code> moves the cursor backward one line.</p>
</li>
<li><p><code>Alt + f</code> moves the cursor forward one word.</p>
</li>
<li><p><code>Alt + b</code> moves the cursor backward one word.</p>
</li>
<li><p><code>Ctrl + a</code> moves the cursor to the beginning of the line.</p>
</li>
<li><p><code>Ctrl + e</code> moves the cursor to the end of the line.</p>
</li>
<li><p><code>Alt + a</code> moves the cursor to the beginning of the sentence.</p>
</li>
<li><p><code>Alt + e</code> moves the cursor to the end of the sentence.</p>
</li>
<li><p><code>Alt + Shift + }</code> moves the cursor to the previous paragraph.</p>
</li>
<li><p><code>Alt + Shift + {</code> moves the cursor to the next paragraph.</p>
</li>
<li><p><code>Alt + Shift + &lt;</code> moves the cursor to the beginning of the document.</p>
</li>
<li><p><code>Alt + Shift + &gt;</code> moves the cursor to the end of the document.</p>
</li>
<li><p><code>Alt + g g</code> prompts for a line number and jumps to that line.</p>
</li>
</ul>
<h3 id="heading-copying-cutting-and-pasting">Copying, Cutting, and Pasting</h3>
<ul>
<li><p><code>Ctrl + space + arrow</code> or <code>Ctrl + n/p/f/b</code> selects text.</p>
</li>
<li><p><code>Alt + w</code> copies the selected text to the <em>kill-ring</em>.</p>
</li>
<li><p><code>Ctrl + y</code> pastes the text from the <em>kill-ring</em>.</p>
</li>
<li><p><code>Ctrl + w</code> cuts the selected text and adds it to the <em>kill-ring</em>.</p>
</li>
<li><p><code>Ctrl + k</code> cuts text from the cursor position to the end of the line.</p>
</li>
<li><p><code>Ctrl + x backspace</code> cuts text from the cursor position to the beginning of the line.</p>
</li>
<li><p><code>Alt + Z .</code> cuts until the first occurrence of a specified character (e.g., <code>.</code>).</p>
</li>
<li><p><code>Esc + 2 Esc + d</code> deletes the next two words.</p>
</li>
</ul>
<h2 id="heading-undoing-changes-and-quitting">Undoing changes and Quitting</h2>
<ul>
<li><p>To undo your last action, press <code>Ctrl + x u</code>.</p>
</li>
<li><p>To quit Emacs, press <code>Ctrl + x Ctrl + c</code>.</p>
</li>
</ul>
<h3 id="heading-searching-and-replacing">Searching and Replacing</h3>
<ul>
<li><p><code>Ctrl + s</code> initiates a search. Type the desired search term and press <code>Ctrl + s</code> to find the next occurrence.</p>
</li>
<li><p><code>Ctrl + r</code> searches for the previous occurrence.</p>
</li>
<li><p><code>Alt + Shift + %</code> activates the search-and-replace functionality.</p>
</li>
</ul>
<h3 id="heading-buffers-and-frames">Buffers and Frames</h3>
<ul>
<li><p><code>Ctrl + x Ctrl + f</code> opens Dired (Directory Editor) file manager to open a document named <code>text.txt</code>.</p>
</li>
<li><p><code>Ctrl + x 0</code> removes or closes the current buffer frame.</p>
</li>
<li><p><code>Ctrl + x b</code> selects a different buffer.</p>
</li>
<li><p><code>Ctrl + x k</code> kills (closes) the current buffer.</p>
</li>
<li><p><code>Ctrl + h v</code> followed by a specific buffer name (e.g., <code>kill-ring</code>) opens the buffer frame.</p>
</li>
</ul>
<h2 id="heading-advanced-features">Advanced Features</h2>
<h3 id="heading-zooming">Zooming</h3>
<ul>
<li><p><code>Ctrl + x Ctrl + +</code> zooms in.</p>
</li>
<li><p><code>Ctrl + x Ctrl + -</code> zooms out.</p>
</li>
</ul>
<h3 id="heading-splitting-windows">Splitting Windows</h3>
<ul>
<li><p><code>Ctrl + x 2</code> splits the window horizontally.</p>
</li>
<li><p><code>Ctrl + x 3</code> splits the window vertically.</p>
</li>
<li><p><code>Ctrl + x 0</code> closes the split window.</p>
</li>
<li><p><code>Ctrl + x 4 f</code> opens a new frame on the right side in a vertical split.</p>
</li>
<li><p><code>Ctrl + x o</code> tabs over to the other frame.</p>
</li>
<li><p><code>Ctrl + x Ctrl + c</code> closes the current window.</p>
</li>
</ul>
<h2 id="heading-customizing-emacs-appearance-with-plugins">Customizing Emacs Appearance with Plugins</h2>
<p>Emacs is known for its highly customizable nature, allowing users to tailor the editor to their preferences. There are several plugins available that can enhance the appearance of Emacs and make it look better. Here are some popular plugins you can use to customize the appearance of Emacs:</p>
<h3 id="heading-doom-themes">doom-themes</h3>
<ul>
<li><strong>GitHub</strong>: <a target="_blank" href="https://github.com/hlissner/emacs-doom-themes">https://github.com/hlissner/emacs-doom-themes</a></li>
</ul>
<p>Doom-themes is a collection of customizable themes for Emacs that provide a sleek and modern look. It offers a variety of dark and light themes with different color schemes. To install doom-themes, you can use the package manager built into Emacs, such as <code>package.el</code> or <code>use-package</code>.</p>
<h3 id="heading-spacemacs-theme">spacemacs-theme</h3>
<ul>
<li><strong>GitHub</strong>: <a target="_blank" href="https://github.com/nashamri/spacemacs-theme">https://github.com/nashamri/spacemacs-theme</a></li>
</ul>
<p>Spacemacs-theme is another popular theme for Emacs inspired by the Spacemacs editor. It offers a visually appealing and well-balanced color scheme. Similar to doom-themes, you can install spacemacs-theme using Emacs' package manager.</p>
<h3 id="heading-all-the-icons">all-the-icons</h3>
<ul>
<li><strong>GitHub</strong>: <a target="_blank" href="https://github.com/domtronn/all-the-icons.el">https://github.com/domtronn/all-the-icons.el</a></li>
</ul>
<p>all-the-icons is a package that provides a set of scalable icons for Emacs. It enhances the visual appearance of various Emacs packages by adding icons next to file names, buffer names, and more. This package is commonly used in conjunction with other themes to provide a more visually appealing experience.</p>
<h3 id="heading-powerline">powerline</h3>
<ul>
<li><strong>GitHub</strong>: <a target="_blank" href="https://github.com/milkypostman/powerline">https://github.com/milkypostman/powerline</a></li>
</ul>
<p>Powerline is a plugin that creates a status bar with informative and customizable segments. It displays various information such as the current mode, line number, git branch, and more. Powerline enhances the overall look of Emacs by adding a stylish and informative status bar.</p>
<h3 id="heading-rainbow-delimiters">rainbow-delimiters</h3>
<ul>
<li><strong>GitHub</strong>: <a target="_blank" href="https://github.com/Fanael/rainbow-delimiters">https://github.com/Fanael/rainbow-delimiters</a></li>
</ul>
<p>Rainbow-delimiters is a simple but effective plugin that highlights parentheses, brackets, and braces with different colors. This plugin makes it easier to identify matching pairs and improves the readability of Lisp-like languages. It can be especially useful when working with complex nested structures.</p>
<h3 id="heading-which-key">which-key</h3>
<ul>
<li><strong>GitHub</strong>: <a target="_blank" href="https://github.com/justbur/emacs-which-key">https://github.com/justbur/emacs-which-key</a></li>
</ul>
<p>Which-key is a helpful plugin that displays key bindings and their associated commands in a popup window. It helps you discover and remember Emacs commands by showing the available options whenever you press a prefix key. Which-key improves the usability of Emacs by providing visual guidance and reducing the need to remember complex key sequences.</p>
<h3 id="heading-beacon">beacon</h3>
<ul>
<li><strong>GitHub</strong>: <a target="_blank" href="https://github.com/Malabarba/beacon">https://github.com/Malabarba/beacon</a></li>
</ul>
<p>Beacon is a small but useful plugin that highlights the cursor position whenever it jumps to a new location. It provides a visual indicator, such as a flashing beacon or a temporary background color change, to draw attention to the cursor. This can be particularly helpful when working with large documents or unfamiliar codebases.</p>
<p>These are just a few examples of the many plugins available for customizing the appearance of Emacs. To install these plugins, you can follow the installation instructions provided in their respective GitHub repositories. Remember to</p>
<p>consult the documentation and readme files of each plugin for configuration options and additional features.</p>
<p>By leveraging these plugins, you can transform the appearance of Emacs to suit your preferences and create a visually appealing and personalized editing environment.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Emacs provides extensive commands and shortcuts to enhance your editing experience. By mastering these commands, you can navigate through documents, edit text efficiently, search and replace, manage buffers and frames, and take advantage of advanced features such as zooming and window splitting. With time and practice, Emacs can become a powerful tool in your arsenal, enabling you to become a more productive and efficient software engineer.</p>
<p><em>Happy Emacs editing!</em></p>
<hr />
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/08-mastering-the-basic-of-emacs-commands">GitHub Repository</a></p>
</li>
<li><p><a target="_blank" href="https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf">GNU RefCard</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=jPkIaqSh3cA">YouTube</a></p>
</li>
</ul>
<hr />
]]></content:encoded></item><item><title><![CDATA[Understanding Flowcharts]]></title><description><![CDATA[Understanding Flowcharts: Visualize and optimize complex processes with a powerful visual tool for improved communication and process analysis.]]></description><link>https://techstack.hashnode.dev/understanding-flowcharts</link><guid isPermaLink="true">https://techstack.hashnode.dev/understanding-flowcharts</guid><category><![CDATA[Web Development]]></category><category><![CDATA[software development]]></category><category><![CDATA[flowcharts]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Tutorial]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Wed, 31 May 2023 11:07:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685530941879/6f8ffe72-0dee-481f-b5f9-3ede1479b198.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/05-writing-pseudocode-a-beginners-guide"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>Flowcharts are powerful tools that provide a visual representation of processes, allowing individuals to understand and analyze complex workflows. They are widely used in various industries, from software development to business management, to document and communicate processes effectively. In this article, we will explore the concept of flowcharts, their benefits, and how to create them.</p>
<h2 id="heading-what-is-a-flowchart">What is a Flowchart?</h2>
<p>A flowchart is a diagrammatic representation of a process or workflow. It uses different shapes and symbols to illustrate the sequence of steps, decision points, and flow of information or materials. Flowcharts provide a clear and concise overview of a process, making it easier to identify bottlenecks, inefficiencies, or opportunities for improvement.</p>
<h2 id="heading-benefits-of-flowcharts">Benefits of Flowcharts</h2>
<ul>
<li><p>Visual Clarity: Flowcharts present complex processes in a visually appealing and easy-to-understand manner, allowing stakeholders to grasp the overall process flow quickly.</p>
</li>
<li><p>Process Analysis: By examining a flowchart, individuals can identify potential issues, redundancies, or areas of improvement within a process.</p>
</li>
<li><p>Communication and Collaboration: Flowcharts serve as a common visual language, facilitating communication and collaboration among team members, stakeholders, and departments.</p>
</li>
<li><p>Standardization: Flowcharts help establish standardized procedures and guidelines by providing a visual representation of the preferred process flow.</p>
</li>
<li><p>Training and Onboarding: Flowcharts are valuable tools for training new employees, as they provide a step-by-step representation of processes and procedures.</p>
</li>
</ul>
<h2 id="heading-common-flowchart-symbols">Common Flowchart Symbols</h2>
<p>Flowcharts use various symbols to represent different elements of a process. Here are some commonly used symbols:</p>
<ul>
<li><p>Oval: Represents the start or end point of a process.</p>
</li>
<li><p>Rectangle: Depicts a specific step or activity within the process.</p>
</li>
<li><p>Diamond: Signifies decision points or branching paths based on a condition or criteria.</p>
</li>
<li><p>Arrow: Indicates the flow or direction of the process.</p>
</li>
<li><p>Parallelogram: Represents input or output of data.</p>
</li>
<li><p>Circle: Denotes connectors or join points for different parts of the flowchart.</p>
</li>
</ul>
<h2 id="heading-types-of-flowcharts">Types of Flowcharts</h2>
<ul>
<li><p>Process Flowchart: Illustrates the sequential steps of a process from start to finish.</p>
</li>
<li><p>Swimlane Flowchart: Organizes the process steps into lanes or columns, representing different departments, individuals, or responsibilities.</p>
</li>
<li><p>Data Flow Diagram: Focuses on the flow of data or information within a system or process.</p>
</li>
<li><p>Workflow Diagram: Demonstrates the movement of tasks or activities within a workflow, including dependencies and decision points.</p>
</li>
</ul>
<h2 id="heading-creating-a-flowchart">Creating a Flowchart</h2>
<p>To create an effective flowchart, follow these steps:</p>
<ul>
<li><p>Identify the process: Clearly define the process or workflow you want to represent in the flowchart.</p>
</li>
<li><p>Determine the symbols: Select the appropriate flowchart symbols to represent each step, decision point, or data input/output.</p>
</li>
<li><p>Define the flow: Connect the symbols using arrows to indicate the sequence and direction of the process flow.</p>
</li>
<li><p>Validate and refine: Review the flowchart for accuracy, clarity, and completeness. Make adjustments as necessary.</p>
</li>
<li><p>Share and collaborate: Share the flowchart with relevant stakeholders to gather feedback and ensure understanding.</p>
</li>
</ul>
<p>An example of a Flowchart with Pseudocode is shown below</p>
<p>Pseudocode:</p>
<pre><code class="lang-txt">1. Start
2. Input the temperature in Celsius
3. Calculate the temperature in Fahrenheit using the formula: Fahrenheit = (Celsius * 9/5) + 32
4. Display the temperature in Fahrenheit
5. End
</code></pre>
<p><a target="_blank" href="https://blog.techstackmedia.com/writing-pseudocode-a-beginners-guide">Check out the article on Pseudocode</a> to learn more.</p>
<p>Flowchart:</p>
<pre><code class="lang-txt">Start
↓
Input Celsius temperature
↓
Fahrenheit = (Celsius * 9/5) + 32
↓
Display Fahrenheit temperature
↓
End
</code></pre>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bgdteg50n1wmvmuszcuc.jpeg" alt="Image description" class="image--center mx-auto" /></p>
<p>Remember, a well-designed flowchart is not only visually appealing but also an accurate reflection of the underlying process. So, leverage the power of flowcharts to map, analyze, and improve your processes, and unlock new opportunities for efficiency and growth.</p>
<hr />
<h2 id="heading-references">References</h2>
<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/07-understanding-flowchart">GitHub Repository</a></p>
]]></content:encoded></item><item><title><![CDATA[A Comprehensive Guide to Git]]></title><description><![CDATA[A Comprehensive Guide to Git: Learn the basics of Git, essential commands, and collaboration techniques for efficient version control.]]></description><link>https://techstack.hashnode.dev/a-comprehensive-guide-to-git</link><guid isPermaLink="true">https://techstack.hashnode.dev/a-comprehensive-guide-to-git</guid><category><![CDATA[GitHub]]></category><category><![CDATA[Git]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Mon, 29 May 2023 12:04:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685359288337/0ced01c5-b072-4429-9e1b-5471481569e3.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/06-a-comprehensive-guide-to-git"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-introduction">Introduction</h2>
<p>Git has revolutionized the way developers collaborate and manage their code. Whether you're a beginner or an experienced developer, understanding the basic concepts and essential commands of Git is crucial for efficient version control. In this blog post, we'll explore the fundamental concepts of Git, including push, merge, branches, and more. We'll also provide code snippets to illustrate how these commands are used in practice. Let's dive in!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687370316703/9a4b9931-68e4-4ecc-974f-fe44c1830d82.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-installation">Installation</h2>
<p>For detailed instructions on installing Git, please refer to the <a target="_blank" href="https://git-scm.com/">official Git website</a>. However, if you're a Windows user, I'll provide you with a few commands to help you install Git.</p>
<h3 id="heading-steps">Steps</h3>
<p>To install Chocolatey and use it to install Git, follow these steps:</p>
<ol>
<li><p>Search for PowerShell and run it as an administrator on Windows.</p>
</li>
<li><p>Go to the Chocolatey <a target="_blank" href="https://chocolatey.org/install">installation page</a>.</p>
</li>
<li><p>If this is your first time installing Chocolatey on your operating system, execute the following command in your terminal, based on the instructions provided on the installation page:</p>
</li>
</ol>
<pre><code class="lang-powershell"><span class="hljs-built_in">Get-ExecutionPolicy</span>
</code></pre>
<ul>
<li>If the output is "Restricted", enter one of the commands below:</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> AllSigned
</code></pre>
<p>or</p>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span>
</code></pre>
<ul>
<li>Regardless of whether "Restricted" was the previous output or not, run the following command (copy and paste it into your terminal):</li>
</ul>
<pre><code class="lang-powershell"><span class="hljs-built_in">Set-ExecutionPolicy</span> Bypass <span class="hljs-literal">-Scope</span> <span class="hljs-keyword">Process</span> <span class="hljs-literal">-Force</span>; [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol = [<span class="hljs-type">System.Net.ServicePointManager</span>]::SecurityProtocol <span class="hljs-operator">-bor</span> <span class="hljs-number">3072</span>; <span class="hljs-built_in">iex</span> ((<span class="hljs-built_in">New-Object</span> System.Net.WebClient).DownloadString(<span class="hljs-string">'https://community.chocolatey.org/install.ps1'</span>))
</code></pre>
<ul>
<li>If there are no errors, check if Chocolatey was successfully installed by running the following command:</li>
</ul>
<pre><code class="lang-powershell">choco
</code></pre>
<p>If the output displays the version of Chocolatey you are using, it means the installation was successful.</p>
<ul>
<li>Now, search for the package you need (in this case, Git) by visiting the <a target="_blank" href="https://community.chocolatey.org/packages">package search page</a>. Once you find the Git package, execute the following command:</li>
</ul>
<pre><code class="lang-powershell">choco install git
</code></pre>
<h3 id="heading-basic-concepts">Basic Concepts</h3>
<p>Before we delve into the commands, let's quickly review some basic concepts of Git:</p>
<h4 id="heading-ls-la">ls -la</h4>
<p>The <code>ls -la</code> command (or <code>ls</code> on Windows) lists all files and directories, including hidden ones, in the current directory. It helps you get a comprehensive view of the files present.</p>
<h4 id="heading-git-commit-m-commit-msg-m-desc-msg">git commit -m "commit msg" -m "desc. msg"</h4>
<p>The <code>git commit</code> command records change to the repository. By specifying a commit message (<code>-m</code> flag), you provide a concise description of the changes made. It's good practice to include both a short commit message and a more detailed description.</p>
<h3 id="heading-generating-ssh-keys">Generating SSH Keys</h3>
<p>You can generate SSH keys to securely connect with remote repositories, such as GitHub. Here's a step-by-step guide:</p>
<h4 id="heading-generate-the-ssh-key">Generate the SSH key</h4>
<p>Use the <code>ssh-keygen</code> command to generate a new SSH key. For example:</p>
<pre><code class="lang-sh">ssh-keygen -t rsa -b 4096 -C <span class="hljs-string">"email@gmail.com"</span>
</code></pre>
<p>Its output will look like below:</p>
<pre><code class="lang-sh">Generating public/private rsa key pair.
Enter file <span class="hljs-keyword">in</span> <span class="hljs-built_in">which</span> to save the key (/c/Users/TechstackMedia - Osagie/.ssh/id_rsa):
</code></pre>
<p>Where it asks you to enter a file name, you can enter any file name of your choice but for the case of this tutorial enter <code>testkey</code> and press <code>Enter</code> or <code>Return</code>.</p>
<p>Now you will probably get another question as shown below:</p>
<pre><code class="lang-sh">Enter passphrase (empty <span class="hljs-keyword">for</span> no passphrase):
</code></pre>
<p>It is asking you to provide a passphrase for encryption or decryption purposes. It is used to protect sensitive data, such as private keys or encrypted files.</p>
<p>You may click enter meaning <code>empty for no passphase</code> but it is generally recommended to set a strong passphrase to enhance the security of your sensitive data.</p>
<h4 id="heading-locate-the-key-file">Locate the key file</h4>
<p>After generating the key, you can find it using the <code>ls</code> command combined with <code>grep</code>. For instance:</p>
<pre><code class="lang-sh">ls | grep testkey
</code></pre>
<p>Here, <code>testkey</code> is the file name containing the SSH key.</p>
<blockquote>
<p><strong>Note:</strong> the <code>testkey</code> without the .pub, its content should not be shared with anyone because it is the key you use to interact with GitHub.</p>
</blockquote>
<h4 id="heading-copy-the-public-key">Copy the public key</h4>
<p>The public key (with a <code>.pub</code> extension) is the key you'll upload to your GitHub interface. Use the following command to copy it to your clipboard:</p>
<p>Now in the terminal run:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">type</span> testkey.pub | clip
</code></pre>
<p>Or</p>
<pre><code class="lang-sh">cat testkey.pub <span class="hljs-comment"># copy the entire public key</span>
</code></pre>
<p>Alternatively, you can simply run the command below:</p>
<pre><code class="lang-sh">pbcopy &lt; testkey.pub
</code></pre>
<p>You might get the error shown below:</p>
<pre><code class="lang-sh"><span class="hljs-string">'pbcopy'</span> is not recognized as an internal or external <span class="hljs-built_in">command</span>,
operable program or batch file
</code></pre>
<p>If this is the case for you it means you are not using Linux or macOS to run the command. You must likely be on a Windows Operating System or any other Operating System not supporting the command. In such cases use the first method, <code>cat</code> <a target="_blank" href="http://testkey.pub"><code>testkey.pub</code></a> and copy whatever is the output or run <code>type testkey.pub | clip</code>.</p>
<h4 id="heading-add-the-ssh-key-on-github">Add the SSH key on GitHub</h4>
<p>Navigate to your GitHub account's settings, select <a target="_blank" href="https://github.com/settings/ssh/new">"SSH and GPG keys"</a>, and add a new SSH key. Paste the copied key into the designated field. Don't forget to fill in the "Title" field.</p>
<h4 id="heading-configure-the-local-git-command-interface">Configure the local Git command interface</h4>
<p>To ensure ssh-agent is running run the command:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">eval</span> <span class="hljs-string">"<span class="hljs-subst">$(ssh-agent -s)</span>"</span>
</code></pre>
<h4 id="heading-update-the-ssh-agent">Update the SSH agent</h4>
<p>Now add your SSH private key to the <code>ssh-agent</code> as show below:</p>
<pre><code class="lang-sh">ssh-add testkey
</code></pre>
<p>The command above ensures that the local Git command interface recognizes the new key, run the following command.</p>
<h3 id="heading-pushing-changes-to-a-remote-repository">Pushing Changes to a Remote Repository</h3>
<p>To push your local repository to a remote repository (e.g., GitHub), follow these steps:</p>
<h4 id="heading-identify-the-remote-repository">Identify the remote repository</h4>
<p>Use the <code>git remote -v</code> command to view the remote repositories connected to your local repository.</p>
<h4 id="heading-set-the-upstream-repository">Set the upstream repository</h4>
<p>When pushing for the first time, set the upstream repository with the <code>-u</code> or <code>--set-upstream</code> flag:</p>
<pre><code class="lang-sh">git push -u origin master
</code></pre>
<p>This tells Git to push to the specified repository by default.</p>
<h4 id="heading-subsequent-pushes">Subsequent pushes</h4>
<p>For subsequent pushes, you can use the simpler command <code>git push</code>, as Git remembers the upstream repository.</p>
<h3 id="heading-branches">Branches</h3>
<p>Branches allow for parallel development and isolating specific features or fixes. Let's explore some common branch-related commands:</p>
<h4 id="heading-creating-a-new-branch">Creating a new branch</h4>
<p>To create a new branch, use the <code>git checkout -b</code> command followed by the branch name. For example:</p>
<pre><code class="lang-sh">git checkout -b feature-readme-instructions
</code></pre>
<p>The command above does two actions, it creates a new branch called <code>feature-readme-instructions</code> and then checks out to that branch.</p>
<p>Below is the command breakdown:</p>
<pre><code class="lang-sh">git branch feature-readme-instructions
</code></pre>
<pre><code class="lang-sh">git checkout feature-readme-instructions
</code></pre>
<h4 id="heading-switching-between-branches">Switching between branches</h4>
<p>To switch to a different branch, use the <code>git checkout</code> command followed by the branch name. For instance:</p>
<pre><code class="lang-sh">git checkout master
</code></pre>
<h4 id="heading-viewing-changes-between-branches">Viewing changes between branches</h4>
<p>To see the code differences between the two branches, use the <code>git diff</code> command followed by the branch names:</p>
<pre><code class="lang-sh">git diff branchname
</code></pre>
<p>The <code>git diff</code> command shows the differences between the current branch and the specified branch.</p>
<h4 id="heading-merging-branches">Merging branches</h4>
<p>To merge changes from one branch into another, use the <code>git merge</code> command followed by the branch name. For example:</p>
<pre><code class="lang-sh">git merge branchname
</code></pre>
<h4 id="heading-deleting-a-branch">Deleting a branch</h4>
<p>To delete a branch, use the <code>git branch -d</code> command followed by the branch name. For instance:</p>
<pre><code class="lang-sh">git branch -d branchname
</code></pre>
<h3 id="heading-resolving-merge-conflicts">Resolving Merge Conflicts</h3>
<p>Sometimes, when merging branches, conflicts may arise when Git cannot automatically merge the changes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687370647549/725ab676-71df-442f-a336-bd3c4be2fb07.png" alt class="image--center mx-auto" /></p>
<p>Here's how to handle merge conflicts:</p>
<ul>
<li><p>Identify the conflicts: After attempting to merge branches, Git will notify you of any conflicts that occurred. You can use commands like <code>git status</code> or <code>git diff</code> to identify the conflicted files.</p>
</li>
<li><p>Open the conflicted files: Open the conflicted files in a text editor or an integrated development environment (IDE). Inside the files, you'll see the conflicting sections marked with special characters like <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code>, <code>=======</code>, and <code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687372663571/c58dfb90-39fd-4d01-85b9-eac9b61e5d18.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Resolve the conflicts: Manually edit the conflicted sections in the files to keep the desired changes and remove the conflicting content. Modify the files according to your intended final result.</p>
</li>
<li><p>Alternatively, when resolving conflict in Git, there are options to either <strong>accept current changes</strong> or <strong>accept incoming changes</strong> or <strong>accept both</strong> <strong>changes</strong>. Accepting current changes means accepting the changes that exist in your local repository before pulling from the remote repository. If you choose this option, you are discarding the incoming changes from the remote branch and keeping your local changes. Accept Incoming Changes means accepting the changes that exist in the remote repository. If you choose this option, you are discarding your local changes and taking the changes from the remote branch. Accept Both Changes In some cases, you may want to combine both sets of changes from your local and remote repositories. You can manually edit the conflicted sections to incorporate both sets of changes, keeping the parts you want from each version.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687370920141/e5c2de77-650c-4c1a-8f48-98e6906e8558.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>Once you have resolved the conflicts and made the necessary edits, you can save the changes, stage the resolved files, and commit them to complete the merge process.</p>
</li>
<li><p>Add the resolved files: Use the <code>git add</code> command to stage the resolved files for the commit. For example, you can use <code>git add file1.txt file2.txt</code> to stage-specific files, or <code>git add .</code> to stage all modified files in the current directory.</p>
</li>
<li><p>Commit the changes: Finally, use the <code>git commit</code> command to create a new commit with the resolved merge conflicts. You can provide a commit message using the <code>-m</code> flag, like <code>git commit -m "Resolve merge conflicts"</code>.</p>
</li>
</ul>
<h4 id="heading-committing-all-modified-files">Committing all modified files</h4>
<p>Use the <code>git commit -am "commit message"</code> command to commit all modified files, including those added to the repository.</p>
<p>Note that <code>git commit -am "commit message"</code> is the same as combining the two commands below:</p>
<pre><code class="lang-sh">git add -A
</code></pre>
<pre><code class="lang-sh">git commit -m <span class="hljs-string">"commit message"</span>
</code></pre>
<p><code>git add -A</code> is the same as <code>git add --all</code>. Most developers prefer using period in place of <code>--all</code> or <code>-A</code>.</p>
<pre><code class="lang-sh">git add .
</code></pre>
<h4 id="heading-unstaging-and-removing-specific-files">Unstaging and removing specific files</h4>
<p>To unstage and remove specific files, use the <code>git reset &lt;filename&gt;</code> command. If no filename is specified, <code>git reset</code> will show the files to be reset.</p>
<h4 id="heading-undoing-a-commit">Undoing a commit</h4>
<p>If you need to undo a commit, use the <code>git reset HEAD~1</code> command to move the pointer (<code>HEAD</code>) to the previous commit.</p>
<h4 id="heading-resetting-to-a-specific-commit">Resetting to a specific commit</h4>
<p>To reset to a specific commit, use the <code>git reset &lt;commit hash&gt;</code> command, replacing <code>&lt;commit hash&gt;</code> with the hash of the desired commit.</p>
<h4 id="heading-removing-all-commits-and-untracked-files">Removing all commits and untracked files</h4>
<p>In some cases, you may want to completely remove all commits and untracked files. Use <code>git reset --hard &lt;commit hash&gt;</code> to accomplish this.</p>
<h3 id="heading-collaboration-with-forks-and-pull-requests">Collaboration with Forks and Pull Requests</h3>
<p>When collaborating on open-source projects, forks and pull requests facilitate contribution. Here's an overview:</p>
<h4 id="heading-forking-a-repository">Forking a repository</h4>
<p>To contribute to a repository, you can create a fork of the original repository. This creates a copy of the repository under your account.</p>
<h4 id="heading-making-changes-and-creating-a-pull-request">Making changes and creating a pull request</h4>
<p>After forking the repository, make your desired changes in the forked repository. Then, create a pull request to propose your changes to the original repository.</p>
<h3 id="heading-additional-useful-commands">Additional Useful Commands</h3>
<h3 id="heading-git-clone">git clone</h3>
<p>When cloning a repository in Git, there are a few different ways to specify the source repository. Here are the common methods to clone a repository using the <code>git clone</code> command:</p>
<h4 id="heading-cloning-via-https">Cloning via HTTPS</h4>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> https://github.com/user/repo.git
</code></pre>
<p>This method uses the HTTPS protocol to clone the repository. You need to replace <code>user</code> with the username and <code>repo</code> with the name of the repository you want to clone.</p>
<h4 id="heading-cloning-via-ssh">Cloning via SSH</h4>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> git@github.com:user/repo.git
</code></pre>
<p>This method uses the SSH protocol to clone the repository. Again, replace <code>user</code> with the username and <code>repo</code> with the repository name.</p>
<h4 id="heading-cloning-via-git-protocol">Cloning via Git Protocol</h4>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> git://github.com/user/repo.git
</code></pre>
<p>The Git protocol is a lightweight protocol specifically for Git. This method clones the repository using the Git protocol.</p>
<h4 id="heading-cloning-via-subversion-svn-bridge">Cloning via Subversion (SVN) Bridge</h4>
<pre><code class="lang-sh">git svn <span class="hljs-built_in">clone</span> svn://svn.example.com/repo
</code></pre>
<p>If the repository is a Subversion (SVN) repository, you can use the <code>git svn clone</code> command to clone it. Replace <code>svn://</code><a target="_blank" href="http://svn.example.com/repo"><code>svn.example.com/repo</code></a> with the URL of the SVN repository.</p>
<h4 id="heading-cloning-a-local-repository">Cloning a Local Repository</h4>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> /path/to/repository
</code></pre>
<p>If the repository is already on your local machine, you can specify the local path to clone it.</p>
<h4 id="heading-cloning-a-bare-repository">Cloning a Bare Repository</h4>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> --bare https://github.com/user/repo.git
</code></pre>
<p>The <code>--bare</code> option is used to clone a repository as a bare repository, which means it will not have a working directory. This is useful when you only need the repository's history and don't plan on making changes directly in the cloned repository.</p>
<p>These are the main methods to clone a repository using the <code>git clone</code> command. Choose the appropriate method based on the type and location of the repository you want to clone.</p>
<h4 id="heading-cloning-private-repository">Cloning Private Repository</h4>
<p>When cloning a private repository on GitHub, you can use a personal access token (PAT) to authenticate and include it in the URL when using the <code>git clone</code> command. This allows you to securely clone the repository without having to enter your GitHub username and password.</p>
<p>The syntax for cloning a repository using a personal access token is as follows:</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> https://&lt;token&gt;@github.com/&lt;username&gt;/repo.git
</code></pre>
<p>Here's how to use it:</p>
<ol>
<li><p>Generate a Personal Access Token (PAT) on GitHub:</p>
<ul>
<li><p>Go to your GitHub account settings.</p>
</li>
<li><p>Navigate to "Developer settings" and click on "Personal access tokens".</p>
</li>
<li><p>Click on "Generate new token" and provide a meaningful description for the token.</p>
</li>
<li><p>Select the desired scopes/permissions for the token. For cloning a private repository, make sure to include the <code>repo</code> scope.</p>
</li>
<li><p>Click on "Generate token" and make a note of the generated token.</p>
</li>
</ul>
</li>
<li><p>Clone the repository using the PAT:</p>
<ul>
<li><p>In the <code>git clone</code> command, replace <code>&lt;token&gt;</code> with the personal access token you generated.</p>
</li>
<li><p>Replace <code>&lt;username&gt;</code> with your GitHub username.</p>
</li>
<li><p>Replace <code>repo.git</code> with the name of the repository you want to clone.</p>
</li>
</ul>
</li>
</ol>
<p>For example:</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">clone</span> https://your-token@github.com/your-username/repo.git
</code></pre>
<p>By including your personal access token in the URL, Git will use it to authenticate and allow you to clone the private repository without any manual authentication steps.</p>
<p>Remember to keep your personal access token secure and avoid sharing it with others, as it provides access to your GitHub account.</p>
<p>If at any point you have generated a new token, you can run the command (in the repo directory) in the format shown below:</p>
<pre><code class="lang-bash">git remote set-url origin https://your-new-token@github.com/your-username/repo.git
</code></pre>
<p>By running the command above, you will update the remote URL of the repository to use the new token, allowing you to authenticate and interact with the repository using the updated token.</p>
<h4 id="heading-git-add">git add</h4>
<p>The <code>git add</code> command is used to stage changes for the next commit. You can use it to specify individual files or directories to add. For example:</p>
<pre><code class="lang-sh">git add file1.txt
git add directory/
</code></pre>
<h4 id="heading-git-log">git log</h4>
<p>The <code>git log</code> command displays a history of commits in reverse chronological order. It shows the commit hash, author, date, and commit message. You can use flags like <code>--oneline</code> for a more concise output or <code>--graph</code> for a graphical representation of branch history. For example:</p>
<pre><code class="lang-sh">git <span class="hljs-built_in">log</span> --oneline
git <span class="hljs-built_in">log</span> --graph
</code></pre>
<h4 id="heading-git-diff">git diff</h4>
<p>The <code>git diff</code> command shows the differences between the working directory and the staging area (changes not yet staged) or between the staging area and the repository (changes staged but not yet committed). It helps you review changes before committing. For example:</p>
<pre><code class="lang-sh">git diff              <span class="hljs-comment"># Show unstaged changes</span>
git diff --staged     <span class="hljs-comment"># Show staged changes</span>
</code></pre>
<h4 id="heading-git-pull">git pull</h4>
<p>The <code>git pull</code> command is used to fetch and integrate changes from a remote repository into the current branch. It combines the <code>git fetch</code> and <code>git merge</code> commands. For example:</p>
<pre><code class="lang-sh">git pull origin master
</code></pre>
<p>This command fetches changes from the <code>origin</code> remote repository and merges them into the current branch.</p>
<p>Note: The code snippets provided assume a Unix-based operating system. Windows users may need to adjust certain commands or use alternative commands specific to their environment. For Windows users <a target="_blank" href="https://git-scm.com/downloads">try installing a good terminal emulator like Git Bash</a>.</p>
<hr />
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://blog.techstackmedia.com/files-manipulation">GitHub Repository</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=RGOj5yH7evk&amp;t=2505s">YouTube</a></p>
</li>
</ul>
<hr />
]]></content:encoded></item><item><title><![CDATA[Writing Pseudocode: A Beginner's Guide]]></title><description><![CDATA[Learn the fundamentals of pseudocode, a high-level representation of code that simplifies complex algorithms.]]></description><link>https://techstack.hashnode.dev/writing-pseudocode-a-beginners-guide</link><guid isPermaLink="true">https://techstack.hashnode.dev/writing-pseudocode-a-beginners-guide</guid><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[pseudocode]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sun, 28 May 2023 17:59:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685296083748/5374256d-88c9-4e63-8a58-cc68c7f89bcd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/07-understanding-flowchart"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<p><strong>Pseudocode</strong> is a valuable tool for expressing algorithms in a high-level and abstract manner. It serves as a bridge between human understanding and actual programming languages. In this blog post, we will explore what pseudocode is, and its purpose, and provide examples of its usage in real-life scenarios.</p>
<h2 id="heading-what-is-pseudocode">What is Pseudocode?</h2>
<p>Pseudocode is not an actual programming language but a representation of code that resembles a programming language without adhering to its strict syntax rules. The term <em>pseudo</em> refers to something false or fake, indicating that pseudocode is a simulated version of code. It allows programmers to focus on the logic and functionality of an algorithm rather than the specific language syntax.</p>
<h2 id="heading-the-purpose-of-pseudocode">The Purpose of Pseudocode</h2>
<p>The primary purpose of pseudocode is to provide a high-level and abstract representation of an algorithm, independent of any particular programming language. By using pseudocode, programmers can simplify complex problems, avoid language-specific limitations, and facilitate understanding and implementation across different languages.</p>
<p>Pseudocode acts as a communication tool between programmers, enabling them to discuss and share algorithms without being constrained by specific programming languages. It allows for flexibility, as the same algorithm can be implemented in different languages based on the pseudocode's logic and structure.</p>
<h2 id="heading-exam-board-pseudocode">Exam Board Pseudocode</h2>
<p>In academic settings, exam boards often use standardized pseudocode in their questions and marking schemes. While these standardized versions of pseudocode may differ slightly between exam boards, they serve the purpose of ensuring consistency and ease of evaluation. However, it's important to note that these specific syntax rules are often only applicable within the context of exams and may not reflect real-world pseudocode usage.</p>
<h2 id="heading-real-life-examples">Real-Life Examples</h2>
<p>To understand how pseudocode is used in practice, let's examine some real-life examples. One such example can be found in university textbooks, where complex algorithms are explained using pseudocode. These textbooks often present machine learning algorithms, such as decision trees, and provide pseudocode representations to illustrate their functionality.</p>
<p>While the pseudocode in textbooks may appear different from what you encounter in exams, the core concepts remain the same. Pseudocode still utilizes familiar programming constructs like <em>functions</em>, <em>parameters</em>, <em>conditionals</em> (<em>if-else statements</em>), <em>loops</em>, and <em>variables</em>. The notation used in these examples simplifies the algorithm's implementation while excluding language-specific details.</p>
<p>Using pseudocode instead of actual programming languages has several advantages. Pseudocode condenses complex algorithms into concise representations, making them easier to understand. It also allows for algorithm portability, enabling programmers to implement the same logic across different programming languages. Additionally, pseudocode serves as a future-proof solution since it remains relevant even as programming languages evolve.</p>
<h2 id="heading-understanding-pseudocode">Understanding Pseudocode</h2>
<p>Pseudocode is a simulated version of code that resembles a programming language but does not adhere to its strict syntax rules. It aims to focus on the logic and functionality of an algorithm, making it independent of any specific programming language. Pseudocode facilitates communication among programmers and enables the implementation of algorithms across different languages.</p>
<h2 id="heading-writing-pseudocode">Writing Pseudocode</h2>
<p>When writing pseudocode, remember that there is no one correct syntax. It's more important to focus on the algorithm's logic and functionality rather than adhering to specific formatting rules. Pseudocode should be clear and easily understandable by competent programmers familiar with the problem domain.</p>
<p>To illustrate the process of writing pseudocode, let's consider an example.</p>
<pre><code class="lang-txt">Example pseudocode for finding the average of two numbers.

Main program
input1 = get user input for number1
input2 = get user input for number2
result = calculateAverage(input1, input2)
display result
</code></pre>
<p>If I was to implement the logic in code using JavaScript, it would look like the example below:</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">calculateAverage</span>(<span class="hljs-params">number1, number2</span>) </span>{
    sum = number1 + number2
    average = sum / <span class="hljs-number">2</span>
    <span class="hljs-keyword">return</span> average
}

calculateAverage(<span class="hljs-number">2</span>, <span class="hljs-number">8</span>)
</code></pre>
<p>In this example, we define a function <code>calculateAverage</code> that takes two numbers as input, calculates their sum, computes the average, and returns it. The main program obtains user inputs, calls the <code>calculateAverage</code> function, and displays the result.</p>
<p>Here is another example:</p>
<pre><code class="lang-txt">The Problem:
Write a program that prints the number from 1 to 20:

For multiples of three print `"FIZZ"` instead of the number
For the multiple of five print `"Buzz"` instead of the number
For numbers which are multiples of both three and five print `"FizzBuzz"`
For numbers not divisible by 3, 5, or both print the number as it is.
</code></pre>
<p>The pseudocode would look like this:</p>
<pre><code class="lang-txt">FOR LOOP:
SET counter to 1
Break when counter reaches 20
Increment counter by 1
    IF number MOD 15 === 0
        print 'FizzBuzz'
    ELSE IF number MOD 3 === 0
        print 'Fizz'
    ELSE iF number MOD 5 === 0
        print 'Buzz'
    ELSE
        print number
</code></pre>
<p>Someone else could write the code as shown below and they will mean the same:</p>
<pre><code class="lang-txt">FOR i = 1 to 20 DO
    IF i is divisible by 3 and 5 THEN
        PRINT "FizzBuzz"
    ELSE IF i is divisible by 3 THEN
        PRINT "Fizz"
    ELSE IF i is divisible by 5 THEN
        PRINT "Buzz"
    ELSE
        PRINT i
    END IF
END FOR
</code></pre>
<p>The code snippets show that writing pseudocode is based on your pattern.</p>
<blockquote>
<p><strong>Note:</strong> Using this keyword like <code>FOR</code>, <code>IF</code>, <code>ELSE IF</code> <code>ELSE</code>, <code>END</code>, etc. are not mandatory because Pseudocode is flexible and allows for the use of alternative keywords or descriptive phrases as long as they effectively convey the intended logic and structure of the algorithm.</p>
</blockquote>
<p>For example, instead of using <code>FOR</code>, you could use <code>REPEAT</code> or <code>LOOP</code>. Similarly, instead of <code>END</code>, you could use <code>STOP</code> or <code>FINISH</code>. The key is to maintain consistency within your pseudocode and ensure that the chosen keywords or phrases accurately represent the intended flow of the algorithm. The example below is the same as the pseudocode above but with a different approach.</p>
<pre><code class="lang-txt">Set i as 1
Repeat until i reaches 20:
    If i is divisible by both 3 and 5:
        Output "FizzBuzz"
    Otherwise, if i is divisible by 3:
        Output "Fizz"
    Otherwise, if i is divisible by 5:
        Output "Buzz"
    Otherwise:
        Output i
    Increment i by 1
End repeat
</code></pre>
<p>The code in JavaScript would look like this:</p>
<pre><code class="lang-js"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">20</span>; i++) {
    <span class="hljs-keyword">if</span> (i % <span class="hljs-number">15</span> === <span class="hljs-number">0</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'FizzBuzz'</span>)
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (i % <span class="hljs-number">3</span> === <span class="hljs-number">0</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Fizz'</span>)
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (i % <span class="hljs-number">5</span> === <span class="hljs-number">0</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Buzz'</span>)
    } <span class="hljs-keyword">else</span> {
        <span class="hljs-built_in">console</span>.log(i)
    }
}
</code></pre>
<p>As you can see, the pseudocode resembles a programming language but avoids specific syntax requirements.</p>
<h3 id="heading-tips-for-writing-pseudocode">Tips for Writing Pseudocode</h3>
<h4 id="heading-familiarize-yourself-with-real-code">Familiarize Yourself with Real Code</h4>
<p>To effectively write and understand pseudocode, it is crucial to have a foundation in a real programming language. Learning a programming language such as Python or Java will provide you with the necessary knowledge and concepts to express algorithms in pseudocode.</p>
<h4 id="heading-simplify-and-generalize">Simplify and Generalize</h4>
<p>When writing pseudocode, aim to simplify the code by excluding language-specific details and unnecessary complexities. Make it as general as possible while retaining clarity and readability. Remember, pseudocode is a high-level representation, so focus on expressing the algorithm's logic rather than the specific syntax.</p>
<h4 id="heading-be-consistent">Be Consistent</h4>
<p>Maintain consistency in your pseudocode by using a uniform style and notation throughout. Choose a convention for variable assignment, function calls, and control structures (such as braces or indentation) and stick to it. Inconsistencies can lead to confusion and may result in lower marks in examinations.</p>
<h4 id="heading-practice-problem-solving">Practice Problem Solving</h4>
<p>To improve your pseudocode writing skills, engage in problem-solving exercises that require expressing solutions using pseudocode. Work through algorithmic questions and practice implementing the logic in pseudocode. This practice will enhance your ability to translate real-world problems into pseudocode representations.</p>
<h4 id="heading-learn-from-examples-and-resources">Learn from Examples and Resources</h4>
<p>Study examples of pseudocode from textbooks, online resources, and tutorial videos. Analyze how experts express complex algorithms in pseudocode and learn from their approach. Additionally, seek out resources specific to your academic curriculum or exam board for standardized pseudocode guidelines.</p>
<h4 id="heading-remember-pseudocode-is-not-executable-code">Remember, Pseudocode Is Not Executable Code</h4>
<p>Always keep in mind that pseudocode is a simplified representation and is not meant to be executed as actual code. It is a tool for communicating algorithmic ideas, not a programming language itself. Therefore, don't stress over small syntax details or worry about the code's executability.</p>
<hr />
<h2 id="heading-references">References</h2>
<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/05-writing-pseudocode-a-beginners-guide">GitHub Repository</a></p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Exploring File Contents with Common Commands in Linux]]></title><description><![CDATA[Discover essential commands to examine and manipulate text files in Linux efficiently. Learn how to utilize head, tail, etc. for effective file analysis.j]]></description><link>https://techstack.hashnode.dev/exploring-file-contents-with-common-commands-in-linux</link><guid isPermaLink="true">https://techstack.hashnode.dev/exploring-file-contents-with-common-commands-in-linux</guid><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Linux]]></category><category><![CDATA[linux for beginners]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sun, 28 May 2023 09:40:28 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685266439850/edaca938-cc47-4a9f-b03c-a5349c33c33d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/04-exploring-file-contents-with-common-commands-in-linux"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="Exploring File Contents with Common Commands in Linux Cover" class="image--center mx-auto" /></a></p>
<p>In Linux, there are several commands you can use to examine the contents of text files. Let's take a closer look at these commands, their functionalities, and how they can be used effectively.</p>
<p>You can use the following commands to look at the contents of text files:</p>
<ul>
<li><p><code>head</code></p>
</li>
<li><p><code>tail</code></p>
</li>
<li><p><code>cat</code></p>
</li>
<li><p><code>less</code></p>
</li>
<li><p><code>echo</code></p>
</li>
<li><p><code>wc</code></p>
</li>
<li><p><code>grep</code></p>
</li>
</ul>
<h3 id="heading-head"><code>head</code></h3>
<p>The <code>head</code> command displays the first part of a file. By default, it shows the first 10 lines, but you can specify a different number using the <code>-n</code> flag.</p>
<pre><code class="lang-sh">head &lt;filename&gt;
</code></pre>
<pre><code class="lang-sh">head README.md
</code></pre>
<p>If you want to specify a different number <code>-n</code> of lines to show, run the code in the format</p>
<pre><code class="lang-sh">head -n &lt;number of lines&gt; &lt;filename&gt;
</code></pre>
<pre><code class="lang-sh">head -n 6 README.md
</code></pre>
<h3 id="heading-tail"><code>tail</code></h3>
<p>The <code>tail</code> command prints the last 10 lines of a file. You can also customize the number of lines to be displayed by using the <code>-n</code> flag. Additionally, the <code>-f</code> flag allows you to continuously monitor changes made to a file, which is useful for log files.</p>
<pre><code class="lang-sh">tail &lt;filename&gt;
</code></pre>
<pre><code class="lang-sh">tail README.md
</code></pre>
<p>If you want to specify a different number <code>-n</code> of lines to show, run the code in the format</p>
<pre><code class="lang-sh">head -n &lt;number of lines&gt; &lt;filename&gt;
</code></pre>
<pre><code class="lang-sh">tail -n 5 README.md
</code></pre>
<h3 id="heading-cat"><code>cat</code></h3>
<p>The <code>cat</code> command is versatile and can be used for multiple purposes. Primarily, it prints the content of a file to the standard output. It can also be used to concatenate files or create new ones.</p>
<p>Printing the content of a file:</p>
<pre><code class="lang-sh">cat &lt;filename&gt;
</code></pre>
<pre><code class="lang-sh">cat README.md
</code></pre>
<p>Concatenating multiple files into a new file:</p>
<pre><code class="lang-sh">cat doc.txt contribute.txt &gt; combine.txt
</code></pre>
<p>Creating a new file:</p>
<pre><code class="lang-sh">cat &gt; newfile.txt
</code></pre>
<h3 id="heading-less"><code>less</code></h3>
<p>The <code>less</code> command provides an interactive and user-friendly way to view file content. It displays file contents in a paginated manner, allowing you to scroll, search, and navigate easily.</p>
<pre><code class="lang-sh">less README.md
</code></pre>
<p>Useful commands within less:</p>
<ul>
<li><p>b: Scroll up one page</p>
</li>
<li><p>G: Go to the end of the file</p>
</li>
<li><p>g: Go to the beginning of the file</p>
</li>
<li><p>q: Quit the command</p>
</li>
</ul>
<h3 id="heading-echo"><code>echo</code></h3>
<p>The <code>echo</code> command prints the argument passed to it to the output.</p>
<pre><code class="lang-sh"><span class="hljs-built_in">echo</span> <span class="hljs-string">'Hello world'</span>
</code></pre>
<h3 id="heading-wc"><code>wc</code></h3>
<p>The <code>wc</code> command, short for word count, provides information about a given input, such as the number of lines, words, and bytes in the content.</p>
<p>Options for <code>wc</code>:</p>
<p><code>-l</code>: Prints the newline count <code>-m</code>: Prints the character count <code>-c</code>: Prints the byte count <code>-w</code>: Prints the word count</p>
<p>For example:</p>
<pre><code class="lang-sh">wc -l README.md
</code></pre>
<h3 id="heading-grep"><code>grep</code></h3>
<p>The <code>grep</code> command is a powerful text manipulation tool that allows you to filter the content of a file based on a specific pattern. It displays only the lines that match the given pattern.</p>
<p>For instance, if you want to see all lines in a file that include the word "command," you can use <code>grep</code> in combination with <code>cat</code>:</p>
<pre><code class="lang-sh">cat README.md | grep <span class="hljs-built_in">command</span>
</code></pre>
<p>In this command, the output of <code>cat</code> <a target="_blank" href="http://README.md"><code>README.md</code></a> is piped (<code>|</code>) to <code>grep command</code> for further filtering.</p>
<p>These commands provide a solid foundation for examining and manipulating file content in Linux. With their flexibility and varied functionalities, you can efficiently navigate and process text files according to your needs.</p>
<blockquote>
<p><strong>Note:</strong> The examples provided here are simplified, and there are many more options and use cases for each command. Further exploration and practice will enhance your understanding and proficiency in working with these commands.</p>
</blockquote>
<p>Let me know if you have any questions or need further assistance!</p>
<hr />
<h2 id="heading-references">References</h2>
<ul>
<li><p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/04-exploring-file-contents-with-common-commands-in-linux">GitHub Repository</a></p>
</li>
<li><p><a target="_blank" href="https://phoenixnap.com/kb/linux-commands-cheat-sheet">Linux Command Line Cheat Sheet</a></p>
</li>
</ul>
<hr />
]]></content:encoded></item><item><title><![CDATA[Mastering Linux Command Line]]></title><description><![CDATA[Discover the essential techniques to navigate the Linux command line effectively. Learn how to unlock the power of Linux command line tools]]></description><link>https://techstack.hashnode.dev/mastering-linux-command-line</link><guid isPermaLink="true">https://techstack.hashnode.dev/mastering-linux-command-line</guid><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sat, 27 May 2023 17:56:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685209889209/19b1c5fc-e67c-46fa-95ef-5b55e5ea055b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/03-mastering-linux-command-line"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<p>The Linux command line is a powerful tool for executing tasks and managing your system efficiently. However, to navigate the command line with confidence, it's essential to identify the type of command you're working with. Linux offers several methods to determine the nature of a command, such as the <code>type</code>, <code>which</code>, <code>help</code>, and <code>man</code> commands.</p>
<p>In this comprehensive guide, we'll explore these command identification techniques and delve into the documentation available for each command type. By understanding how to identify commands accurately and access their documentation, you'll gain a deeper understanding of the command line ecosystem and unleash the full potential of Linux command line tools.</p>
<p>Let's dive in and discover how these methods can enhance your command line proficiency.</p>
<ul>
<li><p><code>type</code></p>
</li>
<li><p><code>which</code></p>
</li>
<li><p><code>help</code></p>
</li>
<li><p><code>man</code></p>
</li>
</ul>
<h2 id="heading-command-identification">Command Identification</h2>
<h3 id="heading-the-type-command">The <code>type</code> Command</h3>
<p>The <code>type</code> command serves as a shell built-in and reveals the nature of a given command to be executed by the shell. Its usage is as follows:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">type</span> [<span class="hljs-built_in">command</span>]
</code></pre>
<p>The "type" command serves as a shell built-in and reveals the nature of a given command to be executed by the shell. Its usage is as follows:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">type</span> [<span class="hljs-built_in">command</span>]
</code></pre>
<p>By replacing <code>[command]</code> with the name of the command in question, we can unveil its classification. Let's explore a few examples:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">type</span> ls
</code></pre>
<p>The output is shown below</p>
<pre><code class="lang-sh">ls is aliased to `ls -F --color=auto --show-control-chars<span class="hljs-string">'</span>
</code></pre>
<p>In the above case, we discover that the "ls" command is an alias with the additional option "--color=auto". This knowledge explains why the output of "ls" is displayed in color.</p>
<pre><code class="lang-sh"><span class="hljs-built_in">type</span> cp
</code></pre>
<p>The output is shown below</p>
<pre><code class="lang-sh">cp is hashed (/usr/bin/cp)
</code></pre>
<p>For the <code>cp</code> command, the output reveals that it is an executable program located at <code>usr/bin/cp</code>. Such insights allow us to better understand the behavior and functionality of various commands.</p>
<p>The <code>which</code> Command: In scenarios where multiple versions of an executable program exist on a system, the <code>which</code> command proves invaluable. Its purpose is to determine the precise location of a given executable. Usage is as follows:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">which</span> [<span class="hljs-built_in">command</span>]
</code></pre>
<p>By replacing <code>[command]</code> with the desired command name, we can ascertain its exact location.</p>
<blockquote>
<p><strong>Note:</strong> <code>which</code> exclusively works for executable programs and cannot identify built-ins or aliases acting as substitutes.</p>
</blockquote>
<p>By utilizing the <code>type</code> and <code>which</code> commands, we can effectively identify the type of command in question and gain insights into its execution within the Linux environment. This knowledge equips us with a deeper understanding of the command line ecosystem.</p>
<h3 id="heading-the-help-command">The <code>help</code> Command</h3>
<p>The bash shell incorporates a built-in help facility that provides documentation for each shell built-in. To access it, simply type "help" followed by the name of the shell built-in. Optionally, the "-m" option can be added to modify the output format. Let's consider an example:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">help</span> -m <span class="hljs-built_in">cd</span>
</code></pre>
<p>Upon executing the above command, the following information about the "cd" command will be displayed:</p>
<pre><code class="lang-sh">NAME
    <span class="hljs-built_in">cd</span> - Change the shell working directory.

SYNOPSIS
    <span class="hljs-built_in">cd</span> [-L|[-P [-e]] [-@]] [dir]

DESCRIPTION
    Change the shell working directory.

    Change the current directory to DIR.  The default DIR is the value of the
    HOME shell variable.

    The variable CDPATH defines the search path <span class="hljs-keyword">for</span> the directory containing
    DIR.  Alternative directory names <span class="hljs-keyword">in</span> CDPATH are separated by a colon (:).
    A null directory name is the same as the current directory.  If DIR begins
    with a slash (/), <span class="hljs-keyword">then</span> CDPATH is not used.

    If the directory is not found, and the shell option `cdable_vars<span class="hljs-string">' is set,
    the word is assumed to be  a variable name.  If that variable has a value,
    its value is used for DIR.

    Options:
      -L        force symbolic links to be followed: resolve symbolic
                links in DIR after processing instances of `..'</span>
      -P        use the physical directory structure without following
                symbolic links: resolve symbolic links <span class="hljs-keyword">in</span> DIR before
                processing instances of `..<span class="hljs-string">'
      -e        if the -P option is supplied, and the current working
                directory cannot be determined successfully, exit with
                a non-zero status
      -@        on systems that support it, present a file with extended
                attributes as a directory containing the file attributes

    The default is to follow symbolic links, as if `-L'</span> were specified.
    `..<span class="hljs-string">' is processed by removing the immediately previous pathname component
    back to a slash or the beginning of DIR.

    Exit Status:
    Returns 0 if the directory is changed, and if $PWD is set successfully when
    -P is used; non-zero otherwise.

SEE ALSO
    bash(1)

IMPLEMENTATION
    GNU bash, version 5.1.16(1)-release (x86_64-pc-msys)
    Copyright (C) 2020 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;</span>
</code></pre>
<blockquote>
<p><strong>Note:</strong> In command syntax descriptions, square brackets denote optional items, while a vertical bar indicates mutually exclusive choices. For instance, the notation for the "cd" command:</p>
</blockquote>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> [-L|-P] [dir]
</code></pre>
<p>This indicates that the <code>cd</code> command can be optionally followed by either <code>-L</code> or <code>-P</code> and further optionally by the argument <code>dir</code>.</p>
<h2 id="heading-command-documentation">Command Documentation</h2>
<h3 id="heading-the-help-option">The "--help" Option</h3>
<p>Many executable programs support a <code>--help</code> option, which provides a detailed description of the command's syntax and supported options. For instance:</p>
<pre><code class="lang-sh">mkdir --<span class="hljs-built_in">help</span>
</code></pre>
<p>Executing the command above will display the following information about the <code>mkdir</code> command:</p>
<pre><code class="lang-sh">Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), <span class="hljs-keyword">if</span> they <span class="hljs-keyword">do</span> not already exist.

Mandatory arguments to long options are mandatory <span class="hljs-keyword">for</span> short options too.
  -m, --mode=MODE   <span class="hljs-built_in">set</span> file mode (as <span class="hljs-keyword">in</span> chmod), not a=rwx - <span class="hljs-built_in">umask</span>
  -p, --parents     no error <span class="hljs-keyword">if</span> existing, make parent directories as needed
  -v, --verbose     <span class="hljs-built_in">print</span> a message <span class="hljs-keyword">for</span> each created directory
  -Z                   <span class="hljs-built_in">set</span> SELinux security context of each created directory
                         to the default <span class="hljs-built_in">type</span>
      --context[=CTX]  like -Z, or <span class="hljs-keyword">if</span> CTX is specified <span class="hljs-keyword">then</span> <span class="hljs-built_in">set</span> the SELinux
                         or SMACK security context to CTX
      --<span class="hljs-built_in">help</span>     display this <span class="hljs-built_in">help</span> and <span class="hljs-built_in">exit</span>
      --version  output version information and <span class="hljs-built_in">exit</span>

GNU coreutils online <span class="hljs-built_in">help</span>: &lt;https://www.gnu.org/software/coreutils/&gt;
Full documentation &lt;https://www.gnu.org/software/coreutils/mkdir&gt;
or available locally via: info <span class="hljs-string">'(coreutils) mkdir invocation'</span>
</code></pre>
<p>Although not all programs support the "--help" option, it is worth attempting as it often provides similar usage information, even if it results in an error message.</p>
<h2 id="heading-the-man-command">The <code>man</code> Command</h2>
<p>Most command-line executable programs offer comprehensive documentation known as a manual or man page.</p>
<blockquote>
<p><strong>Note</strong> that the command from <code>man</code> is by default only available on Unix OS</p>
</blockquote>
<p>The "man" command enables us to view these pages conveniently. Usage of the "man" command is as follows:</p>
<pre><code class="lang-sh">man program
</code></pre>
<p>Replace <code>program</code> with the name of the command to access its manual page. Man pages typically include a title, a synopsis of the command's syntax, a description of its purpose, and a list and explanation of each option. However, they are primarily designed as references rather than tutorials. Let's view the man page for the <code>ls</code> command:</p>
<pre><code class="lang-sh">man ls
</code></pre>
<p>On most Linux systems, the <code>man</code> command employs the <code>less</code> program to display the manual page, allowing the use of familiar <code>less</code> commands for navigation.</p>
<p>By utilizing the <code>help</code>, <code>--help</code>, and <code>man</code> commands, we can access comprehensive documentation for each command type, enabling us to leverage the full potential of Linux command line tools. These resources facilitate efficient command usage, ensuring optimal productivity within the Linux environment.</p>
<h3 id="heading-note">Note</h3>
<p>On your system, various software packages are installed, each accompanied by documentation files located in the <code>/usr/share/doc</code> directory. These files primarily exist in plain text format, which can be easily accessed and viewed using the <code>less</code> command. However, there are instances where certain files are in HTML format, enabling them to be conveniently viewed using a web browser. It is worth noting that some files in this directory may be compressed with the gzip compression program, denoted by the <code>.gz</code> extension. To handle such compressed text files, the gzip package provides a specialized version of <code>less</code> called <code>zless</code>, which allows the contents of gzip-compressed files to be displayed seamlessly.</p>
<hr />
<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/03-mastering-linux-command-line">View on GitHub</a></p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Files Manipulation]]></title><description><![CDATA[Learn the fundamental commands for manipulating files and directories. Understand their usage and options to efficiently manage your file system.]]></description><link>https://techstack.hashnode.dev/files-manipulation</link><guid isPermaLink="true">https://techstack.hashnode.dev/files-manipulation</guid><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[shell]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sat, 27 May 2023 13:11:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685192551654/5552bd91-17ad-4a66-bb09-448905bc8ccf.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/02-files-manipulation"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<p>When working with files and directories, there are basic commands that can be used for manipulation. These commands include:</p>
<ul>
<li><p><code>cp</code> (copy)</p>
</li>
<li><p><code>mv</code> (move)</p>
</li>
<li><p><code>rm</code> (remove)</p>
</li>
<li><p><code>mkdir</code> (make directory)</p>
</li>
<li><p><code>rmdir</code> (remove directory)</p>
</li>
</ul>
<p>Before we delve into these commands, let's create a new file. Name it <code>filename.txt</code> and add some random text to it. Make sure you navigate to its directory using your terminal.</p>
<h2 id="heading-cp-copy"><code>cp</code> - Copy</h2>
<p>The <code>cp</code> command is used to copy files or directories from one location to another. It creates a duplicate of the specified file or directory, which can be placed in the same directory or a different one. The common format for the <code>cp</code> command is:</p>
<pre><code class="lang-sh">cp &lt;file_name&gt; &lt;new_file_name&gt;
</code></pre>
<p>For example, in the code below, <a target="_blank" href="http://README.md"><code>README.md</code></a> already exists. We will create <a target="_blank" href="http://contribute.md"><code>contribute.md</code></a> and copy all the contents from <a target="_blank" href="http://README.md"><code>README.md</code></a> into <a target="_blank" href="http://contribute.md"><code>contribute.md</code></a>:</p>
<pre><code class="lang-sh">cp README.md contribute.md
</code></pre>
<p>The <code>cp</code> command can also be used to copy multiple files. Make sure <code>file_name1</code>, <code>file_name2</code>, etc., exist:</p>
<pre><code class="lang-sh">cp  &lt;file_name1&gt; &lt;file_name2&gt; ...&lt;new_file_name2&gt;
</code></pre>
<p>In the code below, <a target="_blank" href="http://README.md"><code>README.md</code></a> and <a target="_blank" href="http://contribute.md"><code>contribute.md</code></a> already exist:</p>
<pre><code class="lang-sh">cp  README.md contribute.md support.md
</code></pre>
<p>If you want to copy all the contents from all the <code>.md</code> files in a directory to a destination file, you can use the wildcard <code>*</code>:</p>
<pre><code class="lang-sh">cp *.md &lt;destination_file_name&gt;
</code></pre>
<p>For example:</p>
<pre><code class="lang-sh">cp *md teams.md
</code></pre>
<p>To copy a file to a specific directory, create a new directory or folder in your root directory and run the command in the following format:</p>
<pre><code class="lang-sh">cp &lt;file_name&gt; &lt;directory/new_file_name&gt;
</code></pre>
<p>For example:</p>
<pre><code class="lang-sh">cp README.md folder/contribute.md
</code></pre>
<p>Just like the commands above, you can add the <code>-i</code> flag to the cp command. When used, it prompts for confirmation before overwriting an existing file.</p>
<p>To create a new file and put content in it, which is different from an already existing file:</p>
<pre><code class="lang-sh">cp -i &lt;file_name1&gt; &lt;file_name2&gt;
</code></pre>
<p>For example:</p>
<pre><code class="lang-sh">cp -i README.md contribute.md
</code></pre>
<p>When you run the above code in your terminal, you will be prompted if you want to overwrite the file (if <code>&lt;file_name2&gt;</code>already exists). You can enter <code>y</code> (or <code>yes</code>) to override the content of &lt;<code>file_name2</code>\&gt; with the content of &lt;<code>file_name1</code>\&gt;. Enter <code>n</code> (or <code>no</code>) or just click the enter button if you do not want to overwrite it.</p>
<pre><code class="lang-sh">cp: overwrite <span class="hljs-string">'contribute.md'</span>?
</code></pre>
<p>When you need to copy the contents of an existing directory <code>&lt;dir1&gt;</code> to a new directory <code>&lt;dir2&gt;</code>, including all subdirectories and files, you can utilize the <code>cp</code> command with the <code>-R</code> flag. This flag enables recursive copying, ensuring that the entire directory structure is preserved.</p>
<p>Here's how you can accomplish this:</p>
<pre><code class="lang-sh">cp -R &lt;dir1&gt; &lt;dir2&gt;
</code></pre>
<p>In this command, <code>&lt;dir1&gt;</code> represents the source directory whose contents you want to copy, and <code>&lt;dir2&gt;</code> is the destination directory where you want to create the copied contents.</p>
<p>The <code>-R</code> flag tells the <code>cp</code> command to perform a recursive copy, ensuring that all subdirectories and files within <code>&lt;dir1&gt;</code> are copied to <code>&lt;dir2&gt;</code>. If <code>&lt;dir2&gt;</code> does not exist, it will be created during the copying process.</p>
<blockquote>
<p><strong>Note:</strong> that the <code>-R</code> flag is crucial when you want to copy directories, as it allows for the copying of both the directory's contents and its subdirectories.</p>
</blockquote>
<p>By utilizing the <code>cp</code> command with the <code>-R</code> flag, you can efficiently copy the entire contents of one directory to another, preserving the structure and ensuring that all files and subdirectories are successfully copied.</p>
<p>Suppose you have an existing directory named <code>documentation</code>, and you want to move all of its files and subdirectories to a new directory called <code>reserve</code>. You can achieve this by using the <code>cp</code> command with the <code>-R</code> flag for recursive copying.</p>
<pre><code class="lang-sh">cp -R documentation reserve
</code></pre>
<h2 id="heading-mv-move"><code>mv</code> - Move</h2>
<p>The <code>mv</code> command not only allows you to move individual files but also provides the flexibility to move multiple files into another directory (folder) simultaneously.</p>
<p>To move multiple files to a destination directory, you can use the following syntax:</p>
<pre><code class="lang-sh">mv &lt;file1&gt; &lt;file2&gt; &lt;destination_directory&gt;
</code></pre>
<p>In this example, both <code>&lt;file1&gt;</code> and <code>&lt;file2&gt;</code> will be moved to <code>&lt;destination_directory&gt;</code>. The files will no longer exist in their original location and will be consolidated in the specified <code>&lt;destination_directory&gt;</code>.</p>
<p>For instance, consider the command:</p>
<pre><code class="lang-sh">mv file1 file2 destination_folder
</code></pre>
<p>After executing this command, both <code>file1</code> and <code>file2</code> will be moved to the <code>destination_folder</code>. These files will no longer be present in their original location, ensuring a streamlined organization of your files.</p>
<p>The <code>mv</code> command's ability to move multiple files simultaneously simplifies the process of managing and rearranging files within your system.</p>
<blockquote>
<p><strong>Note:</strong> You can use the wildcard pattern <code>*</code> and the <code>i</code> flag if you wish to:</p>
</blockquote>
<pre><code class="lang-sh">mv -i *.txt backup
</code></pre>
<p>Using the wildcard pattern * in combination with the mv command allows for efficient and streamlined file movements, especially when dealing with large numbers of files.</p>
<pre><code class="lang-sh">mv doc/accordion.md documentation
</code></pre>
<p>In this case, the file <a target="_blank" href="http://accordion.md"><code>accordion.md</code></a> located in the doc directory will be moved to the <code>documentation</code> directory. The file will be deleted from the <code>doc</code> directory, and if the <code>documentation</code> directory does not exist, it will be created automatically.</p>
<p>The <code>mv</code> command is a versatile tool for organizing files and directories within your system. It allows you to seamlessly move files between directories, ensuring that your file structure remains well-organized and up-to-date.</p>
<h2 id="heading-rm-remove"><code>rm</code>- Remove</h2>
<p>The <code>rm</code> command is used to delete files and directories from your system. It is important to exercise caution when using this command, as deleted files or folders cannot be recovered.</p>
<p>To remove a single file, use the following command:</p>
<pre><code class="lang-sh">rm &lt;file_name&gt;
</code></pre>
<p>Alternatively, you can use the -i flag to be prompted for confirmation before deleting a file or folder:</p>
<pre><code class="lang-sh">rm -i &lt;file_name&gt;
</code></pre>
<p>For example, to remove the file "<a target="_blank" href="http://accordion.md">accordion.md</a>" located in the "doc" directory, you can run:</p>
<pre><code class="lang-sh">rm -i doc/accordion.md
</code></pre>
<p>The prompt will ask the following question:</p>
<pre><code class="lang-sh">rm: remove regular file <span class="hljs-string">'doc/accordion.md'</span>?
</code></pre>
<p>If you type <code>y</code> (or <code>yes</code>), the file will be deleted.</p>
<p>To delete an entire folder or directory, you need to use the -r flag, which stands for "recursive":</p>
<pre><code class="lang-sh">rm -r &lt;dir&gt;
</code></pre>
<p>For instance, to delete the "folder1" directory and its contents, you can execute:</p>
<pre><code class="lang-sh">rm -r folder1
</code></pre>
<p>If you wish to delete multiple folders or directories, you can use either the <code>-r</code> or <code>-rf</code> flag:</p>
<pre><code class="lang-sh">rm -r &lt;dir1&gt; &lt;dir2&gt; ...
</code></pre>
<pre><code class="lang-sh">rm -rf &lt;dir1&gt; &lt;dir2&gt; ...
</code></pre>
<blockquote>
<p><strong>Note:</strong> that the <code>rm -rf</code> command is more aggressive and powerful than <code>rm -r</code>. It bypasses confirmation prompts and forcefully removes directories and their contents. This option should be used with caution to prevent accidental data loss.</p>
</blockquote>
<p>Remember to double-check your commands before executing them to ensure you are deleting the intended files or directories.</p>
<h2 id="heading-mkdir-make-directory"><code>mkdir</code> - Make Directory</h2>
<p>The <code>mkdir</code> command is used to create a new directory.</p>
<p>To create a single directory, use the following command:</p>
<pre><code class="lang-sh">mkdir &lt;dir_name&gt;
</code></pre>
<p>For example, to create a directory named "folder", you can run:</p>
<pre><code class="lang-sh">mkdir folder
</code></pre>
<p>You can also create multiple directories at once by specifying their names:</p>
<pre><code class="lang-sh">mkdir &lt;dir1&gt; &lt;dir2&gt; ...
</code></pre>
<p>For example, to create directories named "folder1", "folder2", and "folder3", you can execute:</p>
<pre><code class="lang-sh">mkdir folder1 folder2 folder3
</code></pre>
<p><strong>Note:</strong> that if a directory with the same name already exists, the <code>mkdir</code> command will generate an error. To avoid this, you can use the <code>-p</code> flag, which stands for "parents" and allows the creation of nested directories. This way, if any intermediate directories are missing, they will be created as well.</p>
<pre><code class="lang-sh">mkdir -p &lt;dir_path&gt;
</code></pre>
<p>For instance, to create a directory named "nested" inside a directory named "parent" (assuming "parent" doesn't exist yet), you can use:</p>
<pre><code class="lang-sh">mkdir -p parent/nested
</code></pre>
<p>This will create both the "parent" and "nested" directories.</p>
<p>Remember to choose meaningful and descriptive names for your directories to keep your file system organized and easily navigable.</p>
<h2 id="heading-rmdir-remove-directory"><code>rmdir</code> - Remove Directory</h2>
<p>The command <code>rmdir</code> is the opposite of <code>mkdir</code>. It deletes a folder only when it is empty.</p>
<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/02-files-manipulation">View on GitHub</a></p>
<hr />
]]></content:encoded></item><item><title><![CDATA[Shell Navigation]]></title><description><![CDATA[Learn Shell Navigation with common commands like pwd, cd, and ls. Understand file system structure, absolute and relative pathnames, and file management.]]></description><link>https://techstack.hashnode.dev/shell-navigation</link><guid isPermaLink="true">https://techstack.hashnode.dev/shell-navigation</guid><category><![CDATA[shell]]></category><category><![CDATA[shell script]]></category><category><![CDATA[terminal]]></category><category><![CDATA[command line]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Thu, 25 May 2023 23:59:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1685065706034/aed128b6-a9ca-49f6-ace5-ac795799e341.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/01-shell-navigation"><img src="https://res.cloudinary.com/bizstak/image/upload/v1685060686/github_f9ljwi.svg" alt="GitHub Logo" class="image--center mx-auto" /></a></p>
<h2 id="heading-installation">Installation</h2>
<p>Search the <strong>terminal</strong> on your Operating system, but if you are using Windows, don't use the default Windows terminal. Check out the <a target="_blank" href="https://www.youtube.com/watch?v=N-Eu7g8Zv7o&amp;t=2s">video on how to install a terminal emulator</a>. For Mac users, you don't need installation, use the default terminal.</p>
<p>Common terminals to use are:</p>
<ul>
<li><p><a target="_blank" href="https://cmder.app">Cmder</a></p>
</li>
<li><p><a target="_blank" href="https://git-scm.com/downloads">Git Bash</a></p>
</li>
<li><p><a target="_blank" href="https://hyper.is/#installation">Hyper</a></p>
</li>
<li><p><a target="_blank" href="https://iterm2.com/downloads.html">iTerm2</a></p>
</li>
</ul>
<h2 id="heading-common-commands">Common Commands</h2>
<ul>
<li><p><code>pwd</code> (print working directory)</p>
</li>
<li><p><code>cd</code> (change directory)</p>
</li>
<li><p><code>ls</code> (list file and directory)</p>
</li>
<li><p><code>touch</code></p>
</li>
</ul>
<h2 id="heading-file-system">File system</h2>
<ul>
<li><p>In a tree-like pattern of the directory (folder)</p>
</li>
<li><p>A directory may contain files and subdirectories</p>
</li>
<li><p>The first directory in the file system is called the <strong>root directory</strong></p>
</li>
</ul>
<p>One important difference between Windows and Unix-like OS like Linux is that Linux does not employ the concept of drive letters. While Windows drive letters split the file system into a series of different trees (one for each device), Linux always has a single tree.</p>
<h3 id="heading-pwd"><code>pwd</code></h3>
<p>The acronym <strong>PWD</strong> stands for <em>Present Working Directory</em>. It is commonly used in the context of command-line interfaces and operating systems to refer to the current directory in which a user is working. The <code>pwd</code> command is often used to retrieve and display the full path of the current directory. That is the directory we are standing in is called the working directory. To see the name of the working directory, we use the <code>pwd</code> command.</p>
<h3 id="heading-cd"><code>cd</code></h3>
<ol>
<li><p>Absolute pathname</p>
</li>
<li><p>Relative pathname</p>
</li>
</ol>
<h4 id="heading-absolute-pathname">Absolute pathname</h4>
<p>Example</p>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> /user/bin
</code></pre>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> /foldername
</code></pre>
<h4 id="heading-relative-pathname">Relative pathname</h4>
<p>The <code>.</code> notation refers to the working directory itself and the <code>..</code> notation refers to the working directory's parent directory.</p>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> ..
</code></pre>
<pre><code class="lang-sh"><span class="hljs-built_in">cd</span> ../foldername
</code></pre>
<p>If we type <code>cd</code> followed by nothing, <code>cd</code> will change the working directory to our home directory.</p>
<p>A relative shortcut is to type <code>cd ~user_name</code>.</p>
<p>File names that begin with a period character are hidden. This only means that <code>ls</code> will not list them unless we say <code>ls -la</code>.</p>
<ul>
<li>An example is <code>.git</code>.</li>
</ul>
<p>File names in <strong>Linux</strong>, like Unix, are <strong>case-sensitive</strong>. The file names <em>File1</em> and <em>file 1</em> refer to different files.</p>
<p>Linux has no concept of a <strong>file extension</strong> like the Windows system. You may name files any way you like. However, while Linux itself does not care about file extensions, many application programs do.</p>
<p>Though <strong>Linux supports long file names</strong> which may contain embedded spaces and punctuation, limit the punctuation characters to period, dash and underscore. <strong>Use underscores instead of spaces</strong> to represent spaces between words in a file name.</p>
<h3 id="heading-ls"><code>ls</code></h3>
<h4 id="heading-ls-l"><code>ls -l</code></h4>
<p>List the files in the working directory in long format.</p>
<pre><code class="lang-sh">ls -l
</code></pre>
<h4 id="heading-ls-l-etc-bin"><code>ls -l /etc /bin</code></h4>
<p>List the files in the <code>/bin</code> directory and the <code>/etc</code> directory in long format.</p>
<pre><code class="lang-sh">ls -la ..
</code></pre>
<pre><code class="lang-sh">ls -la /foldername
</code></pre>
<p>List all files (even the ones with names beginning with a period character, which are normally hidden) in the working directory's parent in a long format.</p>
<p>Most commands operate like this:</p>
<pre><code class="lang-sh"><span class="hljs-built_in">command</span> -option arguments
</code></pre>
<h4 id="heading-a-closer-look-at-long-format">A Closer Look at Long Format</h4>
<p>For example, try <code>ls -la</code>, you will get more information about the file.</p>
<p><img src="https://res.cloudinary.com/bizstak/image/upload/v1685049199/ls-la-command-info_kgiglf.png" alt="show ls -la command possible information" /></p>
<p>If you run the command <code>ls -l</code> you will get the output that looks like this:</p>
<pre><code class="lang-sh">total 4
-rw-r--r-- 1 TechstackMedia - Osagie 197610 3092 May 25 14:28 README.md
</code></pre>
<p>Let's break down the output:</p>
<ol>
<li><p><code>total 4</code>: This line represents the total number of 1KB blocks used by the files listed below it. In this case, the total size is 4KB.</p>
</li>
<li><p><code>-rw-r--r-- 1 TechstackMedia - Osagie 197610 3092 May 25 14:28</code> <a target="_blank" href="http://README.md"><code>README.md</code></a>: This line represents the details of a specific file called <a target="_blank" href="http://README.md">README.md</a>. Let's analyze each part:</p>
<ul>
<li><p><code>-rw-r--r--</code>: This section represents the file permissions. In this example, it indicates that the file is readable and writable by the owner (<code>rw-</code>), readable by the group (<code>r--</code>), and readable by others (<code>r--</code>).</p>
</li>
<li><p><code>1</code>: The number 1 represents the number of hard links to the file. In this case, there is only one hard link pointing to the file.</p>
</li>
<li><p><code>TechstackMedia</code>: This is the owner of the file. In this case, the file is owned by the user <code>TechstackMedia</code>.</p>
</li>
<li><p><code>-</code>: This hyphen represents the group associated with the file. In this case, the group is not explicitly specified.</p>
</li>
<li><p><code>Osagie</code>: This represents the group associated with the file. In this example, the group is <code>Osagie</code>.</p>
</li>
<li><p><code>197610</code>: This indicates the file size in bytes. In this case, the file <a target="_blank" href="http://README.md"><code>README.md</code></a> is 3092 bytes.</p>
</li>
<li><p><code>May 25 14:28</code>: This represents the file's last modification date and time.</p>
</li>
<li><p><a target="_blank" href="http://README.md"><code>README.md</code></a>: This is the name of the file.</p>
</li>
</ul>
</li>
</ol>
<h3 id="heading-touch"><code>touch</code></h3>
<p>The <code>touch</code> command is a versatile and powerful tool that allows you to create and modify files with ease in various operating systems, including Linux, macOS, and Unix. Its simplicity and efficiency make it a fundamental command for managing files and timestamps.</p>
<p>One of the primary functions of the touch command is to create a new file. Using the command is as simple as typing touch followed by the desired filename. For example, to create a file called <em>example.txt</em>, you would execute the following command:</p>
<pre><code class="lang-sh">touch example.txt
</code></pre>
<p>You can also specify the timestamp. In the example below a file named <em>custom.txt</em> with a specific timestamp of <em>December 31, 2022, at 12:30 PM</em>, you would execute the following command:</p>
<pre><code class="lang-sh">touch -t 202312311230 custom.txt
</code></pre>
<p>In the <code>touch</code> command, the timestamp for the <code>-t</code> option follows a specific format: <code>[[CC]YY]MMDDhhmm[.ss]</code>.</p>
<p>Here's a breakdown of each component:</p>
<ul>
<li><p><code>CC</code>: Represents the first two digits of the year (century).</p>
</li>
<li><p><code>YY</code>: Represents the last two digits of the year.</p>
</li>
<li><p><code>MM</code>: Represents the month (01-12).</p>
</li>
<li><p><code>DD</code>: Represents the day of the month (01-31).</p>
</li>
<li><p><code>hh</code>: Represents the hour in 24-hour format (00-23).</p>
</li>
<li><p><code>mm</code>: Represents the minute (00-59).</p>
</li>
<li><p><code>.ss</code>: (Optional) Represents the second (00-61).</p>
</li>
</ul>
<p>In your example, the timestamp <code>202312311230</code> corresponds to the following components:</p>
<ul>
<li><p><code>CC</code>: Not specified, assuming it is the current century.</p>
</li>
<li><p><code>YY</code>: <code>22</code> (indicating the year 2023).</p>
</li>
<li><p><code>MM</code>: <code>12</code> (indicating December).</p>
</li>
<li><p><code>DD</code>: <code>31</code> (indicating the 31st day of the month).</p>
</li>
<li><p><code>hh</code>: <code>12</code> (indicating 12 PM).</p>
</li>
<li><p><code>mm</code>: <code>30</code> (indicating 30 minutes).</p>
</li>
</ul>
<p>This command will set the modification and access times of the <code>custom.txt</code> file to the specified timestamp, allowing you to manually define the file's timestamp.</p>
<h3 id="heading-less"><code>less</code></h3>
<p>less is a program that lets us view text files. This is very handy since many of the files used to control and configure Linux are human-readable.</p>
<p>Click <code>q</code> to quit or keep clicking enter till you are done reading the file.</p>
<pre><code class="lang-sh">less text_file
</code></pre>
<pre><code class="lang-sh">less README.md
</code></pre>
<hr />
<h3 id="heading-references">References</h3>
<p><a target="_blank" href="https://github.com/techstackmedia/software-engineering-series/tree/01-shell-navigation">GitHub Repository</a></p>
<hr />
]]></content:encoded></item><item><title><![CDATA[JavaScript Symbol]]></title><description><![CDATA[In JavaScript, the object key can only be in either string or symbol. The description is just a label that is unique to an object.]]></description><link>https://techstack.hashnode.dev/javascript-symbol</link><guid isPermaLink="true">https://techstack.hashnode.dev/javascript-symbol</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[webdevelopment]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Bello]]></dc:creator><pubDate>Sun, 20 Jun 2021 23:59:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1624305960034/pOv55oh-o.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In JavaScript, the object key can only be in either string or symbol. </p>
<blockquote>
<p>A symbol represents a unique identifier</p>
</blockquote>
<p>To create a symbol, the syntax is shown below:</p>
<pre><code><span class="hljs-attr">id</span> = Symbol()
</code></pre><p>To create a symbol with a description (symbol-name), the syntax is shown below:</p>
<pre><code><span class="hljs-attr">id</span> = Symbol(<span class="hljs-string">"description"</span>)
</code></pre><p>The description is just a label that is unique to an object.</p>
<p>It is important to note that symbols with the same description are still different.</p>
<p>See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> id1 = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"description"</span>);
<span class="hljs-keyword">const</span> id2 = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"description"</span>);

<span class="hljs-built_in">console</span>.log(id1 === id2); <span class="hljs-comment">// false</span>
</code></pre>
<p>It is also important to note that symbols do not allow auto-conversion (coercion) to string.</p>
<p>See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> id3 = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"description"</span>);
alert(id3); <span class="hljs-comment">// TypeError...</span>
</code></pre>
<p>To do the conversion, use the <code>toString()</code> function on it.</p>
<p>See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> id4 = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"id"</span>);
alert(<span class="hljs-keyword">typeof</span> id4.toString); <span class="hljs-comment">// string</span>
</code></pre>
<p>Alternatively, we can use the <code>id.description</code> to show the description only.</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> id5 = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"id"</span>);
alert(id5.description, toString id5.description); <span class="hljs-comment">// id string</span>
</code></pre>
<hr />
<h2 id="hidden-properties">Hidden Properties</h2>
<p>Symbols allow us to create hidden properties of an object.
See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> person = { <span class="hljs-comment">// belongs to another code</span>
  <span class="hljs-attr">name</span>: <span class="hljs-string">"Bello"</span>
};

<span class="hljs-keyword">let</span> id = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"id"</span>);

person[id] = <span class="hljs-number">4</span>; <span class="hljs-comment">// added id key to user object</span>

alert( person[id] ); <span class="hljs-comment">// 4 =&gt; accessed data by the symbol as the key</span>
</code></pre>
<p>The code above shows that a symbol cannot be accessed accidentally by any part of your code. </p>
<p>If a string is used in place of a symbol, the last string "id" will be overridden (overwritten) by any other previous string id from our script or another JavaScript library script.</p>
<p>See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> person = { <span class="hljs-attr">name</span>: <span class="hljs-string">"John"</span> };

<span class="hljs-comment">// my script uses "id" property</span>
person.id = <span class="hljs-string">"id value before the last script"</span>;

<span class="hljs-comment">// library script uses the "id" property</span>
person.id = <span class="hljs-string">"id value in last script"</span> <span class="hljs-comment">// overwritten by another script!</span>
<span class="hljs-built_in">console</span>.log(person.id); <span class="hljs-comment">// id value in last script</span>
</code></pre>
<hr />
<h2 id="symbol-id-as-key">Symbol id as key</h2>
<p>To use a symbol as a key in an object literal, the square bracket must be used around it.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> id = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"id"</span>);

<span class="hljs-keyword">const</span> user = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">"John"</span>,
  [id]: <span class="hljs-number">639</span> <span class="hljs-comment">// not "id": 639</span>
};
</code></pre>
<hr />
<h2 id="cloning-symbol-keys">Cloning symbol keys</h2>
<p>The for...in skips any symbol key in an object. 
See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> id = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"id"</span>);
<span class="hljs-keyword">const</span> user = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">"Bello"</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">27</span>,
  [id]: <span class="hljs-number">396</span>
};

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> key <span class="hljs-keyword">in</span> user) {
  <span class="hljs-built_in">console</span>.log(key); <span class="hljs-comment">// name, age =&gt; no symbols</span>
}
<span class="hljs-comment">// Object.keys(user) also skips them.</span>
</code></pre>
<p>The <code>Object.assign</code> copies both string and symbol properties.</p>
<p>See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> id = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"id"</span>);
<span class="hljs-keyword">const</span> user = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">"Bello"</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">27</span>,
  [id]: <span class="hljs-number">396</span>
};

<span class="hljs-keyword">let</span> clone = <span class="hljs-built_in">Object</span>.assign({}, user);
alert( clone[id] ); <span class="hljs-comment">// 396</span>
</code></pre>
<hr />
<h2 id="global-symbol-registry">Global Symbol Registry</h2>
<p>Symbols are always different by default even if they have the same description, but sometimes we want to use the same-named symbol of the same entities anyway in a program. </p>
<p>To achieve that, the <code>Symbol.for(key)</code> is used to create a global symbol registry for repeated access by the same name to return exactly the same symbol.</p>
<p>See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> id1 = <span class="hljs-built_in">Symbol</span>.for(<span class="hljs-string">"id"</span>); <span class="hljs-comment">// if the symbol did not exist, it is created</span>
<span class="hljs-keyword">const</span> id2 = <span class="hljs-built_in">Symbol</span>.for(<span class="hljs-string">"id"</span>);

<span class="hljs-built_in">console</span>.log( id1 === id2); <span class="hljs-comment">// true =&gt; the same symbol</span>
</code></pre>
<blockquote>
<p>Symbols inside the registry are called global symbols.</p>
</blockquote>
<hr />
<h2 id="symbolkeyfor">Symbol.keyFor</h2>
<p>The reverse of Symbol.for is Symbol.keyFor, it returns a name by a global symbol.</p>
<p>See the example below:</p>
<pre><code class="lang-js"><span class="hljs-comment">// get symbol by name</span>
<span class="hljs-keyword">const</span> sym1 = <span class="hljs-built_in">Symbol</span>.for(<span class="hljs-string">"id1"</span>);
<span class="hljs-keyword">const</span> sym2 = <span class="hljs-built_in">Symbol</span>.for(<span class="hljs-string">"id2"</span>);

<span class="hljs-comment">// get name by symbol</span>
<span class="hljs-built_in">console</span>.log( <span class="hljs-built_in">Symbol</span>.keyFor(sym1) ); <span class="hljs-comment">// id1</span>
<span class="hljs-built_in">console</span>.log( <span class="hljs-built_in">Symbol</span>.keyFor(sym2) ); <span class="hljs-comment">// id2</span>
</code></pre>
<blockquote>
<p>The <code>Symbol.keyFor</code> internally uses the global symbol registry to look up the key for the symbol. If the symbol is not global, it returns <code>undefined</code></p>
</blockquote>
<p>See the example below:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> globalSymbol = <span class="hljs-built_in">Symbol</span>.for(<span class="hljs-string">"globalName"</span>);
<span class="hljs-keyword">const</span> localSymbol = <span class="hljs-built_in">Symbol</span>(<span class="hljs-string">"localName"</span>);

<span class="hljs-built_in">console</span>.log( <span class="hljs-built_in">Symbol</span>.keyFor(globalSymbol) ); <span class="hljs-comment">// globalName =&gt; global symbol</span>
<span class="hljs-built_in">console</span>.log( <span class="hljs-built_in">Symbol</span>.keyFor(localSymbol) ); <span class="hljs-comment">// undefined =&gt; not global</span>

<span class="hljs-built_in">console</span>.log( localSymbol.description ); <span class="hljs-comment">// localName</span>
</code></pre>
<hr />
<h2 id="system-symbols">System Symbols</h2>
<p>Internally, there are different JavaScript System Symbols. 
Below is a few of them.</p>
<ul>
<li>Symbol.hasInstance</li>
<li>Symbol.isConcatSpreadable</li>
<li>Symbol.iterator</li>
<li>Symbol.toPrimitive</li>
</ul>
<p>Check out the full list on <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#static_properties">MDN</a></p>
<hr />
<p><a target="_blank" href="https://www.buymeacoffee.com/techstackmedia"><img src="https://res.cloudinary.com/bizstak/image/upload/v1610317510/ko-fi-trans_fr3su4.png" alt="Buy me a Coffee" /></a></p>
<hr />
]]></content:encoded></item></channel></rss>