Reset MySQL root password

Reset MySQL/MariaDB Root Password

Step 1:

Stop MySQL/MariaDB Service

CentOS/RHEL 7 Ubutu 16

systemctl stop mysqld/mariadb

CentOS/RHEL 6/5 Ubuntu 14

service mysqld stop

Step 2:

Start the MySQL daemon with “ mysqld_safe”

mysqld_safe –skip-grant-tables

Press CTRL+z to suspend a process by sending it the signal SIGSTOP

Step 3 :
Login DATABASE without Password
mysql --user=root mysql

Step 4 : 
Update Root Password
update user set Password=PASSWORD('new-password') where user='root';
set password for ‘root’@’localhost’=password(‘new-password’);
flush privileges;

Step 5: 
kill all mysql Process and restart mysql/mariadb service
pkill -9 myslqd
CentOS/RHEL 7, Ubuntu 16
systemctl restart myslq/mariadb
CentOS/RHEL 7, Ubuntu 16
service mysqld/mariadb restart.

salt toturial step by step

SALT ( Port Scan Attack Detector ) Tutorial 

Q : How to configure salt
Q : Step by Step PSAD Configure

SALT : it's a automation tool like ceph, puppet , ansible
Hostname :

IP =

Step 1. A

Add Repository

A. Ubuntu 14.4 :

a. Run the following command to import the SaltStack repository key:

#wget -O - | sudo apt-key add -

b. Save the following file to /etc/apt/sources.list.d/saltstack.list:

deb trusty main

c. Then update repository.
 apt-get update

Ubuntu 16.4 :

a. Run the following command to import the SaltStack repository key:

wget -O - | sudo apt-key add -
b. Add  the following line in /etc/apt/sources.list.d/saltstack.list:
deb xenial main
c. Then update repository.

 apt-get update
Step 1. B

Run the following commands to install the SaltStack repository and key:

C. CentOS7 & rhel7 :

sudo yum install
D. CentOS6 & rhel6 :

sudo yum install

Step 2  

Salt general installation process is as follows:

a.Make sure that your Salt minions can find the salt master.

b..Install the Salt minion on each system that you want to manage.

c.Accept the Salt minion key after the Salt minion connects.

Step 3

Salt Master installation and configuration:

ubuntu 14&16 :

sudo apt-get install salt-master

Rhel/CentOS 6&7:

sudo yum install salt-master

Step 4

Salt master configuration file:

vi /etc/salt/master

Edit the following lines:

#interface: (uncomment and put your system ip address)
#publish_port: 4505 (uncomment the line)
#user: root (uncomment the line)
#ret_port: 4506 (uncomment the line)
#pidfile: /var/run/ (uncomment the line)
#pki_dir: /etc/salt/pki/master (uncomment the line)
#cachedir: /var/cache/salt/master (uncomment the line)
#pidfile: /var/run/ (uncomment the line)
#verify_env: True (uncomment the line)
#keep_jobs: 24 (uncomment the line)
#sock_dir: /var/run/salt/master (uncomment the line)
#file_roots: (uncomment the line)
# base: (uncomment the line)
# - /srv/salt/ (uncomment the line)

Save  and exit 

Step 5

Start salt-master service:

Ubuntu 14 and centos/rhel6:
sudo service salt-master start
Ubuntu 16 and Centos/Rhel7
systemctl start salt-master.service

Step 6

Salt-Minion Installation And Configuration:

Ubuntu 14 & 16:
sudo apt-get install salt-minion
Centos 6 & 7 :
sudo yum install salt-minion

Step 7

Salt master configuration file:

vi /etc/salt/minion

Uncomment & edit the following lines:

master: (master ip address"" or domain name )
user: root
id: (xyz)
.......     Save and Exit 

Step 8

Start the service of salt minion
service salt-minion start (ubuntu14 & centos6) 
         systemctl start salt-minion.service (ubuntu16 & centos7) 

Step 9

Create Directory In Master System:

mkdir -p /srv/salt

Now Check the minion request on master system:

salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys: xyz
Rejected Keys:

Accept Minion key by command:
salt-key -A

Now connection is establish between master and minion.

Step 10

Automation type of salt: 

1. CLI Module (salt bash command if you have execute limited job perform)

