Nmap useful commands

Look up which ip is used by which host

nmap -sn 192.168.1.0/24

How to resolve npm permission issue?

This is general solutions for all kind of npm permission issue.

sudo chown -R $USER ~/.npm
sudo chown -R  $USER /usr/bin/npm
sudo chown -R  $USER /usr/lib/node_modules/
chmod -R a+x node_modules

How to replace content in large file?

Many time developer just need to replace a bit of text inside the large file like *.sql or *.sqlite
Opening a file into editor take too much resource of system or server. So I come up with the very easy and useful way to replace content into large file using linux command like. sed command.

Here I am taking an example of MySql file which having *.sql as file extension

sed -i '' 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g'

Linux golden commands

Kill any process using port

USE THIS COMMAND ON YOUR OWN RISK !

sudo kill -9 $(sudo lsof -t -i:4200)

If you want to check that if process running than and than kill the process , use bellow one

if sudo lsof -t -i:4200; then sudo kill -9 $(sudo lsof -t -i:4200); fi

Above command will check that process is running than kill by process id.


Git useful commands

  • Store all your cred into system helper
git config --global credential.helper store
# Set the cache to timeout after 1 hour (setting is in seconds)
git config --global credential.helper 'cache --timeout=3600'

Sudo command with no password in linux!

How to avoid reputations of sudo command in linux.

Just follow bellow steps to avoid reputations.

Create file or edit if exist

sudo visudo -f /etc/sudoers.d/90-cloudimg-ubuntu

How to switch default php version in linux?

Problem :- How to switch default php version in linux ?

Platfom :- Linux

Solutions

Check which php versions are available with system

    sudo update-alternatives --config php

Geany tried to access the unix domain socket of another instance running as another user

Problem :- Geany tried to access the unix domain socket of another instance running as another user

Run bellow command which resolve your issue.

    sudo -H rm ~/.config/geany/geany_socket_*

Linux user permission right way

To solve linux user and group permission issue for any kind of project.

First of all find the right user and right group which is executing that process.

Silver bullet of linux user permission.

sudo lsof -iTCP -sTCP:LISTEN -Pn
export OWENRE=$(whoami)
export GROUP=$(whoami)

Nginx full configuration with best performance

NGINX Tuning For Best Performance

This post assume that you are linux user and logged as root user.

This post is written by margining many configuration files at once so you may find same configuration at nginx official websiteas well.

Nginx tune up are dived into two major part

  1. Nginx main configuration file called as nginx.conf
  2. Another one is called as virtual host file wich located in eather conf.d directory or sites-enable folder based on linux flavour.