Tag Archives: how to

How to install Vim

How to install Vim (vi) on Windows 10

This is a simple installation tutorial for those who don’t know that Vim can be installed in windows 🙂

Vim Website: https://www.vim.org

How to use Windows Terminal to copy files and folders.

Use cmd (command prompt) to copy files and folders.
It’s nice to know how to use the command line to do basic stuff. If you need to create a task scheduled copy/paste job this is going to be very useful.

// go to file or folder dir cd Desktop // list file or folder dir // copy file or folder xcopy file.txt file2.txt xcopy folder1 folder2\
Code language: JavaScript (javascript)

How to stop windows 10x sending data to microsoft (disabling telemetry altogether)

Here we are going to use the built in Mircosoft Windows 10 – Registry Editor to add a new dword and we are going to stop all telemetry (sending statistics to microsoft)

The anti-clickjacking X-Frame-Options header is not present.

If you have this for your site after scanning:

The anti-clickjacking X-Frame-Options header is not present.

Go to apache httpd.conf and add to the bottom of the file

Header always append X-Frame-Options SAMEORIGIN

After restart the apache server

FOR UBUNTU 20.04:

First enable mod headers and restart apache2

a2enmod headers systemctl restart apache2

go to /etc/apache2/conf-enabled/security.conf:

pico /etc/apache2/conf-enabled/security.conf

find

# # Setting this header will prevent other sites from embedding pages from this # site as frames. This defends against clickjacking attacks. # Requires mod_headers to be enabled. # #Header set X-Frame-Options: "sameorigin"
Code language: PHP (php)

Uncomment Header set X-Frame-Options: “sameorigin” to look like this:

# # Setting this header will prevent other sites from embedding pages from this # site as frames. This defends against clickjacking attacks. # Requires mod_headers to be enabled. # Header set X-Frame-Options: "sameorigin"
Code language: PHP (php)

And restart apache2 again:

systemctl restart apache2

Tutorial: How to Disable Track and Trace in apache (TraceEnable Off)

In this simple tutorial I show how to check and disable Apache track and trace. The operating system is CentOS 7 but it can work for CentOS 8 and other distros.

Nikto error: Allowed HTTP Methods: TRACE

If you want to disable TRACE methods go to httpd.conf and add to the bottom:

TraceEnable Off

How to create MySQL replication server

10.20.6.29 – Master Database
10.20.6.30 – Slave Database

pico /etc/mysql/mysql.conf.d/mysqld.cnf

chnage the bind address to your server real ip address 10.20.6.29

bind-address = 127.0.0.1

uncomment

server-id = 1 log_bin = /var/log/mysql/mysql-bin.log
Code language: JavaScript (javascript)

at the bottom of the file add your databases

binlog_do_db = newdatabase binlog_do_db = newdatabase2
sudo service mysql restart

now log in with root on the mysql server via terminal

mysql -u root -p GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
Code language: JavaScript (javascript)

copy the databases to the slave server with phpmyadmin
in 10.20.6.30 a.k. the slave

pico /etc/mysql/mysql.conf.d/mysqld.cnf
server-id = 2 relay-log = /var/log/mysql/mysql-relay-bin.log log_bin = /var/log/mysql/mysql-bin.log binlog_do_db = newdatabase binlog_do_db = newdatabase2
Code language: JavaScript (javascript)
sudo service mysql restart CHANGE MASTER TO MASTER_HOST='10.20.6.29',MASTER_USER='slave_user', MASTER_PASSWORD='password', MASTER_LOG_FILE='mysql-bin.000001';
Code language: JavaScript (javascript)
START SLAVE; SHOW SLAVE STATUS\G

If there is an issue in connecting, you can try starting slave with a command to skip over it:

SLAVE STOP; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; SLAVE START;
Code language: PHP (php)

MySQL Query where id is not equal to (WHERE id <> 6)

Have you ever needed a query where you search for all except one thing?
Here is an example of a query where you search for all except the number 6:

SELECT user_id, username FROM users WHERE user_id <> 6
Code language: HTML, XML (xml)

If you have ten users with id from one to ten , number six won’t be in the executed query.

Linux: How to get remote page load time with a command from the terminal?

Linux: How to get remote page load time with a command from the terminal?
This will give you the remote page load time in miliseconds.

time wget -p http://www.webleit.info >/dev/null 2>&1
Code language: Bash (bash)

You can implement the command with php like:

<?php $output = shell_exec('time wget -p http://www.webleit.info >/dev/null 2>&1'); echo "<pre>$output</pre>"; ?>
Code language: PHP (php)