2. State Module ( If you have to perform multiple jobs on minions.)

CLI Module:

In this module you can perform single task on minion like you want to create directory ram on minion so 
salt ‘*’ ‘ mkdir /tmp/ram’
Here ‘*’ = all minion

Note: if you want to execute on single minion so you have mention its client id . If you want on xyz client so you will e execute 
salt xyz ‘mkdir /tmp/ram’
you want execute ifconfig common on every minion 
salt ‘*’ ‘ifconfig’

Step 11

Package installation on minion:-
salt ‘*’ pkg.install vim

State Module:-

In this phase of automation you can perform multiple task on minions. You can make own cookbook for you project.

Needs for salt state module.

1. Yaml Langaguge
2. Create /srv/salt directory to store your project cookbook
3. Knowldge of salt state function (file, git, apache, firewall etc)

Note: You have add .sls extension in your salt cookbook.

I am showing you example of psad cookbook.

1.Firstly go the /srv/salt directory:
2.And create psad.sls file.
3. Open file with ant text editor (i am using vim)

# vim psad.sls


   - installed
   - show_changes: True



   - name: /etc/psad/psad.conf

   - pattern: 'EMAIL_ADDRESSES [email protected];'

   - repl: 'EMAIL_ADDRESSES [email protected];'

   - show_changes: True



   - name: /etc/psad/psad.conf

   - pattern: '/var/log/messages'

   - repl: '/var/log/kern.log'

   - show_changes: True



    - name: /etc/psad/psad.conf

    - pattern: 'EMAIL_LIMIT 0;'

    - repl: 'EMAIL_LIMIT 1;'

    - show_changes: True



    - name: /etc/psad/psad.conf

    - pattern: 'IMPORT_OLD_SCANS N;'

    - repl: 'IMPORT_OLD_SCANS Y;'

    - show_changes: True



    - name: /etc/psad/psad.conf

    - pattern: 'ENABLE_AUTO_IDS N;'
    - repl: 'ENABLE_AUTO_IDS Y;'

    - show_changes: True



    - name: /etc/psad/psad.conf

    - pattern: 'AUTO_IDS_DANGER_LEVEL 5;'

    - repl: 'AUTO_IDS_DANGER_LEVEL 3;'

    - show_changes: True



    - name: /etc/psad/psad.conf

    - pattern: 'AUTO_BLOCK_TIMEOUT 3600;'

    - repl: 'AUTO_BLOCK_TIMEOUT 86400;'

    - show_changes: True



    - name: psad

Save  and Exit  file.

Now your PSAD project successfully install and configure..

Some Reference:

step by step boot Ubuntu in text mode

Q: How to boot Ubuntu 16 in by default in Text mode

Step 1:

open /etc/default/grub and change according

vi etc/default/grub

A. Remove “splash”

       GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"


B. add 3 for text mode



C. Uncomment this line



Step 2 :

Update grub entry

Step 3:

how to Change default Interface name (enp0s3) to old “eth0”

Q :  how to Change default Interface name (enp0s3) to old “eth0”

Q : how to rename eth0 like interface name on centos 7 / ubuntu 16

Change default network name like enp0s3 or enp1s0 to old like eth0 / eth1 or wlan0 in Ubuntu 16 and CentOS 7

# ifconfig output

Step 1 :   open grub.cfg file

Ubutnu 16 :

vi /boot/grub/grub.cfg

Centos 7 :

vi /boot/grub2/grub.cfg

Step 2 :   

go to menu entry menuentry, find vmlinux line and add “net.ifnames=0 after the word “quiet”

Ubuntu 16 Output:

CentOS 7 Output :

Step 3: 

Reboot your system and change interface name ( enp0s3 ) to ( eth0) in network file

Ubuntu 16

vi /etc/network/interfaces


CentOS 7 : 

mv /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-eth0

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Restart Network Service

systemctl restart network

Convert Partition Table GPT to MBR in Ubutnu

Q:  how to convert gpt partation table to mbr ?

Q: Convert GPT to MBR using gdisk 

Step 1: Install gdisk

apt update
apt install gdisk

Step 2: Check disk OS boot from UFI for BIOS

gdisk -l /dev/sdX

Step 3: Convert GPT to MBR
gdisk /dev/sda

