Tech Junkie Blog - Real World Tutorials, Happy Coding!

Latest Posts

Monday, June 13, 2022

 It is useful in Linux to create cached shared Linux libraries especially is you are developing something.  To do that you first have to create a shared library directory inside the extension libraries which is located in the path /etc/ , if you run the command ls inside the /etc/ you will see that there's already some configuration files within the extension libraries itself

Now let's create a library to contain the shared libraries type in the command mkdir /usr/local/lib/devlibs

What we need to do next is to grab some libraries and put it into the folder we just created, type ldd /bin/bash to get the libraries for bash

Let's copy the /lib64/ into the devlibs folder with the command cp /lib64/ /usr/local/lib/devlibs/ the next thing we need to do is give executable permission to the library so that other programs can execute it, when it's needed with the command chmod +x /usr/local/lib/devlibs/ 

Make sure you are in the /etc/ directory, create a configuration file and name it devlibs.conf with the command vi devlibs.conf and type in the lib folder you've just created, press esc, :x to save the file

We now have update our cache library configuration file located in /etc/ we can't update it manually we have to use the ldconfig command to update it. so type in the command ldconfig to update the cache library configuration.  Now if you run the command ls -l /etc/ you will see that it was updated recently

Monday, June 6, 2022

 As a Linux administrator you will eventually have to deal with libraries.  Libraries are the building blocks of applications and most applications uses shared libraries among them.  I could be beneficial to load the shared libraries from a centralized location.  For example if you want to load shared libraries for developers in a particular location, you can do that.

To load the libraries from a cached location we first need to view the shared libraries in the application/process.  Let's work with the currently running process.  First let's get the processes that are running with the ps -l command.  The first way you can view the shared libraries information is by running the ldd command, the ldd command needs the path to the process.  

As you can see bash is one of the processes that is currently running that is a good candidate to run the ldd command on, but we don't know the path to the process.  We can get more information about the process with the command ps aux | grep bash

From the ps aux command we found out the the path of the process is /bin/bash for root so we can finally view the libraries for bash with the command ldd /bin/bash

As you can see that was quite a lot of work to get to the path.  There's another way to get the libraries for bash and that is the pmap command.  For the pmap command you will need the pid of the process so to see the bash process libraries you can type pmap 870

Monday, May 30, 2022

 In Linux there's a great reporting tool that can look in the past for performance issues, it's an activity reporter call sar, it's an accounting tool which records the information on a cumulative and interval basis.

We can run sar to report on the CPU information with this command sar -u

As you can see there's historical data of a recent restart of the system at 2:46 and from the entries you see that the information is being recorded about every 10 minutes starting at 2:50 PM

You can switch it up and report on the memory utilization with the command sar -r

Or we can look at the disk access with the command sar -b

We could even look at our network adapter information with the command sar -n DEV

There's another good option you can run that is the sar -q option which will show you the load average for the system

You can also specify the the time you wan to look at by giving it a range like so sar -s 03:30:02 -e 05:10:01 and only those time intervals will show up

Monday, May 23, 2022

 In this post we are going to go over the steps to install the Ssysstat tool in Linux. Log in as root or su then run the command yum install -y sysstat, you might already have it installed so you might get this message

[root@cent7 jhuynh]# yum install -y sysstat
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
base                                                                                                                                                                                        | 3.6 kB  00:00:00     
extras                                                                                                                                                                                      | 2.9 kB  00:00:00     
updates                                                                                                                                                                                     | 2.9 kB  00:00:00     
updates/7/x86_64/primary_db                                                                                                                                                                 | 8.8 MB  00:00:01     
Package sysstat-10.1.5-19.el7.x86_64 already installed and latest version
Nothing to do

Now that we know sysstat is installed we can start the service with the command systemctl start sysstat then enable it with the command systemctl enable sysstat and finally we can check to see the that service is running by checking the status with this command systemctl status sysstat

Monday, May 16, 2022

 vmstat is used to report virtual memory stats on your Linux system.  It is helpful to see how much free memory you have left on your system.

As with top you can run the command by typing vmstat, it defaults to kilobytes

You can change the default measure unit by specifying the unit like this vmstat -S m, this will run the command in millibytes, we can see that we have 372 MB of memory free and 1 MB of buffer

