Tech Junkie Blog - Real World Tutorials, Happy Coding!

Latest Posts

Monday, January 24, 2022

 On normal startup of the Linux system you probably see this menu every time you boot up

In this post we are going to add a recovery mode for each of these choices.

Here are the steps to create recovery mode options in the GRUB menu:

1. Log into the system normally

2. Open a terminal session, switch to root privilege or root user

3. Type vi /etc/default/grub to edit the grub file

4. Once you are in the grub file find the line that says GRUB_DISABLE_RECOVERY="true" and change it to GRUB_DISABLE_RECOVERY="false" then press esc then type :wq!

5.  When you get your command prompt back type grub2-mkconfig -o /boot/grub2/grub.cfg to regenerate the grub file

6. When you reboot the system you will see that for each choice on the menu there's an equivalent recovery mode option, you can press esc to stop the menu countdown

Monday, January 17, 2022

 There are times when you need to change the root password, it could be that you are trying to prevent a malicious former employee or that you yourself have forgotten the password.  Well you don't have to rebuild the system.  That would be an option and a costly one at that.  What you could do instead is to reset the root password on the existing install.

Here are the steps to reset the root password on your Linux system:

1. Boot up your Linux system normally when you get the boot menu press esc to stop the countdown, then press e to edit the boot file.

2. Go to the line where you see rhgb and quiet then remove the options from the line

3. Replace the options with rd.break and enforcing=0 the option tells Linux to break at the ram disk break point in the boot process and the if you are using SELinux to enforce it, be mindful that the \ is not part of the command, it's a line break symbol in the boot configuartion file.

4. Press Ctrl+x to continue with the boot process, as you can see you are now stopped at the switch_root:/# prompt which will give you the opportunity to switch to the root's filesystem

5.The first thing we have to do is remount the root filesystem because it's currently set read only.  We want to set it to read and write so that we can reset the root password., if you want to clear the screen type Ctrl+l
6. You accomplish this by typing mount -o remount,rw sysroot
7. Now we want to set a false root call chroot and point it to the root filesystem with the command chroot /sysroot

8. So with the /sysroot filesystem remounted with read and write permission and  chroot as the false root we can now run the passwd command and change the password like we normally would

9. Now it's very important that we set everything back to normal, so type exit to get out and type 

mount -o remoumt,ro /sysroot

to set the root filesystem back to read only, type exit to continue with the boot process

10. Depending on weather you have SELinux enabled or not, your experience will might be different.  If you don't have have it enable you will have it enabled then you will be taken to the login screen and your machine will operate the way that it should with the new root password. But regardless of your experience you should revert boot file configuration back to the way it is by doing the reverse of 2 and 3

11. Before we even do that we want to reinforce security if you have it enabled before by typing the following commands

restorecon /etc/shadow

setenforce 1

Monday, January 10, 2022

 I've done a post on this before, but it was for an older version of Linux CentOS it no longer works for CentOS 8 Stream.  So instead of updating the existing post, I am doing another post so it won't confuse you.  The older post is for older version of CentOS and this one is for CentOS 8

The first thing you noticed after your install of CentOS on VirtualBox is that it's pretty small even if you put it in Fullscreen mode, it doesn't not fill the whole screen at all, as a matter of fact the size stayed the same.

In this post we are going to install the Guest Addition tool in VirtualBox to make the VM fullscreen truly fullscreen. 

Here are the steps to make the VM fullscreen:

1. Log into your system as root

2. Run dnf update -y, if you have no internet access type dhclient -v to get access

3. Next we want to install Red Hat's repository of tools with this command dnf install epel-release

4. Once the update is finished run the command dnf install gcc make perl kernel-devel kernel-headers bzip2 dkms -y to install headers and build tools

5. Once the headers and tools are installed run the following command dnf update kernel-* to get the latest version of the kernel

6. Reboot the system
7. Install the Guest Addition tool by clicking on "Devices" and select "Insert Guest Additions CD image"

8. Click on the "Run" button

9. Type in the root password and click on "Authenticate"

10. If you don't see your VM going fullscreen, then try reboot

11. Once rebooted click on "View", then "Full-screen Mode" to use your VM in fullscreen mode

Monday, January 3, 2022

LVM in Linux allows multiple disks to be combined into one called logical volumes via software.  In this post we are going to create LVMs for a brand new system.  There are two scenarios, the first is LVM on a new system and the second scenario is to create LVM on an existing system.

I am going to create the new system on VirtualBox, I will not go through the process of create a new VM on VirtualBox because I've covered that in the past.  You can search for it on my site if you are lost.

Here are the steps to creating LVM during installation:

1.  On the first screen of installation select the first option

2. Select your language, then click "Continue"

3. On the "Installation Summary" screen click on "Network & Hostname"

4. Give your system a hostname and click "Apply", then click "Done"

5. Click on "Installation Destination"

6. Select disk on the screen and make sure you select "Custom

7. On the "Manual Partitioning" screen select LVM

8. Then click on the + sign
9. The first mount point you are going to create is the /boot mount point because it is required, but it doesn't require a lot of disk space, so we are going to allocate 500m.  A custom Logical Volume basically let's you divide the 8GB on the disk anyway you like instead of letting the operating system decide for you.  That's why most systems run out of disk space at the root level which is / because the operating system did not allocate enough space at installation. Click on "Add mount point" when done

