How to test PHP 7 and WordPress MySQL/MariaDB Database connectivity using a PHP script

To test PHP 7 and WordPress MySQL/MariaDB database connectivity using a PHP script, you can use the following steps: Create a new PHP file with a .php extension, for example test.php Open the file using a text editor and add the following code:   <?php $host = “hostname”; $user = “username”; $password = “password”; $dbname … Read more

How to move/migrate LXD VM to another host on Linux

To move/migrate an LXD virtual machine to another host, follow these steps: On the source host, stop the LXD container: lxc stop <container name> Export the container: lxc export <container name> <file name>.tar.gz Copy the exported tar archive to the target host: scp <file name>.tar.gz <user>@<target host IP address>:~/ On the target host, import the … Read more

How to delete files containing a character or number/digit in their filename on Linux or Unix

You can delete files containing a character or number/digit in their filename using the find command and the rm command. Here is an example to delete all files containing a digit in their filename:   find . -type f -name “*[0-9]*” -delete Explanation: find .: Find files in the current directory. -type f: Find only … Read more

How to install route command on CentOS / RHEL 7

The route command is already installed and available on most Linux distributions, including CentOS and RHEL 7. To verify if it’s installed on your system, you can run the following command in the terminal:   route –version If the output shows the version of the route command, it means it’s already installed on your system. … Read more

How to remove non empty Directory in Linux

To remove a non-empty directory in Linux, you can use the “rm” command with the “-r” option for recursive deletion:   rm -r <directory_name> For example:   rm -r /path/to/non_empty_directory This will remove all files and subdirectories within the target directory. Be careful when using the “-r” option, as it can permanently delete large amounts … Read more

How to find and replace text/IP address with Ansible

To find and replace text/IP address with Ansible, you can use the replace module. Here’s an example of how you can use it in a playbook:   – name: Replace text in file replace: path: /path/to/file regexp: ‘old_text’ replace: ‘new_text’ – name: Replace IP address in file replace: path: /path/to/file regexp: ‘old_ip’ replace: ‘new_ip’ In … Read more