How to kill a node server using its pid(process id) that is running in background

Often we run node servers in background. Like using screen or using a cron job that starts while booting. So how do we kill it when when its running in the background.

Well, one way is if it is running in a screen we can resume the screen and terminate it.

Or even better we can find the process id of the server you are running. For this we need to remember the port on which you are running the node server.

For example if the server you want to terminate is running on the port 3029, run the below command to get the process id of that process.

lsof -i:8044

In the above command 8044 can be any port number. When we run the command we get output like below

node 108597 nagaraju 20u IPv6 318585 0t0 TCP *:8044 (LISTEN)

Notice the PID. That is what we need to terminate the process.

Now we run the below command to kill/terminate that process.

kill -9 108597

Using kill command to terminate the process and then checking if the process is still running after terminating it

How to test PHP installation

To test a successful php installation. We can check the PHP version in your machine or test the entire PHP setup using following

open a file in which your web directory name it anything like php_test.php and write the following content.


Save the file and open the file in your browser like localhost/php_test.php.

Then you will notice that if php is installed the following image will be displayed.

PHP successful installation screenshot

There is a video tutorial that explains the same as above.

Fix ubuntu freezning or hard disk switching to read mode due to bad sector or file system error

This is one of the most common problems that one might encounter these days. This can be due to hardware of software.

If the issue is because of software we can fix it using below mentioned ways..

First print out the output of the command dmesg and see if there are any errors printed in red color which does symbolize that you have a file system error.

Note: sda5 means the disk that you want to check for errors. You can see the name of your disk by using the command df -h

Install smartctl a tool to check your hard disk for errors.

After installing smartctl run the following command.

smartctl -t long /dev/sda5

Then carefully see the output of above command it displays the time it will take to complete the test you have just started. To view the test run the below command.

smartctl -l selftest /dev/sda5

Now run below commands to check the health of your hard disk.

smartctl -a /dev/sda5
smartctl -H /dev/sda5

You can also add a line to your grub file located at /etc/default/grub or modify the line if it already exists.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash libata.force=noncq"

This will make sure that while rebooting you run a force check for errors in your file system. Be careful because you might need to back up your data as you may lose some of it.

Another way to go into recovery mode is to press ESC while rebooting and choose recovery mode. This will make sure to fix file system errors also you can choose to run fsck/resume normal boot in the options provided.

How to use the command CD in Linux Terminal – Ubuntu, Fedora, CentOS

The command CD stands for change directory. CD can be used in many ways to navigate between multiple directories just like we traverse in GUI.

cd <filename>

The above command will move to the directory specified in the angular brackets. But you have to make sure that the name given here is present in the current directory. You can see what are the folders/files in the current directory using the command LS. Also you can check your current working directory using the command PWD.

cd /path/to/another/folder

The above command will take to another folder that is far away from the current working directory. Make sure that the specified path exists. You can check the path of the current structure using the command TREE.

cd ..

The above command will move the current working directory to one level back.


The above command without any arguments will take you to the home directory no matter where your current working directory is.

There is a video example for the same, watch it below

Basics of vim – Create, edit, save and quit in vim.

How to use vim in Linux.

Vim has two modes. Command mode and insert mode. In command mode we can tell the editor to substitue, edit, insert, append, save, quit etc. By default vim opens in command mode. To switch to insert mode press “i” in command mode without quotes. Here you can edit the file with whatever content you want to.

To switch to command mode press “Esc” key. Here we can give commands to save and quit. To save press :w then the file will be saved and to save and quit press :wq.

Here is a video enplaning the same.

How to use “ls” command in Linux terminal

“ls” means list contents of a directory. We have various options with ls that can be used together to view files in a convenient way according to our requirement.

ls -a

ls with -a option shows all hidden files.

ls -l

ls with -l prints long listing format about each file. It consists of information like permissions(read/write/execute), owner, file size, file type(directory or file or symbolic link), last modified time and the name of the file.

ls -l can be used with another options like -t or/and -r. “-t” will sort files by modified time and “-r” reverses the order they are being sorted.

To view examples for above commands see the video below.

Spreadsheet highlight common cell values between two columns


Suppose we are having two columns in a spreadsheet and we are trying to find the common values between them. That is highlight column values if they are present in another column.

For example lets say we have some ids in two different columns. Both columns have some data in common and some data exclusive to each other. But our focus here is to highlight the values in second column if they are present in first column and vice-versa.

To do this we are going to use conditional formatting, as the name suggests it will format the cells based on a condition. Here we are going to specify our own condition.

Look at the image below

spreadsheet with two columns with values/ids

Here we want to highlight the values in column ‘D’ if they are present in column ‘A’.

So to do that, first select the column i.e column ‘D’ and then go to conditional formatting. Go to Format->Conditional -> Condition->Formula (choose from dropdown) in the input box enter the formula COUNTIF($A:$A, $D1) like in the image below.

conditional formatting applied on 3rd column

After you click ‘OK’ you can see that 2nd column values that are present in column 1 will be highlighted like below.

image showing values in 2nd column being highlighted

Now to do the reverse i.e to highlight values in first column from 3rd column we need to do apply similar formula COUNTIF($D:$D, $A1) on column ‘A’.

  1. You can remove conditional formatting rule that has been applied
  2. For this formulae to apply there should be common values between these columns.
  3. We can choose custom formatting like different color, size etc for conditional formatting.

You can also watch video to see how it is done in Google Spreadsheet

Excel Spreadsheet add value in cells/columns based on a condition from another cells/column

The function SUM in Excel is quite useful to add values in a column. But this one is not useful when we have to count the values based on a criteria that should satisfy in another column.

For Example we have a scenario where we have to count items cost that are delivered and undelivered and Grand Total. To get the Grand Total we can use sum function directly. But to count total price which are delivered and undelivered we have to use the sumif function. Look at below screenshots.

To calculate all items Total:

To calculate Items that are delivered:

To calculate Items that are undelivered

This is how it looks finally

Setting Reverse Proxy in Apache Ubuntu

Suppose we have a web app running on a port. For example nodejs runs server on a port. For accepting incoming connections on this port without actually exposing the port number is what we look for.

To solve this we can add few lines in our apache configuration to tell our web server to accept connections on a port.

Lets assume we are trying to access this url

Open the file /etc/apache2/sites-available/000-default.conf using any editor and paste the below lines. You may take a backup of the above file before doing so.

<VirtualHost *:80>
    ProxyPreserveHost On

    ProxyPass /mybankapp
    ProxyPassReverse /mybankapp

Before we restart apache we may enable some modules.

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests

After we execute above command now we may restart apache.

sudo systemctl restart apache2

Now we can access our web app without the port number.