Wednesday, February 9, 2022

How to install node using Brew

This article talks about some simple steps to follow to install node using Brew. Though there are many other ways to do it but the method described below uses nvm to install it and is one of the best method available till date.

Note: Before you proceed, ensure that Brew is installed. To install it follow the link above.

Step 1: Install NVM by running this command

brew install nvm

Step 2: Create a directory for NVM

mkdir ~/.nvm

Steps 3: Create an export in .zshrc to execute nvm command directly, add it to PATH and restart shell

export NVM_HOME="$HOME/.nvm"
    [ -s "$(brew --prefix)/opt/nvm/nvm.sh" ] && . "$(brew --prefix)/opt/nvm/nvm.sh" # This loads nvm
    [ -s "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" ] && . "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
export PATH=$NVM_HOME:$PATH

Step 4: Install node

Use this command for specific version

nvm install <version>

User this command to install the latest version

nvm install node

Step 5: Check the version of node installed

node -v
npm -v

Note: Whenever you install any version of node through nvm command it automatically makes it the default version.

Steps to change the version used by nvm

  1. List all versions which nvm has
    nvm list
  2. Change the version
    nvm use <version>

Thursday, December 2, 2021

Enable WiFi on a headless Raspberry Pi

Enabling WiFi on a headless Raspberry Pi is really simple. Here are the steps:
  1. Take out the SD card from Raspberry Pi and insert into a computer/laptop using a SD card reader in write mode.
  2. SD card will be named as "boot" on a drive on your computer.
  3. Open a text editor and create a file named "wpa_suppplicant.conf" on the root of "boot" or directly on the SD card.
  4. Add the below contents into the file and save it.
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="NETWORK-NAME"
    psk="NETWORK-PASSWORD"
}

Remember:

  • country should have a two character country code of your country.
  • ssid should be your Wifi Network Name in double quotes
  • psk should be the your Wifi Password in double quotes.
  • After saving the file check that the extension of the file is .conf and not .conf.txt. If so, then change it to .conf.
Now, eject the SD card and insert it in Raspberry Pi and it will automatically connect to the Wifi.


Thursday, October 21, 2021

How to enable SSH on Raspberry Pi in five super easy and quick steps

 Following are the easy steps to enable SSH on Raspberry PI without any complications:

Step 1: Shutdown Raspberry Pi

Step 2: Take out the memory card and plug it in any computer using the card reader.

Step 3: Open /boot partition of the card

Step 4: Create an empty file named "ssh" on the boot partition without any extension.

Step 5: Unmount memory card and insert into Raspberry Pi and start it.

That's it !!

To connect to the raspberry pi using SSH, just use this command

 ssh <user>@<IP address of Raspberry pi>

Saturday, August 21, 2021

How to enable Safemode for search engines on your home network using PiHole

If you are using Pi hole it is piece of cake to restrict any unsuitable content on your home network. In this blog, I will show how easy it is to restrict search engines search to Safe Content/Restricted Mode.

Following are the steps:

  • Open Pihole admin console on the browser by opening https://<IP>/admin/index.php.
  • Login into the console.
  • Go to Local DNS -> CNAME Records
  • Add server address for the search engine in Domain and its corresponding safe search server in Target Domain
  • Click on Add

  • You can see that the server and the corresponding safe search server is mapped in the list.
  • Similarly do for all the search engines you want to add.



Names of the search engine domains and their corresponding safe servers:

Google: 

Domain: www.google.com
Target Domain: forcesafesearch.google.com

Bing:

Domain: www.bing.com
Target Domain: strict.bing.com

DuckDuckGo:

Domain: www.duckduckgo.com
Target Domain: safe.duckduckgo.com

How to backup and restore Raspberry Pi MicroSD card on Mac and Windows

 

In order to take a backup following are the basic steps:

  1. Connect the Micro SD card.
  2. Create an Micro SD card image which will act as a backup image.
In order to restore a backup following are the basic steps:
  1. Connect the Micro SD card.
  2. Format the Micro SD card.
  3. Write the Micro SD card image on the Micro SD card.


On Windows


To take backup

  • Connect your Micro SD card

    • Ensure that your computer have an SD card slot.
    • Insert Micro SD card in the SD card adapter which comes with the Micro SD card.
    • Insert the SD card adapter in the SD card slot.
    • Check if Windows is able to detect the card. SD card will have a boot as name.

  • Install Win32 Disk Imager (One of best softwares to use for this purpose but feel free to use other software. Though the steps for other software will be similar.)


  • Open Win32 Disk Imager




  • Select the location for the file where back is required to be created and the file name by either selecting the folder icon (blue icon) or by typing the path. Ensure that the file name should end with .img.


  • Select the SD card from Device dropdown.



  • Click on "Read" button and relax as this is going to take some time to create the backup file.


To restore a backup

  • Connect SD card 


  • Format the SD card

  • Open Win32 Disk Imager


  • Select the file from which the backup is required to be restored.


  • Select the SD card from Device dropdown


  • Select Write and relax. This will take more time as compared to the time it took for backup.




On Mac


To take a backup

  • Connect the SD card. Note: the SD card will not be detected as a card to read the contents and you may see an error popup. Ignore the error popup.

  • Open the Terminal and run this command
$ diskutil list

This command will display all the connected storage devices

 


  • Identify the Name, Size and Volume of your SD card by looking at the output


  • Type this command to create a backup file for the SD card (ensure the file extension is .dmg)
$ sudo dd if=<Volume> of=<Location>/<filename>.dmg 
e.g. sudo dd if=/dev/disk1 of=~/Desktop/pi-backup.dmg


To restore a backup

  • Connect the SD card (Ensure that the card is a blank card or is pre-formatted)


  • List the disk volumes using the following command (refer output above)

$ diskutil list


  • Run the following command to restore the backup

$ sudo dd if=<Location of file>/<filename>.dmg of=<Volume>

e.g. sudo dd if=~/Desktop/pi-backup.dmg of=/dev/disk1


How to get rid of crazy "remote identification changed" error

 In your life if you ever used SSH to access a machine from two different computers or laptops then you might have encountered this error:

[user@hostname ~]$ ssh pi@bestpi.in.universe @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the RSA key sent by the remote host is 5e:45:f9:a8:af:38:3d:b1:a5:c3:76:1d:02:f5:77:00. Please contact your system administrator. Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message. Offending RSA key in /var/lib/sss/pubconf/known_hosts:4 RSA host key for pong has changed and you have requested strict checking. Host key verification failed.


You might be wondering what in the world did you do wrong. Well....nothing actually. How to get rid of this error (and remove yourself from guilt), just use this command on the terminal:

ssh-keygen -R <host>

for e.g. ssh-keygen -R 192.168.0.19

 

 

How to install node using Brew

This article talks about some simple steps to follow to install node using Brew . Though there are many other ways to do it but the method ...