tag:blogger.com,1999:blog-18300418397849540982024-03-19T07:07:09.918-04:00Tech Junkie Blog - Real World Tutorials, Happy Coding!Features blogs and source codes on back end technologies ASP.NET, SQL, C#, SQL Server, Database, APS.NET MVC Entity Framework, as well as front end technologes such as JQuery, HTML5, CSS, JavaScript, ,Bootstrap, we also cover server side technologies which includes virtualization, LinuxJason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.comBlogger425125tag:blogger.com,1999:blog-1830041839784954098.post-36738736712776206022024-01-16T11:25:00.003-05:002024-01-16T11:25:00.242-05:00Linux: Installing Apache Web Server On Linux Mint<p> Apache (HTTPD) is the most popular web server on the web right now. It is from the Apache Software Foundation. A web server serves content to the web. The power of Apache lies in it's modules which allows you to process scripting languages such as Perl, and PHP.</p><br>In this blog we will go over how to install the Apache Http Web Server on the Ubuntu Server:<br><br>1. In the terminal type in the following command<br><br>apt-cache search apache | more<br><br><a href="https://www.techjunkieblog.com/2024/01/linux-installing-apache-web-server-on.html#more">Read more »</a>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com9tag:blogger.com,1999:blog-1830041839784954098.post-42039060476505794982024-01-15T18:46:00.013-05:002024-01-15T18:46:00.261-05:00Linux Mint: Installing Visual Studio Code, Postman, Eclipse IDE, NodeJs<p> Linux Mint has made installing new software a lot easier in Linux. It actually allows you to install more software out of the box with Flathub software source. All you have to do is do a search for it. The first software we are going to install is Visual Studio Code.</p><p>1. Open the "Software Manager"</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip3oyFjS8KWBfMJ_DekhOBwy2fXfyT9PB0N_3WytEiS4pclAZVSAONxvWdgeS_eqQZJsgYfc4fiEGBOI4vbBLCrkUfsrlcBGf8Hq6BCUFTyOBmXa4V9PGX0rlIIPwG9U1Exjr_IZGolRz7TSDfQ5Tfm2Ho00xU5ACx_r_Ld1w4iyEIYf1pvwuXGqMRM2xC/s553/software-manager.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="545" data-original-width="553" height="315" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip3oyFjS8KWBfMJ_DekhOBwy2fXfyT9PB0N_3WytEiS4pclAZVSAONxvWdgeS_eqQZJsgYfc4fiEGBOI4vbBLCrkUfsrlcBGf8Hq6BCUFTyOBmXa4V9PGX0rlIIPwG9U1Exjr_IZGolRz7TSDfQ5Tfm2Ho00xU5ACx_r_Ld1w4iyEIYf1pvwuXGqMRM2xC/s320/software-manager.png" width="320"></a></div><br><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><span></span><a href="https://www.techjunkieblog.com/2024/01/linux-mint-installing-visual-studio.html#more">Read more »</a>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com14tag:blogger.com,1999:blog-1830041839784954098.post-57149607440665410882024-01-14T17:06:00.000-05:002024-01-14T17:06:39.311-05:00Linux Mint: Making Linux Mint Fullscreen On Oracle VirtualBox<p> If you've installed an operating system in VirtualBox before you've probably noticed the screen is really small even when you switch to Fullscreen mode. It's so small that you can't even see the fonts for the icons if you have a desktop GUI installed. To fix this problem VirtualBox provides us with the Guest Additions tool. Which enables the virtual machine to be viewed at fullscreen.</p><br><a href="https://www.techjunkieblog.com/2024/01/linux-mint-making-linux-mint-fullscreen.html#more">Read more »</a>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com8tag:blogger.com,1999:blog-1830041839784954098.post-29356823993833111322022-06-13T08:00:00.002-04:002022-06-13T08:00:00.192-04:00Linux Package Management: Create A Cache Shared Libraries Location<p> 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</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-ribCTdv-G4Y/YM5fU0sECqI/AAAAAAAAGRk/7jti0HlO_X8PDKv54d3OC0HO18quukzhQCLcBGAsYHQ/s716/shared.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="167" data-original-width="716" height="150" src="https://1.bp.blogspot.com/-ribCTdv-G4Y/YM5fU0sECqI/AAAAAAAAGRk/7jti0HlO_X8PDKv54d3OC0HO18quukzhQCLcBGAsYHQ/w640-h150/shared.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>Now let's create a library to contain the shared libraries type in the command mkdir /usr/local/lib/devlibs</p><p>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</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-pVDAqZdTS98/YM5iYzftP8I/AAAAAAAAGRs/6jcxtzX5NsoLE-A9wjjHYSolbEheKDRAACLcBGAsYHQ/s621/shared-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="107" data-original-width="621" height="110" src="https://1.bp.blogspot.com/-pVDAqZdTS98/YM5iYzftP8I/AAAAAAAAGRs/6jcxtzX5NsoLE-A9wjjHYSolbEheKDRAACLcBGAsYHQ/w640-h110/shared-2.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p>Let's copy the /lib64/libtinfo.so.5 into the devlibs folder with the command <b>cp /lib64/libtinfo.so.5 /usr/local/lib/devlibs/</b> 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 <b>chmod +x /usr/local/lib/devlibs/libtinfo.so.5 </b></p><p>Make sure you are in the <b>/etc/ld.so.conf.d/</b> directory, create a configuration file and name it devlibs.conf with the command <b>vi devlibs.conf</b> and type in the lib folder you've just created, press esc, :x to save the file</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-XtmOCbc5lF0/YM5l3PnobZI/AAAAAAAAGR0/Y5vI79v1hcIzKyhoPGRsaeNWygwNaOhpACLcBGAsYHQ/s238/shared-4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="75" data-original-width="238" src="https://1.bp.blogspot.com/-XtmOCbc5lF0/YM5l3PnobZI/AAAAAAAAGR0/Y5vI79v1hcIzKyhoPGRsaeNWygwNaOhpACLcBGAsYHQ/s0/shared-4.png" /></a></div><br /><p><br /></p><p><br /></p><p>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 <b>ldconfig </b>command to update it. so type in the command ldconfig to update the cache library configuration. Now if you run the command <b>ls -l /etc/ld.so.cache</b> you will see that it was updated recently</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-z_ImLG8oBvE/YM5nxJXm96I/AAAAAAAAGR8/U43n0ESONzkO7IM1ihujAtM2irtddd0SACLcBGAsYHQ/s691/shared-5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="96" data-original-width="691" height="88" src="https://1.bp.blogspot.com/-z_ImLG8oBvE/YM5nxJXm96I/AAAAAAAAGR8/U43n0ESONzkO7IM1ihujAtM2irtddd0SACLcBGAsYHQ/w640-h88/shared-5.png" width="640" /></a></div><br /><p><br /></p><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com54tag:blogger.com,1999:blog-1830041839784954098.post-21110853303157122182022-06-06T08:00:00.003-04:002022-06-06T08:00:00.179-04:00Linux Package Management: Viewing Shared Libraries With ldd And pmap<p> 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.</p><p>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 <b>ps -l</b> 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. </p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-GQCtlUTmfbM/YM5HIV2kltI/AAAAAAAAGRM/z0eFAqhN3J8WrvocIftjUVDTPbeD6onngCLcBGAsYHQ/s649/ldd.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="108" data-original-width="649" height="106" src="https://1.bp.blogspot.com/-GQCtlUTmfbM/YM5HIV2kltI/AAAAAAAAGRM/z0eFAqhN3J8WrvocIftjUVDTPbeD6onngCLcBGAsYHQ/w640-h106/ldd.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p>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 <b>ps aux | grep bash</b></p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-3pq86SyIQ58/YM5W6qx-uTI/AAAAAAAAGRU/J_YHuOHzzPAFPM3P4BQyFWb4FqHziHw9wCLcBGAsYHQ/s850/ldd-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="225" data-original-width="850" height="170" src="https://1.bp.blogspot.com/-3pq86SyIQ58/YM5W6qx-uTI/AAAAAAAAGRU/J_YHuOHzzPAFPM3P4BQyFWb4FqHziHw9wCLcBGAsYHQ/w640-h170/ldd-2.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>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 <b>ldd /bin/bash</b></p><p>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 <b>pmap </b>command. For the pmap command you will need the pid of the process so to see the bash process libraries you can type<b> pmap 870</b></p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-8DYPuljZDq0/YM5ZJzZ17pI/AAAAAAAAGRc/zlv9RGZKWYQ0kF_AJ7PaVZvNc8qvIY-mgCLcBGAsYHQ/s484/pmap.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="314" data-original-width="484" height="416" src="https://1.bp.blogspot.com/-8DYPuljZDq0/YM5ZJzZ17pI/AAAAAAAAGRc/zlv9RGZKWYQ0kF_AJ7PaVZvNc8qvIY-mgCLcBGAsYHQ/w640-h416/pmap.png" width="640" /></a></div><br /><p><br /></p><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com32tag:blogger.com,1999:blog-1830041839784954098.post-14379034082433511212022-05-30T08:00:00.002-04:002022-05-30T08:00:00.205-04:00Linux Performance: sar Reporting Tool<p> 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.</p><p>We can run sar to report on the CPU information with this command sar -u</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-GZ13NcgvhXM/YMfFu4elC_I/AAAAAAAAGO4/1RLaSTt_n088VWPRLv0e09OwToqz2er6wCLcBGAsYHQ/s719/sar.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="244" data-original-width="719" height="218" src="https://1.bp.blogspot.com/-GZ13NcgvhXM/YMfFu4elC_I/AAAAAAAAGO4/1RLaSTt_n088VWPRLv0e09OwToqz2er6wCLcBGAsYHQ/w640-h218/sar.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">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</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">You can switch it up and report on the memory utilization with the command sar -r</div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-3UoL6L7R1XU/YMfGzbnDPlI/AAAAAAAAGPA/-unDcelRSGYCMZVMOF7pFacC0vGik4r2gCLcBGAsYHQ/s651/sar-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="204" data-original-width="651" height="200" src="https://1.bp.blogspot.com/-3UoL6L7R1XU/YMfGzbnDPlI/AAAAAAAAGPA/-unDcelRSGYCMZVMOF7pFacC0vGik4r2gCLcBGAsYHQ/w640-h200/sar-2.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Or we can look at the disk access with the command sar -b</div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-mywYxVpMOoU/YMfHZOVJ3CI/AAAAAAAAGPI/xh6JlCvFWekQ2TVCow_EKFnBSrEXFCldgCLcBGAsYHQ/s571/sar-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="323" data-original-width="571" height="362" src="https://1.bp.blogspot.com/-mywYxVpMOoU/YMfHZOVJ3CI/AAAAAAAAGPI/xh6JlCvFWekQ2TVCow_EKFnBSrEXFCldgCLcBGAsYHQ/w640-h362/sar-3.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: left;">We could even look at our network adapter information with the command sar -n DEV</div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-0pNjlBUwpAk/YMfILF_Ms1I/AAAAAAAAGPQ/gy2gDuhCQ4Ij7TP0DzhHgLok2GCY7Rp8QCLcBGAsYHQ/s833/sar-4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="244" data-original-width="833" height="188" src="https://1.bp.blogspot.com/-0pNjlBUwpAk/YMfILF_Ms1I/AAAAAAAAGPQ/gy2gDuhCQ4Ij7TP0DzhHgLok2GCY7Rp8QCLcBGAsYHQ/w640-h188/sar-4.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: left;"><br /></div>There's another good option you can run that is the sar -q option which will show you the load average for the system<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-nGSFgu7T5O8/YMfIy7uj14I/AAAAAAAAGPY/4aOrq6Lc3cIwv1rdnw9f007kDE4wqj6FwCLcBGAsYHQ/s672/sar-5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="228" data-original-width="672" height="218" src="https://1.bp.blogspot.com/-nGSFgu7T5O8/YMfIy7uj14I/AAAAAAAAGPY/4aOrq6Lc3cIwv1rdnw9f007kDE4wqj6FwCLcBGAsYHQ/w640-h218/sar-5.png" width="640" /></a></div><br /><div><br /><div class="separator" style="clear: both; text-align: left;">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</div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-QJmSXnhyo7s/YMfKsXDQLoI/AAAAAAAAGPg/Ik31Nw-Fn1cpCVI528z5sp3i8cUFO8JSQCLcBGAsYHQ/s1011/sar-6.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="34" data-original-width="1011" height="22" src="https://1.bp.blogspot.com/-QJmSXnhyo7s/YMfKsXDQLoI/AAAAAAAAGPg/Ik31Nw-Fn1cpCVI528z5sp3i8cUFO8JSQCLcBGAsYHQ/w640-h22/sar-6.png" width="640" /></a></div><div><br /></div><div><br /></div><div><br /></div><br /></div><div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div><br /><p><br /></p></div>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com5tag:blogger.com,1999:blog-1830041839784954098.post-7911556469553828622022-05-23T08:00:00.001-04:002022-05-23T08:00:00.190-04:00Linux Performance Sysstat: Installing Sysstat<p> 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</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># yum install -y sysstat</span></div><div>Loaded plugins: fastestmirror, langpacks</div><div>Loading mirror speeds from cached hostfile</div><div> * base: linux-mirrors.fnal.gov</div><div> * epel: ewr.edge.kernel.org</div><div> * extras: centos.mirror.constant.com</div><div> * updates: centos-distro.1gservers.com</div><div>base | 3.6 kB 00:00:00 </div><div>extras | 2.9 kB 00:00:00 </div><div>updates | 2.9 kB 00:00:00 </div><div>updates/7/x86_64/primary_db | 8.8 MB 00:00:01 </div><div>Package sysstat-10.1.5-19.el7.x86_64 already installed and latest version</div><div>Nothing to <span style="color: #c586c0;">do</span></div><br /></div><p>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</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-yM657ymeV4E/YMe1ZROCc6I/AAAAAAAAGOw/bR2xkTQswSYmq_uU-LRJbGlEXFn2N-nwwCLcBGAsYHQ/s831/sysstat.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="220" data-original-width="831" height="170" src="https://1.bp.blogspot.com/-yM657ymeV4E/YMe1ZROCc6I/AAAAAAAAGOw/bR2xkTQswSYmq_uU-LRJbGlEXFn2N-nwwCLcBGAsYHQ/w640-h170/sysstat.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com10tag:blogger.com,1999:blog-1830041839784954098.post-34833343614148695652022-05-16T08:00:00.002-04:002022-05-16T08:00:00.196-04:00Linux Performance: vmstat Command<p> 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.</p><p>As with top you can run the command by typing <b>vmstat</b>, it defaults to kilobytes</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-nsP0gKnOWmQ/YMeuRTIm5gI/AAAAAAAAGOY/GMgW-U4Nxtso0lIt16XXnA4yVi8uPPerwCLcBGAsYHQ/s743/top-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="67" data-original-width="743" height="58" src="https://1.bp.blogspot.com/-nsP0gKnOWmQ/YMeuRTIm5gI/AAAAAAAAGOY/GMgW-U4Nxtso0lIt16XXnA4yVi8uPPerwCLcBGAsYHQ/w640-h58/top-3.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p>You can change the default measure unit by specifying the unit like this <b>vmstat -S m</b>, this will run the command in millibytes, we can see that we have 372 MB of memory free and 1 MB of buffer</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-x8AM-ON_khg/YMevIk6orgI/AAAAAAAAGOg/jRCOhl6NSY8-ZwxrI3IKlXjEL0mmtuzLACLcBGAsYHQ/s733/vmstat.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="71" data-original-width="733" height="62" src="https://1.bp.blogspot.com/-x8AM-ON_khg/YMevIk6orgI/AAAAAAAAGOg/jRCOhl6NSY8-ZwxrI3IKlXjEL0mmtuzLACLcBGAsYHQ/w640-h62/vmstat.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p>You can also run vmstat in intervals by typing the following command <b>vmstat 3 5</b>, the command tells vmstat to run every 3 seconds for five times</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-kO-DvvOjogo/YMewR-uigqI/AAAAAAAAGOo/g0rNBg4O2MYtUhjQy6UdTswpaCB9l_9hwCLcBGAsYHQ/s735/vmstat-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="145" data-original-width="735" height="126" src="https://1.bp.blogspot.com/-kO-DvvOjogo/YMewR-uigqI/AAAAAAAAGOo/g0rNBg4O2MYtUhjQy6UdTswpaCB9l_9hwCLcBGAsYHQ/w640-h126/vmstat-2.png" width="640" /></a></div><br /><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com6tag:blogger.com,1999:blog-1830041839784954098.post-22331489020005978222022-05-09T08:00:00.006-04:002022-05-09T08:00:00.199-04:00Linux Performance: top Command<p> The top command is an essential tool in any Linux administrator's toolbelt. Let's take a deeper look at the command.</p><p>First thing you can do is get the version of top we are using</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="1"><div wfd-id="5">[root@cent7 jhuynh]<span style="color: #6a9955;"># top -v</span></div><div wfd-id="4"> procps-ng version 3.3.10</div><div wfd-id="3">Usage:</div><div wfd-id="2"> top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]</div><br /></div><p>If you just type <b>top </b>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.</p><div class="separator" style="clear: both; text-align: center;" wfd-id="0"><a href="https://1.bp.blogspot.com/-TuSrAhGv8jM/YMJzxppheUI/AAAAAAAAGOI/YFV_FtM_1uw-WRRCfm7Io4RJplZAtKbzwCLcBGAsYHQ/s723/top.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="259" data-original-width="723" height="230" src="https://1.bp.blogspot.com/-TuSrAhGv8jM/YMJzxppheUI/AAAAAAAAGOI/YFV_FtM_1uw-WRRCfm7Io4RJplZAtKbzwCLcBGAsYHQ/w640-h230/top.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>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 <b>top -b -n1</b> the command uses the -b option for batch and -n for the number of iterations, in this case it's one</p><p>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 <b>top -b -n1 > top-stats</b></p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-JxEvu-VcjKE/YMer0EKry4I/AAAAAAAAGOQ/oH-vwguA7XQ_t-4h3Cz0yEouSGA6ppLVgCLcBGAsYHQ/s323/top-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="102" data-original-width="323" src="https://1.bp.blogspot.com/-JxEvu-VcjKE/YMer0EKry4I/AAAAAAAAGOQ/oH-vwguA7XQ_t-4h3Cz0yEouSGA6ppLVgCLcBGAsYHQ/s320/top-2.png" width="320" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com8tag:blogger.com,1999:blog-1830041839784954098.post-21963610547361716472022-05-02T21:56:00.001-04:002022-05-02T21:56:00.168-04:00JavaScript Objects Deep Dive: Enumerating Through Object Properties with for/in LoopInstead 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.<br>
<br>
So to use the for/in loop to iterate through the object let's use our product object again.<br>
<br>
<br>
<pre class="prettyprint"><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px;"><div> <span style="color: #569cd6;">var</span> <span style="color: #9cdcfe;">product</span> = <span style="color: #569cd6;">new</span> <span style="color: #4ec9b0;">Object</span>();</div><br><div> <span style="color: #9cdcfe;">product</span>.<span style="color: #9cdcfe;">name</span> = <span style="color: #ce9178;">"Chai"</span>;</div><div> <span style="color: #9cdcfe;">product</span>.<span style="color: #9cdcfe;">category</span> = <span style="color: #ce9178;">"Tea"</span>;</div><div> <span style="color: #9cdcfe;">product</span>.<span style="color: #9cdcfe;">country</span> = <span style="color: #ce9178;">"India"</span>;</div><div> <span style="color: #9cdcfe;">product</span>.<span style="color: #9cdcfe;">supplier</span> = {</div><div> <span style="color: #9cdcfe;">name:</span> <span style="color: #ce9178;">"ACME Tea Of India"</span>,</div><div> <span style="color: #9cdcfe;">location:</span> <span style="color: #ce9178;">"New Delhi"</span></div><div> };</div></div>
</pre>
<br>
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<br>
<br>
<a href="https://www.techjunkieblog.com/2017/11/javascript-objects-deep-dive.html#more">Read more »</a>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com40tag:blogger.com,1999:blog-1830041839784954098.post-33444904542763290762022-04-25T23:21:00.001-04:002022-04-25T23:21:00.169-04:00Hour 18 ASP.NET Core: Add Area For AdministratorsAn 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).<br>
<br>
<a href="https://www.techjunkieblog.com/2019/08/hour-18-aspnet-core-add-area-for.html#more">Read more »</a>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com32tag:blogger.com,1999:blog-1830041839784954098.post-58743606738509994472022-04-18T07:00:00.002-04:002022-04-18T07:00:00.174-04:00Iaas With AWS: Connect to EC2 Linux Instance On Linux Using SSH<p> In the previous <a href="https://www.techjunkieblog.com/2020/08/iaas-with-aws-create-ec2-amazon-linux-2.html" target="_blank">post </a>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.</p><p>Here are the steps to connect to the EC2 instance using SSH on Linux, this will also work on a Mac as well:</p><p>1. Navigate to the folder that contains the key pair file that you've downloaded in the previous <a href="https://www.techjunkieblog.com/2020/08/iaas-with-aws-create-ec2-amazon-linux-2.html" target="_blank">post</a>, I store it in the folder /aws/EC2/KeyPair/ folder , so I would type <b>cd /aws/EC2/KeyPair</b> then type <b>ls </b>to see the file in the folder</p><p><a href="https://1.bp.blogspot.com/-BNJe5Sfd22M/XzHDj7-uoBI/AAAAAAAAFAU/1NwezE0aVQ46Z5AzXls7bJXlq54xqCD8ACLcBGAsYHQ/s455/ssh-linux.png" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" data-original-height="152" data-original-width="455" src="https://1.bp.blogspot.com/-BNJe5Sfd22M/XzHDj7-uoBI/AAAAAAAAFAU/1NwezE0aVQ46Z5AzXls7bJXlq54xqCD8ACLcBGAsYHQ/s0/ssh-linux.png"></a></p><p><span></span></p><a href="https://www.techjunkieblog.com/2020/08/iaas-with-aws-connect-to-ec2-linux.html#more">Read more »</a>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com112tag:blogger.com,1999:blog-1830041839784954098.post-3145097169546265782022-04-11T08:00:00.004-04:002022-04-11T08:00:00.175-04:00Linux Performance: uptime, tload Command<p> In this post we are going to look at another performance related command, which is the uptime command.</p><p>First let's look at the uptime command, as the name implies the uptime command shows you what the uptime is for the system:</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="20"><div wfd-id="22">[root@cent7 jhuynh]<span style="color: #6a9955;"># uptime</span></div><div wfd-id="21"> 12:41:20 up 1:29, 2 users, load average: 0.05, 0.04, 0.06</div><br /></div><p>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.</p><p>If you type w, you can see which users are using the system</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="14"><div wfd-id="19">[root@cent7 jhuynh]<span style="color: #6a9955;"># w</span></div><div wfd-id="18"> 12:41:29 up 1:29, 2 users, load average: 0.04, 0.04, 0.06</div><div wfd-id="17">USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT</div><div wfd-id="16">jhuynh :0 :0 11:15 ?xdm? 3:02 0.49s /usr/libexec/gnome-session-binary --session gnome-classic</div><div wfd-id="15">jhuynh pts/0 :0 11:21 1.00s 0.42s 11.27s /usr/libexec/gnome-terminal-server</div><br /></div><p>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.</p><p>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.</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="2"><div wfd-id="13">[root@cent7 jhuynh]<span style="color: #6a9955;"># lscpu</span></div><div wfd-id="12">Architecture: x86_64</div><div wfd-id="11">CPU op-mode(s): 32-bit, 64-bit</div><div wfd-id="10">Byte Order: Little Endian</div><div wfd-id="9">CPU(s): 1</div><div wfd-id="8">On-line CPU(s) list: 0</div><div wfd-id="7">Thread(s) per core: 1</div><div wfd-id="6">Core(s) per socket: 1</div><div wfd-id="5">Socket(s): 1</div><div wfd-id="4">NUMA node(s): 1</div><div wfd-id="3">Vendor ID: GenuineIntel</div><br /></div><p>Now let's run the tload command</p><div class="separator" style="clear: both; text-align: center;" wfd-id="1"><a href="https://1.bp.blogspot.com/-9EW1e1i5e08/YMJGYC7x6HI/AAAAAAAAGN4/SOJHKbFl9ckZrwARQWCo-r9ywpAygQRuwCLcBGAsYHQ/s191/tload.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="44" data-original-width="191" src="https://1.bp.blogspot.com/-9EW1e1i5e08/YMJGYC7x6HI/AAAAAAAAGN4/SOJHKbFl9ckZrwARQWCo-r9ywpAygQRuwCLcBGAsYHQ/s0/tload.png" /></a></div><br /><p><br /></p><p>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.</p><p>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 </p><p></p><div class="separator" style="clear: both; text-align: center;" wfd-id="0"><a href="https://1.bp.blogspot.com/-uSZUswDsb8E/YMJG-0AN6-I/AAAAAAAAGOA/jkBCCUV0WZswJKTDggDLB2SWaPXkHGb9gCLcBGAsYHQ/s216/tload-2.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="216" data-original-width="83" src="https://1.bp.blogspot.com/-uSZUswDsb8E/YMJG-0AN6-I/AAAAAAAAGOA/jkBCCUV0WZswJKTDggDLB2SWaPXkHGb9gCLcBGAsYHQ/s0/tload-2.png" /></a></div><br /> <p></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>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.</p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com6tag:blogger.com,1999:blog-1830041839784954098.post-88432366703765974702022-04-04T08:00:00.001-04:002022-04-04T08:00:00.183-04:00Linux Performance: procps-ng Commands, free, pmap, pwdx<p> In this post we are going to look at the procps-ng package commands to get some performance related information on our Linux system.</p><p>The first command we are going to look at is the free command, which shows the free memory available</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># free</span></div><div> total used free shared buff/cache available</div><div>Mem: 1882072 754028 404848 33544 723196 942276</div><div>Swap: 978940 0 978940</div><br /></div><p>We can use the free command with the -m option to show the free memory in megabytes</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># free -m</span></div><div> total used free shared buff/cache available</div><div>Mem: 1837 734 397 32 706 922</div><div>Swap: 955 0 955</div><br /></div><p>Or free -g for gigabytes</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># free -g</span></div><div> total used free shared buff/cache available</div><div>Mem: 1 0 0 0 0 0</div><div>Swap: 0 0 0</div></div><p>The next command we are going to look at is the pmap command, let's grab a process id for this one with the ps -l command</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># ps -l</span></div><div>F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD</div><div>4 S 0 3358 3315 0 80 0 - 68658 poll_s pts/0 00:00:00 sudo</div><div>4 S 0 3365 3358 0 80 0 - 58056 do_wai pts/0 00:00:00 su</div><div>4 S 0 3368 3365 0 80 0 - 29107 do_wai pts/0 00:00:00 bash</div><div>0 R 0 4238 3368 0 80 0 - 38332 - pts/0 00:00:00 ps</div><br /></div><p>Let's run the pmap command on the bash process, the pmap command displays the memory map of a process, besides the memory usage it's nice to see the shared libraries used for the process</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># pmap 3368</span></div><div>3368: bash</div><div>0000000000400000 888K r-x-- bash</div><div>00000000006dd000 4K r---- bash</div><div>00000000006de000 36K rw--- bash</div><div>00000000006e7000 24K rw--- [ anon ]</div><div>00000000021b3000 1144K rw--- [ anon ]</div><div>00007f53b0616000 48K r-x-- libnss_files-2.17.so</div><div>00007f53b0622000 2044K ----- libnss_files-2.17.so</div><div>00007f53b0821000 4K r---- libnss_files-2.17.so</div><div>00007f53b0822000 4K rw--- libnss_files-2.17.so</div><br /></div><p>Another useful command is the pwdx command, this command finds the home working directory of a process. So if we run the command pwdx 3368 we will find out what the home working directory of the bash shell is</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># pwdx 3368</span></div><div>3368: /home/jhuynh</div><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># ps -l</span></div><div>F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD</div><div>4 S 0 3358 3315 0 80 0 - 68658 poll_s pts/0 00:00:00 sudo</div><div>4 S 0 3365 3358 0 80 0 - 58056 do_wai pts/0 00:00:00 su</div><div>4 S 0 3368 3365 0 80 0 - 29107 do_wai pts/0 00:00:00 bash</div><div>0 R 0 4345 3368 0 80 0 - 38332 - pts/0 00:00:00 ps</div><br /></div><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com3tag:blogger.com,1999:blog-1830041839784954098.post-67993987420945127272022-03-28T08:00:00.028-04:002022-03-28T08:00:00.198-04:00Linux Process Management: Controlling Process Priority With nice And renice Command<p> In Linux you can control the priority of a process with the commands nice and renice. There are limitations if you are a non-root user. The nice and renice commands have the values in the range of -20 to +19. The higher the numbers the higher the priority, or the nicer the process is meaning the less CPU it would use, so it's kind of the opposite of what you are thinking. So it's like nice guys finished last?</p><p>So if we run the sleep process again let's see what happens by default</p><p>sleep 1500&</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="33"><div wfd-id="42">[root@cent7 jhuynh]<span style="color: #6a9955;"># sleep 1500&</span></div><div wfd-id="41">[1] 3401</div><div wfd-id="40">[root@cent7 jhuynh]<span style="color: #6a9955;"># ps -l</span></div><div wfd-id="39">F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD</div><div wfd-id="38">4 S 0 3358 3315 0 80 0 - 68658 poll_s pts/0 00:00:00 sudo</div><div wfd-id="37">4 S 0 3365 3358 0 80 0 - 58056 do_wai pts/0 00:00:00 su</div><div wfd-id="36">4 S 0 3368 3365 0 80 0 - 29107 do_wai pts/0 00:00:00 bash</div><div wfd-id="35">4 S 0 3401 3368 0 80 0 - 27014 hrtime pts/0 00:00:00 sleep</div><div wfd-id="34">0 R 0 3402 3368 0 80 0 - 38332 - pts/0 00:00:00 ps</div></div><p>As you can see the priority(PRI) is set to 80 percent by default</p><p>Now let's be a nice guy and assign the sleep process to the nicest value -19</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="22"><div wfd-id="32">[root@cent7 jhuynh]<span style="color: #6a9955;"># nice -n 19 sleep 1500&</span></div><div wfd-id="31">[2] 3438</div><div wfd-id="30">[root@cent7 jhuynh]<span style="color: #6a9955;"># ps -l</span></div><div wfd-id="29">F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD</div><div wfd-id="28">4 S 0 3358 3315 0 80 0 - 68658 poll_s pts/0 00:00:00 sudo</div><div wfd-id="27">4 S 0 3365 3358 0 80 0 - 58056 do_wai pts/0 00:00:00 su</div><div wfd-id="26">4 S 0 3368 3365 0 80 0 - 29107 do_wai pts/0 00:00:00 bash</div><div wfd-id="25">4 S 0 3401 3368 0 80 0 - 27014 hrtime pts/0 00:00:00 sleep</div><div wfd-id="24">4 S 0 3438 3368 0 99 19 - 27014 hrtime pts/0 00:00:00 sleep</div><div wfd-id="23">0 R 0 3439 3368 0 80 0 - 38332 - pts/0 00:00:00 ps</div><br /></div><p>As you can see the new sleep process is set to priority 99 meaning only run the process if processes with the a lower number is ran first. It's like being the 99th person in line.</p><p>If you run it at the highest nice value, not so nice. Let's see what happens</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="11"><div wfd-id="21">[root@cent7 jhuynh]<span style="color: #6a9955;"># nice -n -20 sleep 1500&</span></div><div wfd-id="20">[2] 3546</div><div wfd-id="19">[root@cent7 jhuynh]<span style="color: #6a9955;"># ps -l</span></div><div wfd-id="18">F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD</div><div wfd-id="17">4 S 0 3358 3315 0 80 0 - 68658 poll_s pts/0 00:00:00 sudo</div><div wfd-id="16">4 S 0 3365 3358 0 80 0 - 58056 do_wai pts/0 00:00:00 su</div><div wfd-id="15">4 S 0 3368 3365 0 80 0 - 29107 do_wai pts/0 00:00:00 bash</div><div wfd-id="14">4 S 0 3543 3368 0 99 19 - 27014 hrtime pts/0 00:00:00 sleep</div><div wfd-id="13">4 S 0 3546 3368 0 60 -20 - 27014 hrtime pts/0 00:00:00 sleep</div><div wfd-id="12">0 R 0 3547 3368 0 80 0 - 38332 - pts/0 00:00:00 ps</div><br /></div><p>You can also reassign the priority of an existing process with renice command, with the renice command you have to specify the process id</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="0"><div wfd-id="10">[root@cent7 jhuynh]<span style="color: #6a9955;"># renice -n 5 -p 3543</span></div><div wfd-id="9">3543 (process ID) old priority 19, new priority 5</div><div wfd-id="8">[root@cent7 jhuynh]<span style="color: #6a9955;"># ps -l</span></div><div wfd-id="7">F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD</div><div wfd-id="6">4 S 0 3358 3315 0 80 0 - 68658 poll_s pts/0 00:00:00 sudo</div><div wfd-id="5">4 S 0 3365 3358 0 80 0 - 58056 do_wai pts/0 00:00:00 su</div><div wfd-id="4">4 S 0 3368 3365 0 80 0 - 29107 do_wai pts/0 00:00:00 bash</div><div wfd-id="3">4 S 0 3543 3368 0 85 5 - 27014 hrtime pts/0 00:00:00 sleep</div><div wfd-id="2">4 S 0 3546 3368 0 60 -20 - 27014 hrtime pts/0 00:00:00 sleep</div><div wfd-id="1">0 R 0 3589 3368 0 80 0 - 38332 - pts/0 00:00:00 ps</div><br /></div><p>Linux was nice enough to tell you that the process has been changed from priority of 19 to 5, so now the process is assigned a priority value of 85. Still the nicest priority!</p><p>The caveat on the renice command is that if you are not a user with root privileges, you cannot set a higher priority than the original priority of a process. </p><p>If you are root you can also control other user's priority settings by editing the /etc/security/limits.conf. Priority is the last item or settings that you can set limits on, so move to the end of the line and type in the following for user limit, if you want group limits you just prefix it with the @ sign</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div><span style="color: #6a9955;">#* soft core 0</span></div><div><span style="color: #6a9955;">#* hard rss 10000</span></div><div><span style="color: #6a9955;">#@student hard nproc 20</span></div><div><span style="color: #6a9955;">#@faculty soft nproc 20</span></div><div><span style="color: #6a9955;">#@faculty hard nproc 50</span></div><div><span style="color: #6a9955;">#ftp hard nproc 0</span></div><div><span style="color: #6a9955;">#@student - maxlogins 4</span></div><br /><div><span style="color: #6a9955;"># End of file</span></div><div>techjunkie - priority 5</div><br /></div><p>Now the next time techjunkie sets a priority he will be limited to priority number 5 nice value. Since he is not a root user he cannot renice the process to be anything higher than 5. Therefore he is a pretty nice guy.</p><p><br /></p><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com0tag:blogger.com,1999:blog-1830041839784954098.post-63569483369240736142022-03-21T08:00:00.006-04:002022-03-21T08:00:00.193-04:00Linux Process Management: Running Processes In The Background And Foreground With bg And fg Command<p> Linux allows you to run jobs in the background and in the foreground. It accomplish this by identifying the processes as jobs and assigning the state to the jobs by numbers.</p><p>First let's create a process, we are just create a sleep job in the background, with the command <b>sleep 1500&</b> the <b>& </b>automatically put the process in the background. If you observe the behavior you will noticed that the prompt is in your control right away because it's running in the background.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-RRPwbzmCuKY/YL-N3ul-G_I/AAAAAAAAGNI/CK4DF1d-U0UX2p7L7yxF0624ASE50oPZwCLcBGAsYHQ/s398/bg.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="74" data-original-width="398" height="74" src="https://1.bp.blogspot.com/-RRPwbzmCuKY/YL-N3ul-G_I/AAAAAAAAGNI/CK4DF1d-U0UX2p7L7yxF0624ASE50oPZwCLcBGAsYHQ/w400-h74/bg.png" width="400" /></a></div><br /><p><br /></p><p><br /></p><p>If you run the jobs command you see the process is running but it's running in the background. However if you forgot to put the & at the end the job will have to be finished before you get your prompt back, the only way to get your prompt back before then is to type <b>CTRL+Z</b> , but that would also stop the process or job from running. That's probably not what you wanted</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-hklcGNfH0A8/YL-OxFcm97I/AAAAAAAAGNQ/AwPvqyN6TaMw2HfFOMgahvSiMmRtjPz8gCLcBGAsYHQ/s412/bg-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="89" data-original-width="412" height="86" src="https://1.bp.blogspot.com/-hklcGNfH0A8/YL-OxFcm97I/AAAAAAAAGNQ/AwPvqyN6TaMw2HfFOMgahvSiMmRtjPz8gCLcBGAsYHQ/w400-h86/bg-2.png" width="400" /></a></div><br /><p><br /></p><p><br /></p><p>You've gotten your prompt back but you've also stopped the process, that's probably not what you wanted to do. You want to get your prompt and keep the job running at the same time. So the solution is to use the <b>bg </b>command to run the job in the background</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-DhtM5QjnvXo/YL-PrCIZ5aI/AAAAAAAAGNY/cVHluHXD5RcoxaDKA4MCj8BUAwg4tnaTACLcBGAsYHQ/s396/bg-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="151" data-original-width="396" height="153" src="https://1.bp.blogspot.com/-DhtM5QjnvXo/YL-PrCIZ5aI/AAAAAAAAGNY/cVHluHXD5RcoxaDKA4MCj8BUAwg4tnaTACLcBGAsYHQ/w400-h153/bg-3.png" width="400" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>To bring the job into the foreground you just type fg</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-Nuy-C9SOHWU/YL-QgTiOuzI/AAAAAAAAGNg/SeQ-ko2ZmKkJo6hx8lc1QM3JHabBUWdAACLcBGAsYHQ/s239/bg-4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="42" data-original-width="239" src="https://1.bp.blogspot.com/-Nuy-C9SOHWU/YL-QgTiOuzI/AAAAAAAAGNg/SeQ-ko2ZmKkJo6hx8lc1QM3JHabBUWdAACLcBGAsYHQ/s0/bg-4.png" /></a></div><br /><p><br /></p><p>As you can see you lose the prompt once the job is put in the foreground because it has to finish running the job before you can get the prompt back. Press <b>CTRL+Z</b> again to interrupt the process</p><p>Now there's another way to put a process in the background, that is to specify the job number. So if we want to put the second job that was stopped in the background again we can type <b>bg 2 </b></p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-pf87-Q_RH7U/YL-RmtevwsI/AAAAAAAAGNo/bHMaHMgmhDoFG5Qm87TLe_bhnUmz0SERgCLcBGAsYHQ/s394/bg-5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="161" data-original-width="394" height="164" src="https://1.bp.blogspot.com/-pf87-Q_RH7U/YL-RmtevwsI/AAAAAAAAGNo/bHMaHMgmhDoFG5Qm87TLe_bhnUmz0SERgCLcBGAsYHQ/w400-h164/bg-5.png" width="400" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>You can do the same thing with the fg command. Kill the sleep process with the command <b>pkill sleep</b> for cleanup</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-Dnxm589pwDE/YL-Slx4pScI/AAAAAAAAGNw/qaJKHV-S7dwq9Z3yJP6HqhSkacKAd5z4ACLcBGAsYHQ/s382/bg-6.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="96" data-original-width="382" height="100" src="https://1.bp.blogspot.com/-Dnxm589pwDE/YL-Slx4pScI/AAAAAAAAGNw/qaJKHV-S7dwq9Z3yJP6HqhSkacKAd5z4ACLcBGAsYHQ/w400-h100/bg-6.png" width="400" /></a></div><br /><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com2tag:blogger.com,1999:blog-1830041839784954098.post-19310073827140371362022-03-14T07:38:00.007-04:002022-03-14T07:38:00.231-04:00Linux Process Management: pgrep, pkill, And top<p> Since searching for a process and killing process is such a common task there's are shortcut commands available for these tasks in form of <b>pgrep </b>and <b>pkill</b>. As you suspect these commands are used for finding and killing processes respectively.</p><p>For example we can search for gnome processes like this instead of combining the ps command with the grep command</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[jhuynh@cent7 ~]$ pgrep gnome</div><div>2292</div><div>2303</div><div>2521</div><div>2570</div><div>2822</div><div>5338</div><div>5345</div></div><p>Or to get more information you can use the command like command below to get the full listing</p><p><span style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; white-space: pre;">[jhuynh@cent7 ~]$ ps -F -p </span><span style="background-color: #1e1e1e; color: #ce9178; font-family: Consolas, "Courier New", monospace; font-size: 16px; white-space: pre;">$(pgrep gnome)</span></p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>UID PID PPID C SZ RSS PSR STIME TTY STAT TIME CMD</div><div>jhuynh 2292 1 0 79358 3836 0 06:53 ? Sl 0:00 /usr/bin/gnome-keyring-daemon --daemonize --login</div><div>jhuynh 2303 2280 0 204743 11336 0 06:53 ? Ssl 0:00 /usr/libexec/gnome-session-binary --session gnome-classic</div><div>jhuynh 2521 2303 1 756875 210812 0 06:53 ? Sl 0:48 /usr/bin/gnome-shell</div><div>jhuynh 2570 1 0 162513 13756 0 06:54 ? Sl 0:00 /usr/libexec/gnome-shell-calendar-server</div><div>jhuynh 2822 2303 0 278015 67620 0 06:54 ? Sl 0:03 /usr/bin/gnome-software --gapplication-service</div><div>jhuynh 5338 1 0 167498 29064 0 07:43 ? Sl 0:01 /usr/libexec/gnome-terminal-server</div><div>jhuynh 5345 5338 0 2134 724 0 07:43 ? S 0:00 gnome-pty-helper</div></div><p>The pkill command works in similar fashion, so instead of killing the process by the number, you can just kill the bash process with this command <b>pkill PID</b>, one caveat is that it does not work like <b>kill -9</b> so your usage may be limited.</p><p>Another useful command is the top command, this command will sort the processes that uses the most resources first by default. All you have to do is type top in the terminal</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-VqyPaE-Edqk/YL9bbcljubI/AAAAAAAAGMs/Npj94cEzeJsv-4HSayeJcYOGFVYxcL9qQCLcBGAsYHQ/s753/ps-12.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="300" data-original-width="753" height="254" src="https://1.bp.blogspot.com/-VqyPaE-Edqk/YL9bbcljubI/AAAAAAAAGMs/Npj94cEzeJsv-4HSayeJcYOGFVYxcL9qQCLcBGAsYHQ/w640-h254/ps-12.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>You sort it by other attributes as well such as memory, by default it's by CUP usage, to get to the other options type the f key</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-Dr5Ae-prYgA/YL9cYH4n46I/AAAAAAAAGM0/ca4kpCGJl-IYgjQq2fMkVMy57Mc8GdcygCLcBGAsYHQ/s605/ps-13.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="319" data-original-width="605" height="338" src="https://1.bp.blogspot.com/-Dr5Ae-prYgA/YL9cYH4n46I/AAAAAAAAGM0/ca4kpCGJl-IYgjQq2fMkVMy57Mc8GdcygCLcBGAsYHQ/w640-h338/ps-13.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>Select %MEM and type <b>s </b>to select it and press esc to sort the top screen by memory usage</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-98mhIzkJKNc/YL9dHWRM9zI/AAAAAAAAGM8/ypOK7udwz6cmGEvWZCkf6pc0_QIbyvqnACLcBGAsYHQ/s750/ps-14.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="286" data-original-width="750" height="244" src="https://1.bp.blogspot.com/-98mhIzkJKNc/YL9dHWRM9zI/AAAAAAAAGM8/ypOK7udwz6cmGEvWZCkf6pc0_QIbyvqnACLcBGAsYHQ/w640-h244/ps-14.png" width="640" /></a></div><br /><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com0tag:blogger.com,1999:blog-1830041839784954098.post-17831896133523722092022-03-07T07:15:00.001-05:002022-03-07T07:15:00.190-05:00Linux Process Management: The kill Command<p> The kill command in Linux is a powerful command to kill a process. You usually see the kill command accompanied by the process ID however there's other ways you can use the kill command. To get a list of how you can use the kill command, type kill -l</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># kill -l</span></div><div> 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP</div><div> 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1</div><div>11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM</div><div>16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP</div><div>21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ</div><div>26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR</div><div>31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3</div><div>38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8</div><div>43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13</div><div>48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12</div><div>53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7</div><div>58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2</div><div>63) SIGRTMAX-1 64) SIGRTMAX </div></div><p>There's one important thing that you have to remember as a standard user you can only kill are your own processes, so if you have two terminals open and one of them is not yours. You can only kill the processes in your terminal or session.</p><p>Let's say you run the command ps to see the processes that are running, all you need to kill a process is type <b>kill -9 PID</b></p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>[root@cent7 jhuynh]<span style="color: #6a9955;"># ps</span></div><div> PID TTY TIME CMD</div><div> 3526 pts/0 00:00:00 sudo</div><div> 3541 pts/0 00:00:00 su</div><div> 3544 pts/0 00:00:00 bash</div><div> 4787 pts/0 00:00:00 ps</div><br /></div><p>So it's something like this <b>kill -9 3544</b> to kill the bash process this will kill the terminal, alternatively you can type out the word that corresponds to -9 with the command <b>kill -sigkill 3544</b></p><p><br /></p><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com2tag:blogger.com,1999:blog-1830041839784954098.post-57437970748685013522022-02-28T08:00:00.002-05:002022-02-28T08:00:00.188-05:00Linux Process Management: The ps command<p> In Linux managing processes is an essential part of keeping your system running in an efficient state. In this post we are going to look at the commonly used ps command.</p><p>If you just type ps you will get the processes that's currently running along with the PID (process ID), TTY (terminal it is running in), Time (CPU utilization time), and the command that is used to run the process</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-sKHEDdPyWJI/YL8bS3yIBDI/AAAAAAAAGLU/kkxEsaRd98gUcpas57nz3Qp8c0yDmAkOQCLcBGAsYHQ/s262/ps.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="147" data-original-width="262" src="https://1.bp.blogspot.com/-sKHEDdPyWJI/YL8bS3yIBDI/AAAAAAAAGLU/kkxEsaRd98gUcpas57nz3Qp8c0yDmAkOQCLcBGAsYHQ/s0/ps.png" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>Here are some of the options that are useful with the ps command:</p><p>1. <b>ps -e</b> this will show you all the processes</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-Xfv9uypz0zQ/YL8dHdGPj6I/AAAAAAAAGLc/P-zE80IYCTAZNMjJxC9XFCyaBoFXb3-cQCLcBGAsYHQ/s341/ps-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="259" data-original-width="341" src="https://1.bp.blogspot.com/-Xfv9uypz0zQ/YL8dHdGPj6I/AAAAAAAAGLc/P-zE80IYCTAZNMjJxC9XFCyaBoFXb3-cQCLcBGAsYHQ/s320/ps-2.png" width="320" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>2. <b>ps aux</b> this will show you all the processes that are not assigned to a user terminal</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-A0vpsGgQ6nA/YL8d097jibI/AAAAAAAAGLk/_Q-oi9fizTgFRbgP0WTGICXPRdPutFeCACLcBGAsYHQ/s739/ps-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="310" data-original-width="739" height="268" src="https://1.bp.blogspot.com/-A0vpsGgQ6nA/YL8d097jibI/AAAAAAAAGLk/_Q-oi9fizTgFRbgP0WTGICXPRdPutFeCACLcBGAsYHQ/w640-h268/ps-3.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>3.<b> ps -e --forest</b> this will show you the process tree view of the process</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-aXaecvd5IuU/YL8ebh_KOUI/AAAAAAAAGLs/d7TQNxyRoOo1vQhUT7je5vFygLcVyQZ9ACLcBGAsYHQ/s551/ps-4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="179" data-original-width="551" height="208" src="https://1.bp.blogspot.com/-aXaecvd5IuU/YL8ebh_KOUI/AAAAAAAAGLs/d7TQNxyRoOo1vQhUT7je5vFygLcVyQZ9ACLcBGAsYHQ/w640-h208/ps-4.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>There's a nicer way to look at the process tree with the command <b>pstree</b></p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-eKY2CvWtew0/YL8e9gRM1NI/AAAAAAAAGL0/mXoTVDBdIRg5isQ-XwDr8M_NaDwjfPFrACLcBGAsYHQ/s530/ps-5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="244" data-original-width="530" height="294" src="https://1.bp.blogspot.com/-eKY2CvWtew0/YL8e9gRM1NI/AAAAAAAAGL0/mXoTVDBdIRg5isQ-XwDr8M_NaDwjfPFrACLcBGAsYHQ/w640-h294/ps-5.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>4. <b>ps -f </b>gives you the full ps process information which includes the user id and the parent process id</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-OXJ_kV26HfQ/YL8fk8qmUII/AAAAAAAAGL8/nnvF4VkD42Q3YI0AoJIaAK90YHZSrczlACLcBGAsYHQ/s505/ps-6.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="89" data-original-width="505" height="112" src="https://1.bp.blogspot.com/-OXJ_kV26HfQ/YL8fk8qmUII/AAAAAAAAGL8/nnvF4VkD42Q3YI0AoJIaAK90YHZSrczlACLcBGAsYHQ/w640-h112/ps-6.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><b>ps -F</b> gives you even more information about the process, it gives you the size and RSS (memory size) of the process</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-bN3MJXlovIc/YL8gOcnXeHI/AAAAAAAAGME/A5MU8stMu7oPlpRid1pEy9WZTqwhtSZUgCLcBGAsYHQ/s658/ps-7.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="83" data-original-width="658" height="80" src="https://1.bp.blogspot.com/-bN3MJXlovIc/YL8gOcnXeHI/AAAAAAAAGME/A5MU8stMu7oPlpRid1pEy9WZTqwhtSZUgCLcBGAsYHQ/w640-h80/ps-7.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p>5. <b>ps -l</b> shows you the long listing, which shows you different kinds of information like the UID (number) and the process priority</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-6dd1DGdXlcI/YL8hAsqLRiI/AAAAAAAAGMM/Yr4_VXYO2IIkX0DGh7IGmEZRuHJXj27kQCLcBGAsYHQ/s645/ps-8.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="111" data-original-width="645" height="110" src="https://1.bp.blogspot.com/-6dd1DGdXlcI/YL8hAsqLRiI/AAAAAAAAGMM/Yr4_VXYO2IIkX0DGh7IGmEZRuHJXj27kQCLcBGAsYHQ/w640-h110/ps-8.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p>6. You can combine options with commands like <b>ps -elf </b>which will give you the full ad long listing</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-YhFFfHdes2w/YL8hxcpC4QI/AAAAAAAAGMU/EG7UwFuoKqcvqviPReSwUmgA7GwQExQgwCLcBGAsYHQ/s820/ps-9.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="285" data-original-width="820" height="222" src="https://1.bp.blogspot.com/-YhFFfHdes2w/YL8hxcpC4QI/AAAAAAAAGMU/EG7UwFuoKqcvqviPReSwUmgA7GwQExQgwCLcBGAsYHQ/w640-h222/ps-9.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>7. As with other commands, you can search for a process when you combine it with the grep command. Let's say we want to search for all the gnome processes we can type the following <b>ps -elf | grep gnome</b></p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-9SAiwfb-LEk/YL8iyGkm0ZI/AAAAAAAAGMc/n_Rr4mdM1B0rBFmjIcbLCHuUOYVXlfMhQCLcBGAsYHQ/s895/ps-10.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="149" data-original-width="895" height="106" src="https://1.bp.blogspot.com/-9SAiwfb-LEk/YL8iyGkm0ZI/AAAAAAAAGMc/n_Rr4mdM1B0rBFmjIcbLCHuUOYVXlfMhQCLcBGAsYHQ/w640-h106/ps-10.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p>8. <b>ps -ly</b> will replace the address column with the resident size (memory size)</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-jcXf5ZBDn40/YL8jig7CihI/AAAAAAAAGMk/MhTqciCPZzgM72uuEl4OySuy-nz9BAcVwCLcBGAsYHQ/s656/ps-11.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="107" data-original-width="656" height="104" src="https://1.bp.blogspot.com/-jcXf5ZBDn40/YL8jig7CihI/AAAAAAAAGMk/MhTqciCPZzgM72uuEl4OySuy-nz9BAcVwCLcBGAsYHQ/w640-h104/ps-11.png" width="640" /></a></div><br /><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com1tag:blogger.com,1999:blog-1830041839784954098.post-91941062321779589742022-02-21T08:00:00.002-05:002022-02-21T08:00:00.186-05:00Linux System Administration GRUB2: Custom GRUB2 Entrie<p> GRUB2 is a wonderful tool, and one of the cool thing you can do is create a custom entry on the boot menu. Let's say you built a system especially for HR and it's different than the rest of the organization's system. Well with GRUB2 you can create an entry for the HR system as one of the choices in the boot menu.</p><p>Here are the steps to create a custom entry in GRUB2:</p><p>1. The first thing we want to do is create a custom file in our root home directory with the following contents. Log in as root and make sure you are at the root home directory and type vi custom your linux16 entry might be different so make sure you have the right path in production. In this post we are more concerned about making it show up in the boot menu</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div>menuentry <span style="color: #ce9178;">'HR Department'</span> {</div><div> insmod gzio</div><div> insmod part_msdos</div><div> insmod xfs</div><div> <span style="color: #dcdcaa;">set</span> root=<span style="color: #ce9178;">'hd0,msdos1'</span></div><div> linux16 /vmlinuz-3.10.0-327.3.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap </div><div> initrd16 /initramfs-3.10.0-327.3.1.el7.x86_64.img</div><div>}</div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/--vu8R4Nlirs/YL51d1e5trI/AAAAAAAAGK0/SPjqWa83raIgsXRjm1XwmZEJaTtHNtQhQCLcBGAsYHQ/s667/custom.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="219" data-original-width="667" height="210" src="https://1.bp.blogspot.com/--vu8R4Nlirs/YL51d1e5trI/AAAAAAAAGK0/SPjqWa83raIgsXRjm1XwmZEJaTtHNtQhQCLcBGAsYHQ/w640-h210/custom.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>2. To make it show up in the boot menu we want to edit the 40_custom file in the /etc/grub.d/ directory. So type vi /etc/grub.d/40_custom in the terminal. Now you want to go to the end of the file and append the custom file to the end of it. The way you can do that in vi is type esc then type :r /root/custom and press ENTER</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-4EwYAOA8tm8/YL561_ZNY_I/AAAAAAAAGK8/aPx2WbcDYtkh_q2kUbQmOYBNcpc1DH4LwCLcBGAsYHQ/s804/custom-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="251" data-original-width="804" height="200" src="https://1.bp.blogspot.com/-4EwYAOA8tm8/YL561_ZNY_I/AAAAAAAAGK8/aPx2WbcDYtkh_q2kUbQmOYBNcpc1DH4LwCLcBGAsYHQ/w640-h200/custom-2.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>The completed file should look something like this</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div><span style="color: #6a9955;">#!/bin/sh</span></div><div><span style="color: #dcdcaa;">exec</span> tail -n +3 <span style="color: #9cdcfe;">$0</span></div><div><span style="color: #6a9955;"># This file provides an easy way to add custom menu entries. Simply type the</span></div><div><span style="color: #6a9955;"># menu entries you want to add after this comment. Be careful not to change</span></div><div><span style="color: #6a9955;"># the 'exec tail' line above.</span></div><br /><div>menuentry <span style="color: #ce9178;">'HR Department'</span> {</div><div> insmod gzio</div><div> insmod part_msdos</div><div> insmod xfs</div><div> <span style="color: #dcdcaa;">set</span> root=<span style="color: #ce9178;">'hd0,msdos1'</span></div><div> linux16 /vmlinuz-3.10.0-327.3.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap </div><div> initrd16 /initramfs-3.10.0-327.3.1.el7.x86_64.img</div><div>}</div><br /></div><p>Type esc, :x to save the file</p><p>3. Now regenerate the grub.cfg file with the following command grub2-mkconfig -o /boot/grub2/grub.cfg</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-68tP3U1ukB4/YL57-7Si9qI/AAAAAAAAGLE/vpvnc6rAing-nM_-SyiE2IFVuHO2tZNtACLcBGAsYHQ/s776/custom-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="183" data-original-width="776" height="150" src="https://1.bp.blogspot.com/-68tP3U1ukB4/YL57-7Si9qI/AAAAAAAAGLE/vpvnc6rAing-nM_-SyiE2IFVuHO2tZNtACLcBGAsYHQ/w640-h150/custom-3.png" width="640" /></a><a href="https://1.bp.blogspot.com/-68tP3U1ukB4/YL57-7Si9qI/AAAAAAAAGLE/vpvnc6rAing-nM_-SyiE2IFVuHO2tZNtACLcBGAsYHQ/s776/custom-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div><div class="separator" style="clear: both; text-align: left;">Now if you reboot the machine you will see the custom entry in the boot menu</div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-AanBPnORC8U/YL580KDzNeI/AAAAAAAAGLM/23iYa859bToDowcZQVUqm5YSNIOxKHOFwCLcBGAsYHQ/s607/custom-4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="139" data-original-width="607" height="146" src="https://1.bp.blogspot.com/-AanBPnORC8U/YL580KDzNeI/AAAAAAAAGLM/23iYa859bToDowcZQVUqm5YSNIOxKHOFwCLcBGAsYHQ/w640-h146/custom-4.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: left;"><br /></div><p><br /></p><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com4tag:blogger.com,1999:blog-1830041839784954098.post-62130969471327842352022-02-14T08:06:00.013-05:002022-02-14T08:06:00.203-05:00Linux System Administration GRUB2: Password Protect GRUB2<p> From the past few posts you can see that GRUB2 is a very powerful utility in Linux. It's so powerful that you can create and change the root password. One way to prevent unauthorized access to this feature is to password protect it and encrypt the password as well.</p><p>Here are the steps to password protect GRUB2:</p><p>1. Make a copy of the file <b>/etc/grub.d/01_users</b> with the command <b>cp /etc/grub.d/01_users . </b>in the terminal</p><p>2. Go into the grub.d directory with the command cd /etc/grub.d</p><p>3. Now you want to edit the 01_users file with the command vi 01_users</p><div class="separator" style="clear: both; text-align: center;" wfd-id="22"><a href="https://1.bp.blogspot.com/-WJAva-mxY8s/YL38DxpyoyI/AAAAAAAAGKE/yLDNznerWBAYBElkv0GiIKBp623QEv-1QCLcBGAsYHQ/s444/password.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="80" data-original-width="444" height="73" src="https://1.bp.blogspot.com/-WJAva-mxY8s/YL38DxpyoyI/AAAAAAAAGKE/yLDNznerWBAYBElkv0GiIKBp623QEv-1QCLcBGAsYHQ/w400-h73/password.png" width="400" /></a></div><br /><p><br /></p><p><br /></p><p>4. The file should look something like this, by looking at the file you can see that it's currently using the root encrypted root password for authentication. What we want to do is use a user that's not in the system to control access to GRUB2.</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="10"><div wfd-id="21"><span style="color: #6a9955;">#!/bin/sh -e</span></div><div wfd-id="20">cat <<<span style="color: #ce9178;"> </span><span style="color: #c586c0;">EOF</span></div><div wfd-id="19"><span style="color: #ce9178;">if [ -f \${prefix}/user.cfg ]; then</span></div><div wfd-id="18"><span style="color: #ce9178;"> source \${prefix}/user.cfg</span></div><div wfd-id="17"><span style="color: #ce9178;"> if [ -n "\${GRUB2_PASSWORD}" ]; then</span></div><div wfd-id="16"><span style="color: #ce9178;"> set superusers="root"</span></div><div wfd-id="15"><span style="color: #ce9178;"> export superusers</span></div><div wfd-id="14"><span style="color: #ce9178;"> password_pbkdf2 root \${GRUB2_PASSWORD}</span></div><div wfd-id="13"><span style="color: #ce9178;"> fi</span></div><div wfd-id="12"><span style="color: #ce9178;">fi</span></div><div wfd-id="11"><span style="color: #c586c0;">EOF</span></div></div><p>Here is what the file will look like with the new user</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;" wfd-id="4"><div wfd-id="9"><span style="color: #6a9955;">#!/bin/sh -e</span></div><div wfd-id="8">cat <<<span style="color: #ce9178;"> </span><span style="color: #c586c0;">EOF</span></div><div wfd-id="7"><span style="color: #ce9178;"> set superusers="johndoe"</span></div><div wfd-id="6"><span style="color: #ce9178;"> password johndoe Topsecret1!</span></div><div wfd-id="5"><span style="color: #c586c0;">EOF</span></div></div><p>Save the file with esc then :x enter</p><p>5. The next step is we have to regenerate our configuration file with this command grub2-mkconfig -o /boot/grub2/grub.cfg</p><p>If you get this error message </p><p>/etc/default/grub: line 7: unexpected EOF while looking for matching `"'</p><div wfd-id="3">that means your /etc/default/grub file is missing a double quote, this might be a bug in the Linux OS, some people don't seem to have this issue. So the solution is to edit the file and add a quote to the second to last line</div><div wfd-id="2"><br /></div><div class="separator" style="clear: both; text-align: center;" wfd-id="1"><a href="https://1.bp.blogspot.com/-jMvEI9RU5aY/YL4LtaBHnQI/AAAAAAAAGKM/QR3MYUN3v28LKguyGRrS5c06eGVznPXeQCLcBGAsYHQ/s1004/password-2.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="1004" height="341" src="https://1.bp.blogspot.com/-jMvEI9RU5aY/YL4LtaBHnQI/AAAAAAAAGKM/QR3MYUN3v28LKguyGRrS5c06eGVznPXeQCLcBGAsYHQ/w640-h341/password-2.png" width="640" /></a></div><br /><div wfd-id="0"><br /></div><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>6. Now if you press e at the GRUB menu you will be prompted a username and password, you can authenticate by typing in the username and password you just specified</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-D01v-AlhsS0/YL5DScxkEZI/AAAAAAAAGKU/7vUV2pAeh9MZNEqCEFjL_ocTgxPvoI3wwCLcBGAsYHQ/s165/password-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="76" data-original-width="165" src="https://1.bp.blogspot.com/-D01v-AlhsS0/YL5DScxkEZI/AAAAAAAAGKU/7vUV2pAeh9MZNEqCEFjL_ocTgxPvoI3wwCLcBGAsYHQ/s0/password-3.png" /></a></div><br /><p><br /></p><p><br /></p><p>After typing in the username you will have access to functions for system administrations, just type Ctrl+x to go through the normal boot process</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-xANGs8zvfVA/YL5EITljTJI/AAAAAAAAGKc/DBfSgOitnKcLbrn9HCumC_PgkIAnczeLACLcBGAsYHQ/s720/password-4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="400" data-original-width="720" height="357" src="https://1.bp.blogspot.com/-xANGs8zvfVA/YL5EITljTJI/AAAAAAAAGKc/DBfSgOitnKcLbrn9HCumC_PgkIAnczeLACLcBGAsYHQ/w640-h357/password-4.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>7. That's great and all but the password is stored in clear text and a someone can just look at the file to figure out what the password is. To encrypt the password type in the command grub2-mkpasswd-pbkdf2 to get the encrypted password. Copy the encrypted password into the clipboard</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-L1wjHA3MvqQ/YL5F_D6zO7I/AAAAAAAAGKk/fMpVgVlAKbUVBq9pR_vnLaE4R3eU_hsXQCLcBGAsYHQ/s945/password-5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="161" data-original-width="945" height="110" src="https://1.bp.blogspot.com/-L1wjHA3MvqQ/YL5F_D6zO7I/AAAAAAAAGKk/fMpVgVlAKbUVBq9pR_vnLaE4R3eU_hsXQCLcBGAsYHQ/w640-h110/password-5.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p>8. Go into the grub.d folder with the command cd /etc/grub.d/ and edit the 01_users command again to change the password to an encrypted password, the file should look like this</p><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 16px; line-height: 22px; white-space: pre;"><div><span style="color: #6a9955;">#!/bin/sh -e</span></div><div>cat <<<span style="color: #ce9178;"> </span><span style="color: #c586c0;">EOF</span></div><div><span style="color: #ce9178;"> set superusers="johndoe"</span></div><div><span style="color: #ce9178;"> password_pbkbf2 johndoe grub.pbkdf2.sha512.10000.D923C3338B8C00DEA2546724EF33CD91B37DB0B52502148B387ACDFDA2A3628777A8D68ADD009044E6A590E59EECEE5B243D594EC11ED25EF502227EBA425FDC.CEB89F60CE9826B57A116B7049CB2F9C359BF0793B9AB210E75E394A503EFAB8C9C56EF4C2CF7BB7A55E267C938D578AED9D26ABEC3677E92EE4203128558BE4</span></div><div><span style="color: #c586c0;">EOF</span></div></div><p>Obviously your encryption string will be different depending on your password, save the file by typing esc, :x.</p><p>9. Regenerate the grub.cfg file with the command grub2-mkconfig -o /boot/grub2/grub.cfg</p><p>10. Now when you are confronted with the password prompt at the GRUB menu you can type in the password as you were before but now it's encrypted</p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com3tag:blogger.com,1999:blog-1830041839784954098.post-53989545365307349312022-02-07T11:32:00.001-05:002022-02-07T11:32:00.209-05:00Linux System Administration: Working With grubby<p> Having to change our grub menus with a text editor every time we want to make a change and be cumbersome and error prone. Luckily there's a tool that we can use to work with grub called grubby. In this post we are going to go over some of the useful commands that comes with grubby.</p><p>The first command we are going to look at is the grubby --default-kernel as you may have guess this will display the current default kernel</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-BLYKUHdLmSQ/YLJg0pO99CI/AAAAAAAAGJU/Sg2GkfCydkAJtQz9wIUrMhRCdzHQpF53ACLcBGAsYHQ/s411/grubby.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="33" data-original-width="411" height="32" src="https://1.bp.blogspot.com/-BLYKUHdLmSQ/YLJg0pO99CI/AAAAAAAAGJU/Sg2GkfCydkAJtQz9wIUrMhRCdzHQpF53ACLcBGAsYHQ/w400-h32/grubby.png" width="400" /></a></div><br /><p><br /></p><p>In addition to showing the default kernel we could set the default kernel with the command --set-default kernel command, with this command though you need to know the exact path to the kernel. Let's set the default kernel to be the second choice. To do that we want to see all the choices first, to list all the kernels we type the command grubby --info=ALL</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-qJCAbvT8o6E/YLJjCc8KaoI/AAAAAAAAGJc/PfSKpLvt7W8AiZ-K179KNqMvidB7abABQCLcBGAsYHQ/s754/grubb-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="415" data-original-width="754" height="352" src="https://1.bp.blogspot.com/-qJCAbvT8o6E/YLJjCc8KaoI/AAAAAAAAGJc/PfSKpLvt7W8AiZ-K179KNqMvidB7abABQCLcBGAsYHQ/w640-h352/grubb-2.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>From the command we see that the second choice is kernel=/boot/vmlinuz-3.10.0-1160.el7.x86_64</p><p>Now we can set the default kernel to be the second choice by typing gubby --set-default /boot/vmlinuz-3.10.0-1160.el7.x86_64</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-9VslGjeV56s/YLJkglahoUI/AAAAAAAAGJk/j0AQILHRnRcb9A0_2aQ3WPaqr-yrsNzvgCLcBGAsYHQ/s733/grubby-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="56" data-original-width="733" height="48" src="https://1.bp.blogspot.com/-9VslGjeV56s/YLJkglahoUI/AAAAAAAAGJk/j0AQILHRnRcb9A0_2aQ3WPaqr-yrsNzvgCLcBGAsYHQ/w640-h48/grubby-3.png" width="640" /></a></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div>Now if you reboot you will see that the second choice is selected in the boot menu instead of the first choice<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-xPtzEiJBzTU/YLJpOofulGI/AAAAAAAAGJs/Le4YJ9-y-AYGRdTV1gxdUx1UOIjbRImzwCLcBGAsYHQ/s548/grubby-4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="115" data-original-width="548" height="84" src="https://1.bp.blogspot.com/-xPtzEiJBzTU/YLJpOofulGI/AAAAAAAAGJs/Le4YJ9-y-AYGRdTV1gxdUx1UOIjbRImzwCLcBGAsYHQ/w400-h84/grubby-4.png" width="400" /></a></div><br /><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div>Set the default kernel to the first choice again.</div><div><div><br /></div><div>grubby --set-default /boot/vmlinuz-3.10.0-1160.25.1.el7.x86_64</div></div><div><br /></div><div>Another useful use of grubby is the ability to add and remove arguments so let's we want to add the arguments rhgb and quiet to the default boot option we can just type grubby --args="rhgb quiet" --update-kernel /boot/vmlinuz-3.10.0-1160.25.1.el7.x86_64</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-jrHIJ0Tm_4o/YLJw3oUtrJI/AAAAAAAAGJ0/ADZ8863mA3gXvMwptz_tRLbL0PeOkc-RACLcBGAsYHQ/s1012/grubby-5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="215" data-original-width="1012" height="136" src="https://1.bp.blogspot.com/-jrHIJ0Tm_4o/YLJw3oUtrJI/AAAAAAAAGJ0/ADZ8863mA3gXvMwptz_tRLbL0PeOkc-RACLcBGAsYHQ/w640-h136/grubby-5.png" width="640" /></a></div><br /><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div>To remove the argument just add the --remove to the args command like so grubby --remove-args="rhgb quiet" --update-kernel /boot/vmlinuz-3.10.0-1160.25.1.el7.x86_64</div><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-wJp_CLgqjPw/YLJxweyVotI/AAAAAAAAGJ8/GJPAMz6N3nEEsKi9RGvVYwbE53J8a7c3ACLcBGAsYHQ/s863/grubby-6.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="160" data-original-width="863" height="118" src="https://1.bp.blogspot.com/-wJp_CLgqjPw/YLJxweyVotI/AAAAAAAAGJ8/GJPAMz6N3nEEsKi9RGvVYwbE53J8a7c3ACLcBGAsYHQ/w640-h118/grubby-6.png" width="640" /></a></div><br /><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /></div><div><br /><div><br /><p><br /></p><div><br /></div></div></div>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com0tag:blogger.com,1999:blog-1830041839784954098.post-68264172176216478932022-01-31T10:45:00.003-05:002022-01-31T10:45:00.204-05:00Linux System Administration: Installing And Working With Grub Defaults<p> There are times when you need to reinstall GRUB which is the tool to manage Linux boot system. It could be corrupted and such. It's also important to know the defaults that you have to work with once it's installed. In this post we are going to go through the steps to do both.</p><p>Here are the steps to install GRUB.</p><p>1. Log in and open a terminal session as root</p><p>2. There's two ways install GRUB that first is to install it locally by typing grub2-install /dev/sda and the second way is to use the yum package manager to install. Type yum reinstall grub2-efi shim notice we are using the reinstall option for the yum command because grub should already be in the system we are just reinstalling because something is wrong with it</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-okWufbQe8-k/YLJWHC5i4DI/AAAAAAAAGI0/7SsCZK5Klsoxz2royHuPkZsoGRIJDIrNgCLcBGAsYHQ/s667/grub-install.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="517" data-original-width="667" height="496" src="https://1.bp.blogspot.com/-okWufbQe8-k/YLJWHC5i4DI/AAAAAAAAGI0/7SsCZK5Klsoxz2royHuPkZsoGRIJDIrNgCLcBGAsYHQ/w640-h496/grub-install.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>2. Once you have GRUB installed you can work with the defaults by using a text editor to edit the /etc/default/grub configuration file. So type vi /etc/default/grub to edit the grub default.</p><p>We are going to change the countdown to 10 seconds instead of 5 and set the GRUB_DISABLE_RECOVERY="true" to get rid of the recovery options in the boot menu, esc :x to save the changes</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-fGDsQqUiP5E/YLJYPG4bLMI/AAAAAAAAGI8/eMgEytukRDchXsu_5WJXhlRNYQPPmHjaACLcBGAsYHQ/s302/grub-install-2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="137" data-original-width="302" src="https://1.bp.blogspot.com/-fGDsQqUiP5E/YLJYPG4bLMI/AAAAAAAAGI8/eMgEytukRDchXsu_5WJXhlRNYQPPmHjaACLcBGAsYHQ/s0/grub-install-2.png" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>3. Once the changes have been made to the file you have to run the command grub2-mkconfig -o /boot/grub2/grub.cfg to regenerate the grub configuration file</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-qRLy2vC9HCI/YLJZpZdxwFI/AAAAAAAAGJE/hquhtuQ0P78YQsapSiTvf0KeCdP5pqg7wCLcBGAsYHQ/s1046/grub-install-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="324" data-original-width="1046" height="198" src="https://1.bp.blogspot.com/-qRLy2vC9HCI/YLJZpZdxwFI/AAAAAAAAGJE/hquhtuQ0P78YQsapSiTvf0KeCdP5pqg7wCLcBGAsYHQ/w640-h198/grub-install-3.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>4. Now if you reboot you should not see the recovery options anymore in the boot menu and the countdown will be 10 seconds instead of 5</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-xYD5f5F7pGg/YLJaMPRzVDI/AAAAAAAAGJM/Dnsq6scTFN4pFlIH9d_T8JJBxSTGyL6ygCLcBGAsYHQ/s720/grub-install-4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="101" data-original-width="720" height="90" src="https://1.bp.blogspot.com/-xYD5f5F7pGg/YLJaMPRzVDI/AAAAAAAAGJM/Dnsq6scTFN4pFlIH9d_T8JJBxSTGyL6ygCLcBGAsYHQ/w640-h90/grub-install-4.png" width="640" /></a></div><br /><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com3tag:blogger.com,1999:blog-1830041839784954098.post-80016601469643900632022-01-24T09:23:00.001-05:002022-01-24T09:23:00.184-05:00Linux System Administration: Adding Recovery Mode To Grub Menu<p> On normal startup of the Linux system you probably see this menu every time you boot up</p><div class="separator" style="clear: both; text-align: center;" wfd-id="2"><a href="https://1.bp.blogspot.com/-XqtpVSYBP10/YLCy56tfINI/AAAAAAAAGHU/fCCvluqvL2UgGvLgZtJx8pag6p4_U2ryQCLcBGAsYHQ/s720/recovery.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="400" data-original-width="720" height="356" src="https://1.bp.blogspot.com/-XqtpVSYBP10/YLCy56tfINI/AAAAAAAAGHU/fCCvluqvL2UgGvLgZtJx8pag6p4_U2ryQCLcBGAsYHQ/w640-h356/recovery.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>In this post we are going to add a recovery mode for each of these choices.</p><p>Here are the steps to create recovery mode options in the GRUB menu:</p><p>1. Log into the system normally</p><p>2. Open a terminal session, switch to root privilege or root user</p><p>3. Type <b>vi /etc/default/grub </b>to edit the grub file</p><p>4. Once you are in the grub file find the line that says <b>GRUB_DISABLE_RECOVERY="true"</b> and change it to <b>GRUB_DISABLE_RECOVERY="false"</b> then press esc then type :wq!</p><div class="separator" style="clear: both; text-align: center;" wfd-id="1"><a href="https://1.bp.blogspot.com/-fYYVC5mz0ss/YLC2EUmG5fI/AAAAAAAAGHc/oh88rO_CNHsUDYPe4iF6l-etmE4uEsozQCLcBGAsYHQ/s601/recovery-2.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="212" data-original-width="601" height="226" src="https://1.bp.blogspot.com/-fYYVC5mz0ss/YLC2EUmG5fI/AAAAAAAAGHc/oh88rO_CNHsUDYPe4iF6l-etmE4uEsozQCLcBGAsYHQ/w640-h226/recovery-2.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>5. When you get your command prompt back type grub2-mkconfig -o /boot/grub2/grub.cfg to regenerate the grub file</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-fE5V7XWVNZ0/YLJBz3h-7-I/AAAAAAAAGIk/cZfuwj0yv_M3e8ZCgkcWbvJQeQAgN4ehQCLcBGAsYHQ/s772/recovery-4.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="156" data-original-width="772" height="130" src="https://1.bp.blogspot.com/-fE5V7XWVNZ0/YLJBz3h-7-I/AAAAAAAAGIk/cZfuwj0yv_M3e8ZCgkcWbvJQeQAgN4ehQCLcBGAsYHQ/w640-h130/recovery-4.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;" wfd-id="0"><br /></div><p>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</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-mZ_ToIE7RlI/YLJCKFvOKkI/AAAAAAAAGIs/vpkjFrAlRGY6TH3JeXRU7NYBxios29qWACLcBGAsYHQ/s720/recovery-5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="400" data-original-width="720" height="356" src="https://1.bp.blogspot.com/-mZ_ToIE7RlI/YLJCKFvOKkI/AAAAAAAAGIs/vpkjFrAlRGY6TH3JeXRU7NYBxios29qWACLcBGAsYHQ/w640-h356/recovery-5.png" width="640" /></a></div><br /><p><br /></p><p><br /></p>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com26tag:blogger.com,1999:blog-1830041839784954098.post-62371495670248156172022-01-17T08:00:00.014-05:002022-01-17T08:00:00.186-05:00Linux Administration: Reset Lost Root Password<p> 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.</p><p>Here are the steps to reset the root password on your Linux system:</p><p>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.</p><div class="separator" style="clear: both; text-align: center;" wfd-id="28"><a href="https://1.bp.blogspot.com/-ZyIframztV8/YLICftn1CoI/AAAAAAAAGH0/X3D2k0VyB1wyB8JZ0XAxiMBpFXWy9amYgCLcBGAsYHQ/s435/password.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="120" data-original-width="435" height="176" src="https://1.bp.blogspot.com/-ZyIframztV8/YLICftn1CoI/AAAAAAAAGH0/X3D2k0VyB1wyB8JZ0XAxiMBpFXWy9amYgCLcBGAsYHQ/w640-h176/password.png" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;" wfd-id="27"><br /></div><p>2. Go to the line where you see rhgb and quiet then remove the options from the line</p><div class="separator" style="clear: both; text-align: center;" wfd-id="26"><a href="https://1.bp.blogspot.com/-KRIYDtkNHnQ/YLICrmy_xFI/AAAAAAAAGH4/IC5FLoNL_iszjt6INfUuHdxVTQNICrRzQCLcBGAsYHQ/s724/password-2.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="134" data-original-width="724" height="118" src="https://1.bp.blogspot.com/-KRIYDtkNHnQ/YLICrmy_xFI/AAAAAAAAGH4/IC5FLoNL_iszjt6INfUuHdxVTQNICrRzQCLcBGAsYHQ/w640-h118/password-2.png" width="640" /></a></div><div wfd-id="25"><br /></div><div wfd-id="24"><br /></div><div wfd-id="23"><br /></div><div wfd-id="22"><br /></div><div wfd-id="21"><br /></div><div wfd-id="20"><br /></div><div wfd-id="19"><br /></div><div wfd-id="18"><br /></div>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.<div class="separator" style="clear: both; text-align: center;" wfd-id="17"><a href="https://1.bp.blogspot.com/-YJK7qXkEySI/YLIDzta23pI/AAAAAAAAGIE/DgCGh_ZcdZEi6Y1YwRekajcsW-C4thj3QCLcBGAsYHQ/s709/password-3.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="142" data-original-width="709" height="128" src="https://1.bp.blogspot.com/-YJK7qXkEySI/YLIDzta23pI/AAAAAAAAGIE/DgCGh_ZcdZEi6Y1YwRekajcsW-C4thj3QCLcBGAsYHQ/w640-h128/password-3.png" width="640" /></a></div><br /><div wfd-id="3"><br /><p><br /></p><p><br /></p><p><br /></p><p>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</p><div class="separator" style="clear: both; text-align: center;" wfd-id="16"><a href="https://1.bp.blogspot.com/-wl1UdLcWn6E/YLIFEhDsvwI/AAAAAAAAGIM/QkOKgtt26U8dDO30Bzay80CiP3c5P33hQCLcBGAsYHQ/s524/password-4.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="168" data-original-width="524" height="206" src="https://1.bp.blogspot.com/-wl1UdLcWn6E/YLIFEhDsvwI/AAAAAAAAGIM/QkOKgtt26U8dDO30Bzay80CiP3c5P33hQCLcBGAsYHQ/w640-h206/password-4.png" width="640" /></a></div><div wfd-id="15"><br /></div><div wfd-id="14"><br /></div><div wfd-id="13"><br /></div><div wfd-id="12"><br /></div><div wfd-id="11"><br /></div><div wfd-id="10"><br /></div><div wfd-id="9"><br /></div><div wfd-id="8"><br /></div><div wfd-id="7"><br /></div><div wfd-id="6"><br /></div><div wfd-id="5"><br /></div><div wfd-id="4"><br /></div>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</div><div wfd-id="2">6. You accomplish this by typing <b>mount -o remount,rw sysroot</b></div><div wfd-id="0"><b>7. </b>Now we want to set a false root call chroot and point it to the root filesystem with the command chroot /sysroot<br /><p>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</p><div class="separator" style="clear: both; text-align: center;" wfd-id="1"><a href="https://1.bp.blogspot.com/-vdGiW7jg9EI/YLIHtfxjfCI/AAAAAAAAGIU/lPJ5tz96OJQNuc23QRAaEMrlbkVx3D0sACLcBGAsYHQ/s464/password-5.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="113" data-original-width="464" height="156" src="https://1.bp.blogspot.com/-vdGiW7jg9EI/YLIHtfxjfCI/AAAAAAAAGIU/lPJ5tz96OJQNuc23QRAaEMrlbkVx3D0sACLcBGAsYHQ/w640-h156/password-5.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p>9. Now it's very important that we set everything back to normal, so type exit to get out and type </p><p>mount -o remoumt,ro /sysroot</p><p>to set the root filesystem back to read only, type exit to continue with the boot process</p><p>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</p><p>11. Before we even do that we want to reinforce security if you have it enabled before by typing the following commands</p><p>restorecon /etc/shadow</p><p>setenforce 1</p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-2X3VRssAFsM/YLIOlWdWIRI/AAAAAAAAGIc/l_A9au3SFVYvVBqbfS-bNs_nH6oMq-iFgCLcBGAsYHQ/s427/password-8.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="36" data-original-width="427" height="54" src="https://1.bp.blogspot.com/-2X3VRssAFsM/YLIOlWdWIRI/AAAAAAAAGIc/l_A9au3SFVYvVBqbfS-bNs_nH6oMq-iFgCLcBGAsYHQ/w640-h54/password-8.png" width="640" /></a></div><br /><p><br /></p><p><br /></p><p><br /></p></div>Jason Huynhhttp://www.blogger.com/profile/06651747254494826114noreply@blogger.com0