You can also run vmstat in intervals by typing the following command vmstat 3 5, the command tells vmstat to run every 3 seconds for five times

Monday, May 9, 2022

 The top command is an essential tool in any Linux administrator's toolbelt.  Let's take a deeper look at the command.

First thing you can do is get the version of top we are using

[root@cent7 jhuynh]# top -v
  procps-ng version 3.3.10
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]

If you just type top with no options you will get the following information, the information will update every 3 seconds by default.  The top area is a summary of resources and CPU usage while the bottom portion are information about the processes.  The information is sort by CPU utilization by default.

Press q to quit, you can also run the top command in batch mode by specifying how many times you want it to run by typing the command like this top -b -n1 the command uses the -b option for batch and -n for the number of iterations, in this case it's one

As you can see it only runs once and you get your prompt back, you use your mouse to scroll back up. You can also write the results to a file like this top -b -n1 > top-stats

Monday, May 2, 2022

Instead of testing to see if a property exists in the object you could just use the for/in loop to iterate through all the enumerable properties in the object.  Enumerable properties are the properties that owned by the object.  In JavaScript there are always two objects that are created with each object, one hidden object that's always there is the prototype object.  It's like the blueprint for the object you just created.  The owned properties are the properties that explicitly created with your object. The prototype properties are what's called inherited properties. So if we use the for/in loop we  will get the owned properties and the prototype properties.

So to use the for/in loop to iterate through the object let's use our product object again.

        var product = new Object(); = "Chai";
        product.category = "Tea"; = "India";
        product.supplier = {
            name: "ACME Tea Of India",
            location: "New Delhi"

Now type in the following to loop through the object with the for/in loop and outputs the property name and property value to the console

Monday, April 25, 2022

An ASP.NET MVC can get big, and it could be overwhelming.  Areas are a way to break up the application into smaller segments,  A perfect candidate for an Area is the Administrative features of the site because it has multiple pages, and functionalities.  So it is a good idea to segment off the Administration area to its own area (no pun intended).

Monday, April 18, 2022

 In the previous post we created an EC2 instance in AWS in this post we are going to connect to that instance on a Linux workstation or server with SSH.

Here are the steps to connect to the EC2 instance using SSH on Linux, this will also work on a Mac as well:

1. Navigate to the folder that contains the key pair file that you've downloaded in the previous post, I store it in the folder /aws/EC2/KeyPair/ folder , so I would type cd /aws/EC2/KeyPair then type ls to see the file in the folder

Monday, April 11, 2022

 In this post we are going to look at another performance related command, which is the uptime command.

First let's look at the uptime command, as the name implies the uptime command shows you what the uptime is for the system:

[root@cent7 jhuynh]# uptime
 12:41:20 up  1:29,  2 users,  load average: 0.05, 0.04, 0.06

The command shows you the uptime for the system, the number of users who are using the system, and the system load average (Number of CPU used) in intervals of 5 minutes.

If you type w, you can see which users are using the system

[root@cent7 jhuynh]# w
 12:41:29 up  1:29,  2 users,  load average: 0.04, 0.04, 0.06
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
jhuynh   :0       :0               11:15   ?xdm?   3:02   0.49s /usr/libexec/gnome-session-binary --session gnome-classic
jhuynh   pts/0    :0               11:21    1.00s  0.42s 11.27s /usr/libexec/gnome-terminal-server

The load average is the most important stat in the uptime command however, it is currently static, and to get updates you need to run the uptime every 5 minutes.  There's a better way to monitor your Linux system.  But you have to call now, and for a limited time only for just $19.99 you can have the answer.  Since I am such a nice guy I am going to give you the answer for free.

What you can do is type the command tload and it will monitor the load average time in real-time. Before we run the tload command a good command to run is the lscpu command to see how many CPU you have.  For instance you have just one CPU and your load average is 1+ then you have got a problem.

[root@cent7 jhuynh]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel

Now let's run the tload command

There are two parts to the tload utility, at the top you will see the average load time in real time instead of the 1, 5, 15 minute interval like before.  But it will be dynamic and updates automatically based on the load.

On the bottom you will see a graphical representation of the load average, it's probably not going to win any awards for best graphics 


Everything looks fine right now, but if you open another terminal and run the dnf update -y command you will see the load changing accordingly. Or some tasks that would put stress on the system.

Search This Blog