Recovery and transformation options (experts only) = Press “r”

Convert GPT into MBR and exit = Press “g”

Print the MBR partition table = Press “p”

Write the MBR partition table to disk and exit = Press “w”

Step 4: Reboot Or partprobe


Step 5: Re-install Grub

apt-get purge grub-common

apt-get instal grub-pc

Reboot Your System

latest kernel compile in ubuntu step by step

Q : How to Compile Kernel in Ubuntu 

Q : Latest Kernel Compilation step's in Ubuntu

Q : Atheros 5Ghz AP Channel Enable 

Q : Kernel Compile for Artheros Wifi Card to Allow 5Ghz Frequency on AP Mode

Step 1 

Install compulsory packages 
sudo apt-get update
sudo apt-get install linux-source fakeroot kernel-wedge build-essential
Step 2 Install Dependency
sudo apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc
sudo apt-get install binutils-dev crash kexec-tools makedumpfile kernel-wedge
  sudo apt-get install libssl-dev bc debhelper kernel-package libc6-dev
Step 3 

Download Kernel for ( you can download latest kernel )
cd /usr/src
wget tar xvf linux-4.8.4.tar.gz
Optional Steps : It's Required a approx 30-60GB disk space, if you don't have just mount external disk by following steps, best to create directory with kernel name
mkdir /usr/src/linux-4.8.4
mount /dev/sdb2 /usr/src/linux-4.8.4
here /dev/sdb2 is external hdd, and extract tar on it
tar xvf linux-4.8.4.tar.gz -C /usr/src/linux-4.8.4/
Step 4 and 5, if you don’t need 5ghz access point channel for Atheros WIFI
Card, avoid step 4 and 5 

Step 4 

Download Patch for wifi 5ghz frequency 
cd /usr/src/linux-4.8.4/drivers/net/wireless/ath/ wget --no-check- certificate package/mac80211/patches/403-ath_regd_optional.patch
Step 5 Apply Patch
patch -Np5 -i 403-ath_regd_optional.patch echo "#define ATH_USER_REGD 1"|cat - regd.c > /tmp/out && mv /tmp/out regd.c
 Step 6 Create .config file and make oldconfig
cd /usr/src/linux-4.8.4/ cp /boot/config-$(uname -r) .config make oldconfig
Note: choose default option just hit the enter on every prompt or choose according your need..

Step 7 

Compile, make and create .deb file
fakeroot make-kpkg --initrd --append-to-version=-linuxtopic kernel-image kernel-headers

     fakeroot make -j5 deb-pkg LOCALVERSION=-linuxtopic KDEB_PKGVERSION=1

Note: Wait approx 1 to 10 hour 

Step 8 

check .deb and Install Kernel
ls ../*.deb dpkg -i ../*.deb

How To Stress Test CPU and Memory

Stress is a h/w test utility. It is a simple workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the system.

Step 1:

Installation Stress Package 

A: Ubuntu 16
apt-get install stress
B: CentOS 6

yum install epel*
yum install stress*

C: CentOS 7

Downolad Stress RPM
cd /tmp

yum localinstall stress-1.0.2-1.el7.rf.x86_64.rpm

rpm -ivh

Step 2:

Below command to watch load average

watch uptime

Step 3:

Open new terminal and run stress command

stress -c 4 -i 8 -m 8 --vm-bytes 256M -d 1 --hdd-bytes 10GB -t 300s

    htop command output

stress -c 4 -i 4 -m 4 --vm-bytes 1024M -d 1 --hdd-bytes 10GB -t 300s

          stress -c 4 -i 4 -m 4 --vm-bytes 256M -d 1 --hdd-bytes 10GB -t 300s

Stress : load

         CPU = 4 cpu

         I/O  = 4 

         VM = 256MB

        HDD = 10GB 

     top command output

Here :

-c,    --cpu N spawn N workers spinning on sqrt()
-i,     --io N spawn N workers spinning on sync()
-m,   --vm N spawn N workers spinning on malloc()/free()
--vm-bytes B malloc B bytes per vm worker (default is 256MB)
-d, --hdd N spawn N workers spinning on write()/unlink()
--hdd-bytes B write B bytes per hdd worker (default is 1GB)
-t,   --timeout N timeout after N seconds

See more option

stress --help