Latest Posts
Monday, May 23, 2022
In this post we are going to go over the steps to install the Ssysstat tool in Linux. Log in as root or su then run the command yum install -y sysstat, you might already have it installed so you might get this message
Now that we know sysstat is installed we can start the service with the command systemctl start sysstat then enable it with the command systemctl enable sysstat and finally we can check to see the that service is running by checking the status with this command systemctl status sysstat
Monday, May 16, 2022
vmstat is used to report virtual memory stats on your Linux system. It is helpful to see how much free memory you have left on your system.
As with top you can run the command by typing vmstat, it defaults to kilobytes
You can change the default measure unit by specifying the unit like this vmstat -S m, this will run the command in millibytes, we can see that we have 372 MB of memory free and 1 MB of buffer
You can also run vmstat in intervals by typing the following command vmstat 3 5, the command tells vmstat to run every 3 seconds for five times
Monday, May 9, 2022
The top command is an essential tool in any Linux administrator's toolbelt. Let's take a deeper look at the command.
First thing you can do is get the version of top we are using
If you just type top with no options you will get the following information, the information will update every 3 seconds by default. The top area is a summary of resources and CPU usage while the bottom portion are information about the processes. The information is sort by CPU utilization by default.
Press q to quit, you can also run the top command in batch mode by specifying how many times you want it to run by typing the command like this top -b -n1 the command uses the -b option for batch and -n for the number of iterations, in this case it's one
As you can see it only runs once and you get your prompt back, you use your mouse to scroll back up. You can also write the results to a file like this top -b -n1 > top-stats
Monday, May 2, 2022
So to use the for/in loop to iterate through the object let's use our product object again.
var product = new Object();product.name = "Chai";product.category = "Tea";product.country = "India";product.supplier = {name: "ACME Tea Of India",location: "New Delhi"};
Now type in the following to loop through the object with the for/in loop and outputs the property name and property value to the console
Monday, April 25, 2022
Monday, April 18, 2022
In the previous post we created an EC2 instance in AWS in this post we are going to connect to that instance on a Linux workstation or server with SSH.
Here are the steps to connect to the EC2 instance using SSH on Linux, this will also work on a Mac as well:
1. Navigate to the folder that contains the key pair file that you've downloaded in the previous post, I store it in the folder /aws/EC2/KeyPair/ folder , so I would type cd /aws/EC2/KeyPair then type ls to see the file in the folder
Monday, April 11, 2022
In this post we are going to look at another performance related command, which is the uptime command.
First let's look at the uptime command, as the name implies the uptime command shows you what the uptime is for the system:
The command shows you the uptime for the system, the number of users who are using the system, and the system load average (Number of CPU used) in intervals of 5 minutes.
If you type w, you can see which users are using the system
The load average is the most important stat in the uptime command however, it is currently static, and to get updates you need to run the uptime every 5 minutes. There's a better way to monitor your Linux system. But you have to call now, and for a limited time only for just $19.99 you can have the answer. Since I am such a nice guy I am going to give you the answer for free.
What you can do is type the command tload and it will monitor the load average time in real-time. Before we run the tload command a good command to run is the lscpu command to see how many CPU you have. For instance you have just one CPU and your load average is 1+ then you have got a problem.
Now let's run the tload command
There are two parts to the tload utility, at the top you will see the average load time in real time instead of the 1, 5, 15 minute interval like before. But it will be dynamic and updates automatically based on the load.
On the bottom you will see a graphical representation of the load average, it's probably not going to win any awards for best graphics
Everything looks fine right now, but if you open another terminal and run the dnf update -y command you will see the load changing accordingly. Or some tasks that would put stress on the system.
Monday, April 4, 2022
In this post we are going to look at the procps-ng package commands to get some performance related information on our Linux system.
The first command we are going to look at is the free command, which shows the free memory available
We can use the free command with the -m option to show the free memory in megabytes
Or free -g for gigabytes
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
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
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
Monday, March 28, 2022
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?
So if we run the sleep process again let's see what happens by default
sleep 1500&
As you can see the priority(PRI) is set to 80 percent by default
Now let's be a nice guy and assign the sleep process to the nicest value -19
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.
If you run it at the highest nice value, not so nice. Let's see what happens
You can also reassign the priority of an existing process with renice command, with the renice command you have to specify the process id
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!
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.
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
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.
Monday, March 21, 2022
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.
First let's create a process, we are just create a sleep job in the background, with the command sleep 1500& the & 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.
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 CTRL+Z , but that would also stop the process or job from running. That's probably not what you wanted
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 bg command to run the job in the background
To bring the job into the foreground you just type fg
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 CTRL+Z again to interrupt the process
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 bg 2
You can do the same thing with the fg command. Kill the sleep process with the command pkill sleep for cleanup