10. On the confirmation screen reselect LVM on the drop down if Standard is selected, accept the default, notice now you only have 7.5GB of disk space left, that's because you allocated 500MB to the /boot mount.

11. Click on the + sign again, this time assign 2 GB to the /home mount, follow the steps above to create the /home mount point with 2 GB

12. Repeat the steps for /var and allocate 2 GB to it and the mount swap with 1 GB, your screen should look like the following when you are finished

13.  You should be left with about 3 GB of disk space left, the best thing we can do right now is to assign it to the root / mount so that we are using all the capacity of the disk.  To do that click on the + sign again, select / from the mount dropdown and type all in the "Desired Capacity" field, then click on the "Add mount point" button

Your screen should look like the following when you are done, click "Done"

Error checking will be performed and a message will pop up telling you to click "Done" again.  "Accept Changes"

14.  While Error checking is performed on the disk, create a root password by clicking on "Root Password" follow the direction to create a root password

15. For Error checking, it says that /boot cannot be LVM so change it to Standard

Note: I had to add a bigger disk on VirtualBox because apparently CentOS required more disk space for installation.  It would not pass the installation requirements, so I used a 25 GB disk.  But the instructions should be the same.

16.  Once the root password has been created click on the "Begin Installation" button.

17.  This step is going to take awhile.

18.  Once installation is complete remove the installation media and click on "Reboot System"

19. On reboot for the first time you will be asked to create a new user, that's up to you.  I usually create one just for convenience.  If you don't want to create a user just accept the license and click "Finish Configuration"

20. Once you completed the configuration steps and logged in, type df -h in the terminal and you will see that the disk's setup is as you specified in your installation

Friday, December 31, 2021

The some() array works similar to the every() method, it also returns true or false when the condition is met.  some() needs to match just one element in the array that meets the condition to return true.  So lets run the same code that we ran for the every() method.  We will test to see if the array is greater than 50 for the first condition, and then we will test to see if the array is greater than 70 for the second condition.  For the every() method the first condition returns true, while the second condition returns false.  Let's see what happens with the some() method.

        var oilPrices = [70.15, 69.50, 71.23, 74.32, 76.99];

        var greaterThanFifty = oilPrices.some(function (value) { return value > 50; });

        var greaterThanSeventy = oilPrices.some(function (value) { return value > 70 });

        console.log("greaterThanFifty: " + greaterThanFifty);
        console.log("greaterThanSeventy: " + greaterThanSeventy);

Thursday, December 30, 2021

If you come from C# or Java, JavaScript inheritance is a little different than what you are used to.  In JavaScript you don't inherit from a class, but you inherit the classes' prototype object.  In our previous post we created an Account class.  In this post we are going to inherit from the account class.  First let's recreate the Account class with the code below.

        function Account(balance, type) {
            this.balance = balance;
            this.type = type;

        Account.prototype.deposit = function (d) {

            this.balance = this.balance + d;
            return this.balance;

        Account.prototype.withdrawal = function (w) {
            this.balance = this.balance - w;
            return this.balance;


Wednesday, December 29, 2021

In the previous post we created arrays of different types, in this post we are going to read the values from our arrays.

Let's work with the following arrays
  1. var numbers = [1,2,3,4];
  2. var stringArray = new Array("USA", "Canada","China");
  3. var objectArray = [{firstName: "Jane", lastName:"Johnson", weight:"115lbs"},{firstName: "Jack", lastName:"Johnson", weight:"200lbs"}];
Let's start with getting a value from an array:

To get the second value of an array you would write the following code by using the :


Tuesday, December 28, 2021

Arrays in JavaScripts are a collection of values stored in what are called elements.  Each element is represented by a numeric index that is zero based, meaning the first element of an array starts at index zero.  JavaScript arrays are dynamic and can contain many types of objects including functions.  The useful thing about arrays is that they are a specialized object that contains a variety of built-in methods that are useful in the manipulation of the array.

First let's create an empty array, there are several ways to do this:

  1. var empty = [ ];
  2. var empty = new Array();
  3. var empty = new Array(0);

Monday, December 27, 2021

The Array.isArray() method is a useful method to determine object is of type array.  Let's demonstrate with some code.

        var oilPrices = [70.15, 69.50, 71.23, 74.32, 69.50, 76.99];
        var iamObject = new Object();


The code above tests to see if the oilPrices array is of type array which it is, and then it tests to see iamObject is an array.  The console.log out put should return true, and the second console.log should return false.

Friday, December 24, 2021

In JavaScript when you define a function you get a built-in Arguments object, this object is an array-like object that puts the arguments/parameters of the your function in an object which can be accessed via indexes much like an array.

This can be useful if you have a function that takes multiple parameters, but you don't know how parameters there will be.  Let's modify our addNumbers function so that it can add more than two numbers using the Arguments object.

        function addNumbers() {
            var sum = 0;

            for (var i = 0; i < arguments.length; i++)
                sum += arguments[i];

            return sum;

        console.log("The sum of the numbers are " + addNumbers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));

Search This Blog