Read and Troubleshoot Linux Config Files 10x Faster! 2.0

This post is an iteration of my original post: https://linux-admin.blog/2018/11/01/read-and-troubleshoot-linux-config-files-10x-faster/

In it, I explained how reading and troubleshooting config files in Linux are sometimes a pain in the rear. In particular, when the config files are long and mostly comments.

When we are troubleshooting, we want to know just the effective settings that are going to be loaded at run time and nothing else. And read them quickly.

The script I provided in that original post works, but I’ve iterated it into a more elegant solution.

My solution – then and now – was inspired by a very useful book I discovered years ago: Perl One-Liners: 130 Programs That Get Things Done

So here is my new and improved version; I will also demo the heartburn it removes on two files: smb.conf and sshd_config:

perl -ne 'print unless /^(#|;|\n)/' <filename>

Notice how I defined a comment to be a “#” or a “;”.

smb.conf

Now, if we do a cat /etc/samba/smb.conf we can see how the output is extremely overwhelming with a lot of comments and blank lines:

cat /etc/samba/smb.conf

We could egrep -v "^(#|;)" /etc/samba/smb.conf to see the effective settings, but that will still leave ALOT of empty lines:

egrep -v “^(#|;)” /etc/samba/smb.conf

If we use the Perl Oneliner, we can remove ALL comments, and remove empty lines for EVEN BETTER readability

perl -ne ‘ print unless /^(#|;|\n)/ ‘ /etc/samba/smb.conf

Now we can quickly see our effective settings in /etc/samba/smb.conf.

sshd_config

We can run the same script on /etc/ssh/sshd_config for easier reading and troubleshooting:

perl -ne ‘ print unless /^(#|;|\n)/ ‘ /etc/ssh/sshd_config

Summary

Let take a step back and point out the main benefits with this script.

It will remove all comments (lines beginning with a “#” or “;”) and the empty lines. This will make reading the effective settings quicker and easier.

And make troubleshooting alot easier.

If this code helps you solve any problems, comment and let me know below

How To Quickly Create A Git Repository For Rapid Testing

When you’re learning Git (or anything for that matter) rapid and cheap testing, feedback, and failure can expedite the learning process from hours to minutes!

When you’re learning and experimenting with Git concepts like:

  • Branching,
  • Merging,
  • Tagging,
  • The Working directory,
  • The Cache (or Index),
  • Reading the Commit History,
  • Or basically any Git command or concept

You want to have the freedom to make mistakes, even to the point of corrupting the entire Git repository (repo).

Essentially, a “Git Repo Sandbox” that you can rebuild in seconds.

Here is my code to quickly (re)create said “Git Repo Sandbox” that contains:

  • 2 Branches (master and dev)
  • 1 Merge

Just copy and paste the following code into your bash prompt and let it rip.

There is a merge-conflict warning but it’s ignored because all we want is our “Git Repo Sandbox” up and running again:

rm -Rf ./git_test #<== be VERY careful with this line
mkdir ./git_test
cd git_test
sleep 1

git init
echo ":)" >> ./script.sh
git add *
git commit -m "Commit message"
echo ":)" >> ./script.sh
git add *
git commit -m "Commit message"
sleep 1

git branch dev
git checkout dev
echo ":)" >> ./script.sh
git add *
git commit -m "Commit message"
echo ":)" >> ./script.sh
git add *
git commit -m "Commit message"
sleep 1

git checkout master
echo ":)" >> ./script.sh
git add *
git commit -m "Commit message"
sleep 1

git merge dev
git add *
git commit -m "Commit message"
sleep 1

git log --oneline --all --graph --decorate

You will get output similar to the following (only difference is commit hashes):

Here’s a live demo on how to use my code. For me, I performed a Right-click on my mouse to paste:

Now you can study and experiment with as many git concepts and commands to your heart’s content. Or at least, what this simple repository will allow.

You don’t have to worry about making a mistake, because if you corrupt everything, just “re-build and reload”.

How To Read Git Branches

Love Git Branches But Hate Reading Them?

If you’re using git branching, it can be difficult sometimes to orient yourself within your git repository (repo).

Knowing where you are, where you want to go, and how to get there is next to impossible if you don’t know how to read your commit history (branches)

So I’m going to show you how to read your commit history in this post.

Commits

Here’s your first insight: Commits always point BACK to their parent commit(s), never forward to their child commit(s):

If you make some changes and commit again, the next commit stores a pointer to the commit that came immediately before it.

3.1 Git Branching – Branches in a Nutshell, Figure 10.

This subtle distinction may not seem like a big deal now, but soon this will make all the difference.

Reading Commits

Here is the output of the branch master from my local repo:

git log --oneline --graph --decorate

Given that commits always point back, we can trace our branch from Branch Pointer master (78f107a) all the way back down to our initial commit (7bc8a7a):

The totality of the entire trail from the most recent commit master (78f107a) all the way back down to our initial commit (7bc8a7a) is one branch.

Reading Multiple Branches

Here is where knowing commits point back, not forward, is REALLY going to help us out

First we expose ALL branches from my git repo:

git log --oneline --graph --decorate --all

In this output we now can see all branches laid out at once.

Reading the dev Branch

Here are a couple of things to remember when reading the commit history from command ‘git log’:

  1. The previous commit(s) is denoted by following back to the previous asterisk(s), not necessarily the commit beneath it.
  2. The vertical and diagonal bars actually do a great job of guiding us to the previous commit(s).

7bc8a7a <= a6b939a <= 8e005a4 <= 0461fc6 <= 5e3384e (dev)

We can confirm this by checking out the dev branch and listing the commit history

Reading the test Branch

Just repeat the same process for branch test and you will get the following:

Confirming the test branch:

7bc8a7a <= a6b939a <= 8e005a4 <= e5a2bcc <= 3d6f3bb (test)

Summary

Now that you know how to read your commit history (branches) you should be able to orient yourself and navigate within your git repo.

Hopefully this will empower you to leverage git branches more when you need to experiment with different version and features of your code.

Branches will allow you to test your experimental code without losing the production code.

CentOS Linux 8 Will End In 2021 And Shift To CentOS Stream

Possible Alternatives To CentOS

Here are some alternatives identical to CentOS: 100% binary clones of Red Hat

Infograph Showing Where CentOS Stream Will “Sit”

Image Source: https://twitter.com/fatherlinux/status/1339330731709960194

CentOS Stream will be a rolling release operating system, similar to Arch Linux.

Therefore, it will NOT have version numbers and will site between Fedora and Red Hat. For contrast, CentOS sat AFTER every Red Hat release.

Stated another way:

  • CentOS was downstream to Red Hat: Fedora > Redhat > CentOS
  • CentOS Stream will be upstream to Red Hat: Fedora > CentOS Stream > Redhat

CentOS 7 and 8 End Of Life

CentOS 7 => June 30, 2024

CentOS 8 => December 31, 2021


Notes:

How To Connect To Your Raspberry Pi’s Graphical Desktop From Windows 10

Here I’m going to show you how to easily connect to your Raspberry Pi over the network from your Windows 10 machine.[1]

This is going to be accomplished with the Remote Desktop Protocol (RDP).

This will allow you to quickly and conveniently access the Raspberry Pi’s graphical desktop without having to disconnect and move any of your cables (USB, HDMI, etc.) around.

A real pain in the butt!

Then you can easily experiment and test all of the open source software that the Raspberry Pi platform has to offer:

Here are a few quick examples:

1.) LibreOffice

Opensource Alternative to Microsoft Office

2.) Programming In Python For Beginners

Any Linux platform is going to come with amazing programming IDEs for dozens of popular programming languages: C, C++, Ruby, Python, Perl, you name it!

Raspberry Pi has one in particular for Python beginners.

Thonny Python IDE (to name just one of dozens)

3.) Raspberry Pi Documentation

If you want to go down the Raspberry Pi and/or Debian rabbit hole, you can access all of their References, Guides, and Help files:


Raspberry Pi OS Commands

To get this RDP solution implemented, we will need to:

  1. Install the latest Raspberry Pi OS updates (as a Best Practice)
  2. Install the open source version of RDP onto your Raspberry Pi: Xrdp
sudo apt-get update #update list of available updates
sudo apt-get upgrade #actually installs latest software versions
sudo apt-get install xrdp #installs XRDP onto Raspberry Pi

“RDP” to your Raspberry Pi

From your Windows 10 machine, type mstsc into your search bar and select Remote Desktop Connection

Enter your Raspberry Pi’s IP Address and click Connect

Click Yes if you see the following warning:

Enter the username and password of a valid Raspberry Pi account.

The one you use to Putty with should work.

Then you will be presented with the Raspberry Pi’s graphical desktop:

HAVE FUN EXPLORING!!


[1]Curated from the following website: https://pimylifeup.com/raspberry-pi-remote-desktop