Tech Junkie Blog - Real World Tutorials, Happy Coding!: June 2022

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/ld.so.conf.d , if you run the command ls inside the /etc/ld.so.conf.d 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/libtinfo.so.5 into the devlibs folder with the command cp /lib64/libtinfo.so.5 /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/libtinfo.so.5 

Make sure you are in the /etc/ld.so.conf.d/ 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/ld.so.cache 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/ld.so.cache 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




Search This Blog