Monday, September 26, 2022

How to change Folder and File Permission in Linux

sudo find /var/www/html -type d -exec chmod 755 {} \;

sudo find /var/www/html -type f -exec chmod 644 {} \;

sudo chmod 644 /var/www/html/textbook.php

sudo chmod 644 /var/www/html/textbook.php

sudo systemctl restart httpd

Wednesday, September 21, 2022

Debian/Ubuntu Linux Specific Commands to Start/Stop/Restart Apache Engine

Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older:
/etc/init.d/apache2 restart

sudo /etc/init.d/apache2 restart

sudo service apache2 restart

/etc/init.d/apache2 stop

sudo /etc/init.d/apache2 stop

sudo service apache2 stop

/etc/init.d/apache2 start

sudo /etc/init.d/apache2 start

sudo service apache2 start

Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04+ or above:

sudo systemctl start apache2.service

sudo systemctl stop apache2.service

sudo systemctl restart apache2.service

sudo systemctl status apache2.service

CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x:

## Start ##
service httpd start
## Stop ##
service httpd stop
## Restart ##
service httpd restart

CentOS/Fedora/RHEL (Red Hat) Linux version 7.x or newer:

## Start command ##
sudo systemctl start httpd.service
## Stop command ##
sudo systemctl stop httpd.service
## Restart command ##
sudo systemctl restart httpd.service

Alpine Linux:

service apache2 start
service apache2 stop
service apache2 status
service apache2 restart

Tuesday, September 20, 2022

Two-Factor Authentication (2FA) for Webmin with Google Authenticator

First install Perl Modules :

Then follow the instructions as given through the URL:

Install Perl CPAN Module in CentOS 8

dnf install perl-CPAN

dnf install "@Development Tools"

perl -MCPAN -e 'install Authen::OATH'

cpan -i Geo::IP OR 
cpan Geo::IP

cpan[1]> install Log::Log4perl


You need gcc.:
yum install gcc

yum install CPAN

Configure CPAN ( just run CPAN ):

After CPAN is configured:
install Authen::OATH [module in CPAN shell, which takes a long time to complete.]

When Authen::OATH is successfully installed, configure 2FA in WebMin.

Permission denied (publickey) fix

$ ls -laZ

$ restorecon -r -vv /home/user/.ssh

Monday, September 19, 2022

Friday, September 16, 2022

Installing PHP 7.4 on macOS Sierra without brew?

 sudo port install php74

sudo port install php74-cgi php74-gd php74-curl php74-intl php74-iconv php74-gettext php74-mbstring php74-imap php74-mcrypt php74-xmlrpc php74-mysql php74-openssl php74-sockets php74-zip php74-tidy php74-opcache php74-xsl php74-sqlite
sudo port select php php74

Thursday, September 15, 2022

How to remove directory in Linux

 To permanently remove a directory in Linux, use either rmdir or rm command:

  • For empty directories, use rmdir [dirname] or rm -d [dirname]
  • For non-empty directories, use rm -r [dirname]

Before you remove a directory, you need to know the name of it. To discover files and directories, use the ls command, and to know the current directory you are in, use the pwd command.

The options you use together with these commands are also important to determine how they work. Here’s a quick recap of rm command options:

Command and OptionDescription
rm -dRemove an empty directory using the rm command.
rm -rRemove a non-empty directory and its content.
rm -fIgnore any prompt when deleting a write-protected file.
rm -rfIgnore any prompt when deleting a write-protected non-empty folder.
rm -iOutput a prompt before deleting every file.
rm -IOutput a prompt only once before deleting more than three files.
rm *Wildcard that represents multiple characters.
rm ?Wildcard that represents a single character.
rmdir -pRemove an empty subdirectory and its parent directory.
rmdir -vPrint the information that the specified directory was deleted.

/usr/bin/env: 'php': No such file or directory CentOS Stream

sudo ln -s /usr/bin/php* /usr/bin/php

*= your current php version

Convert from CentOS Linux 8 to CentOS Stream 8

dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos

dnf distro-sync



Monday, September 12, 2022

Reset MySQL Root Password on Red Hat Enterprise Linux 8

sudo systemctl stop mysqld

sudo systemctl set-environment MYSQLD_OPTS=”--skip-grant-tables”

sudo systemctl start mysqld

sudo mysql -u root


mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewRootPassw0rd!'; 


mysql> QUIT;

sudo systemctl stop mysqld

sudo systemctl unset-environment MYSQLD_OPTS

sudo systemctl start mysqld

sudo mysql -u root -p

mysql> QUIT;

sudo mysql -u root -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ChangeRootPassw0rd!';

mysql> ALTER USER 'shola'@'localhost' IDENTIFIED BY 'ChangeSholaPassw0rd!';


mysql> QUIT;

Now login again with new root password !!

Sunday, September 11, 2022

Make PPK to Pem using Mac terminal

sudo port install putty
brew install putty

This will also install puttygen. To get puttygen to output a .PEM file:
puttygen privatekey.ppk -O private-openssh -o privatekey.pem

Once you have the key, open a terminal window and:
ssh -i privatekey.pem

The private key must have tight security settings otherwise SSH complains. Make sure only the user can read the key.

chmod go-rw privatekey.pem

Sunday, September 4, 2022

How to access EC2 instance if lost key Pair and root credentials


Create a new instance with same OS as previous one or create it from AIM made from old instance


Shutdown the old instance and detach the volume


Shutdown new instance Attached the detached volume to new instance and start the instance


Login new instance using ssh console

Run the following commands:


df -h

cd mnt

mkdir oldvolume

sudo mount /dev/sda1 mnt/oldvolume

cd mnt/oldvolume/root/.ssh

sudo vi authorized_keys

Now add your public key and save 

umount /dev/sda1

sudo shutdown now


Now detach the dev/sda1 volume from new instance and attach to old instance as dev/sda


Reboot old instance from AWS dashboard and login your old instance using ssh console 

 Note: Your old instance IP will be changed after doing this if no elastic IP

Friday, September 2, 2022

Install NVM (Node Version Manager) on macOS with Homebrew

Step - 1:
/bin/bash -c "$(curl -fsSL"
echo "# Homebrew\nexport PATH=/opt/homebrew/bin:\$PATH" >> .bash_profile
source ~/.bash_profile

/bin/bash -c "$(curl -fsSL"
echo "# Homebrew\nexport PATH=/opt/homebrew/bin:\$PATH" >> .zshrc
source ~/.zshrc

Step - 1:

brew update
brew install nvm
mkdir ~/.nvm

echo "export NVM_DIR=~/.nvm\nsource \$(brew --prefix nvm)/" >> .bash_profile
source ~/.bash_profile
echo "export NVM_DIR=~/.nvm\nsource \$(brew --prefix nvm)/" >> .zshrc
source ~/.zshrc

nvm install 12.13.0
nvm install --lts

How to install SSL on CWP hostname?

1 - Check that you should have an A record for the hostname. For example if your server hostname is, then you should have a...