How To Do Find & Replace In WordPress Datababes

Whatever operation you perform on a WordPress database, don’t forget to backup it before you start!

Find & Replace with Worpdress Plugin

Better Search and Replace Plugin is one of the most popular WordPress plugins which does the job. It provides you with an interface in WP-Admin to find and replace text across all database tables. All you need to do is download, install, and activate the plugin and you are ready to go. It is easy and straightway to use. There are also other plugins that do the same job for you. Just take a look at WordPress repository.

Better Seach And Replace
Better Seach And Replace

Although very easy to implement, WordPress plugin method for find and replace in databases provides limited functionality. You can only search in the current database. This is the blog’s database. If you want to be able to extended find and replace with regular expressions, you should use more advanced methods.

Search & Replace With PHPMyAdmin

This method requires an external program, PHPMyAdmin, installed at your hosting. As phpMyAdmin is a free software tool, intended to handle the administration of MySQL over the Web, I can bet you have it installed on your hosting account. As always, don’t forget to backup your databases.
After backing up, open your database with PhpMyAdmin. The content of your blog is located in “wp_post” table.
Click on the SQL tab. If you want to change something in your post’s content, here is the example to tackle the problem:

UPDATE `wp_posts` SET `post_content` = replace(post_content,
'string1',
'string2')

PHPMyAdmin
PHPMyAdmin

Find & Replace In Multiple Tables

Manual Find & Replace Within PHPMyAdmin

In order to do manual search and replace with PHPMyAdmin, you can select the table you wont to change. It can be post_content as in the example above. Click on the Search tab. Then select the ‘Find and replace’ submenu. It will take you to a place where you can enter the unwanted (find) ‘String1’ wanted (replace with) ‘String2’ and drop-down menu with the columns of the table you can perform the operation.
This option is not quicker than the one above, it is less techie only.

In the examples above I am using SQL commands to change ‘String1’ to ‘String2’ within the post_content field, or do it manually. If you want to change media files or custom fields, the table to work with, is ‘wp_postmeta’.

In all the above cases we have single table update. If you face the need to change multiple tables at once, make a dump of the database, search/replace within, and then upload it back. This will save you time and effort.

How To Find The Largest Files In Linux

Why Find The Largest Files In Linux

Before starting with the tutorial let me clarify why will somebody need finding the largest files in Linux. There could be several reasons. All the reasons boil down to log files.
1. Your server could have been a target of brute-force attacks. In this case /var/log/btmp file grows extremely big. Huge /var/log/btmp is an clue that you need to enhance your server security on several levels: change the port for SSH from 22 to something arbitrary and install a firewall. Of course, DenyHosts can block login attempts after a certain number of failures. ConfigServer is a better and more complex solution that definitely is worth all the time invested in its installing and configuring.
2. There could be a problem with systemd journal performance. To start off, let’s take a look at /etc/systemd/journald.conf. There is a setting to limit the amount of journals the system keeps.
Old ones get rotated out. Nevertheless, corrupted files do not get counted against this total. You can recognize the corrupted journal files by a .journal~ suffix.
3. Sometimes /var/lib/mysql/ibdata1 can get quite big. Preventing the shared table of  InnoDB’s, ibdata1, is  out of scope of this article. But you can find a good source of information on the topic at StackOverflow

Piped Commands to help you Find The Largest File On the Disk

There isn’t a single command to determine the largest file in Linux (Unix,BSD). Piped commands are used instead.
# du -a /var | sort -n -r | head -n 12
du – summarizes disk usage of each FILE, recursively for directories. The option -a writes counts on all files, not just directories.
sort – writes sorted concatenation of all FILE(s) to standard output. The option -n compares according to string numerical value. -r reverses the result of comparisons
head – prints the first 10 lines of a file to standard output, -n number option prints number lines instead 10 lines only.
Here is a sample answer

159502 /var
112868 /var/lib
100237 /var/lib/mysql
64922 /var/lib/mysql/ibdata1
22218 /var/log
12717 /var/cache
12712 /var/cache/yum
12712 /var/cache/yum/x86_64
12712 /var/cache/yum/x86_64/7
11141 /var/www

Judging by the results we might improve the ibdata1 mysql problem. At least we can check the configuration settings in my.conf

Free Social Networks Autoposters

The scope of this article is far beyond explaining the crucial importance of social media networks for blog authors and publishers. Social networks are the best traffic sources nowadays. Creating fan club and getting your content to reach as many readers as possible are just few targets you can set while using social networks.
Each time an author publishes a new article or blog post, they need to syndicate the post with their Facebook, Twitter or other social media profile. Social media auto posters are plugins that remove a workload from their head so that they can focus on blogging.

April 2017 update. There are some good reason to update the article about the social media WordPress plugins. The main one is Blog2Media plugin.

Blog2Media plugin

This plugin is downloadable from the WordPress.org repository. It is a new for me. I came across it when searching for something different in the repository. I am glad I have found it, because it prove to be better than I expected.
The plugin does the same as other similar plugins do: automatically share the posts whenever you publish a new post. With the free version of the plugin you can post to multiple social media profiles and Facebook pages. As you can guess, only one account per network is allowed with the free version. If you need multiple accounts per network, there is a premium version.
Plugin is very intuitive and easy to setup and use.
The plugin is accessible from every post in the editor or from ‘Post & Sharing’ lefthand menu. This menu displays a preview of all social media posts and allows you to customize your posts for each network in one single-page workflow. You can change the text and hashtags for any network of any post with on a single page.
Last but least this plugin will help you submit your photo blog posts to Instagram and Pinterest. This is the first plugin so far which can submit pictures to Instagram from a desktop computer. This is an extremely useful feature.

Update: Using this plugin to submit to Instagram can lead to Instagram disabling your account temporally. Use it very cautiously  and beware of the risk.

The only shortcoming, in my own opinion, is that plugin lacks support for some major networks like WordPress.com. Other from this it works like a magic, and lives up to its author promises.
[maxbutton id=”14″ url=”http://www.adamantmedia.com/go/blog2social” text=”Blog2Social Official Website” ]

Social Media Auto Publish

Social Media Auto Publish
I followed the instructions and was able to get it work seamlessly. All posts and events from my wordpress website went to Facebook without any need to bother. Definitely a keeper. Premium version of the plugin includes support to Pinterest and Google Plus.

Social Networks Auto Poster

Social Networks Auto Poster
Here I came to my third choice SNAP or Social Networks Auto Poster. The plugin is on the WordPress.org repository, at least its free version. There is a paid version which by the time I am writing this article is the best WordPress plugin for social media auto posting. With the paid version you can publish to the following social networks in nicely formatted manner: Facebook, Twitter, Google+(Google Plus), Blogger, LiveJournal, Delicious, Diigo, Stumbleupon, LinkedIn, Pinterest, Plurk, VKontakte(VK.com), WordPress, and Tumblr accounts. You can reach the most audience and let all your friends, readers and followers about your new post automatically. Plugin works with profiles, business pages, community pages, groups, etc.
Of course the free version has some limitation: it doesn’t have the ability to publish to Google+ (Google Plus), Pinterest and multiple accounts. Yet it works perfectly with the other networks. Paid version is $49.95 but is well worth the money provided you are a vigorous hard- working author.

[maxbutton id=”14″ url=”http://www.adamantmedia.com/go/nextscripts” text=”Download Social Networks Auto Poster” ]

Publisize by Jetpack

Jetpack from WordPress.com is a very popular package and I have already used some other features like the fancy tiled gallery. As expected there wasn’t any problem installing and getting it to work. The only shortcoming was that Publisize doesn’t have the functionality to publish automatically to Google+.

WordPress 4.7.1 Vulnerability Hacked By SA3D HaCk3

WordPress 4.7.1 Vulnerability Hacked By SA3D HaCk3

Recently one of my clients had two of their wordpress websites hacked. The main evidence were two posts added to the blogs with a title either ‘Hacked By SA3D HaCk3’ or ‘Hacked by Xurupitas Farm’.

After doing my research on Google I found that the reason was a vulnerability in 4.7.1 release of WordPress. So users who failed to upgrade from 4.7.1. to 4.7.2 suffered from the vulnerability in WP_Query. Although the Worspress Core is not endangered, some themes and plugins could be susceptible to a SQL injection (SQLi) when passing unsafe data. This issue was fixed in 4.7.2 version.

What did the hackers Add To The Blogs

After deleting the injected posts, I looked into the wordpress databases for more clues and did find some revisions of the aforementioned posts, but anything else.

Then I checked the websites with two free online scanners for malware. I used Sucuri and Quiterra to double check the blogs for viruses. Both of them didn’t find anything suspicious.

The moral of this story for me is to bring attention to our customers for the need to update core software and plugins regularly. Additionally, automatic background updates are very useful in promoting better security. One approach for this is to add a statement enabling core upgrade in the WordPress config file wp-config.php

Configuration of wp-config.php

Using wp-config one can completely disable Worpress core

define( 'AUTOMATIC_UPDATER_DISABLED', true );

or fine-tune the way core will update in future.

define( 'WP_AUTO_UPDATE_CORE', true );

In the above statement we can have three values.
True- the core will always update, even in major upgrades
False- the core will never update
Minor- Only minor updates will be executed

How To Install Software Packages in Linux

linux

How to install and remove software packages in Linux

The scope of today’s article is installing and removing certain software packages in Linux using both high and low level package management tools.
Installing software packages, including updates, is one of the most common tasks every system administrator performs. The main reason behind this is that Linux being an open source software, is constantly updated. New features are added and old bugs get fixed. Regular update of the used software also improves overall security.

Key Terms Used In This Article

  1. Software repository: trusted central source of compiled, tested, integrated software
    packages provided by a distribution.
  2. Low level package management: actions that pertain to an individual package: install,
    upgrade, query, remove. Does not handle dependency resolution: dpkg command in
    Debian-derived distributions, and rpm in distributions made up of rpms.
  3. High level package management: System level actions like system updates, accessing
    repository metadata, multiple package upgrades, and dependency resolution: apt in
    Debian-derived distributions, yum in rpm-based distributions

Real life task to fulfill

Install some software packages on Linux server using both low level and high level package management commands. In the examples below I am installing the libpng
ubuntu

How to install or remove a single package using apt-get

Apt- get is a high level package manager for Debian bases distributions like Ubuntu. You can use the command with proper parameters to install via terminal. To open a terminal you’d just press Ctrl+Alt+T on your keyboard to open. When it opens, you would run the apt- get to install the application.

When it opens, type the following code:
sudo apt-get install libpng12-dev

This one line of code will do all the work for you. It will download using wget the libpng package from the repository listed in sources.list in /etc/apt folder.
Centos

How to install or remove a single package using YUM

YUM command is run on a rpm- based distributions like Centos and RedHat.
It is run as yum .
In our case in order to install the libpng software, we should run:
yum install libpng12-dev

How to install Google fonts on Ubuntu

DIY graphic design is among of my recent business ventures. I figured out that I need fancy fonts for GIMP to make my work more aesthetically pleasing. My first choice fall upon Google fonts because they are free to obtain and suited my needs.

Using The Font Manager To Add Fonts

There are quite a lot fonts packed for Ubuntu. The Font Manager (font management application for the GNOME desktop) can make your life easier for handling fonts. If you are a keen graphic designer wannabe, I would recommend installing it. As the usual Ubuntu fonts was not my choice, I looked for another way to install fonts.
If you are into manual installations like me you will find Ask Ubuntu thread about this very useful.
You can simply copy the fonts into a hidden .fonts directory in your home folder. Alternatively if you are a super user of Ubuntu you can make available system-wide by coping them to /usr/share/fonts . After that make a new font cache with fc-cache -f -v.

As you can guess I made a google search on the topic ‘How to install Google fonts on Ubuntu’. The suggestion the search engine gave on the topic was from some author who used TypeCatcher for his designer needs. Unfortunately this article was outdated. TypeCatcher project hasn’t been updated for quite a lot of time. There wasn’t a update for the newest “Xenial” Ubuntu.
I didn’t want to waste my time and went down to the search engine results list looking for an information how to install Google fonts on Ubuntu.

Working Easy Way To Add Google Fonts To Ubuntu

My search was rewarded with an blog post dated back 2011. The author of the article made use of a simple shell script that does all the necessary work. The scripts first downloads the Google fonts bundle from a repository.
After extracting the files from the tarball file, the scripts creates a new subdirectory google-fonts in /usr/share/fonts/truetype/ where it installs the new fonts. After updating the font cache, it cleans up the tarball file.

Voila, Google fonts are ready for use!

Top Free Slider Plugins For WordPress

It has become blogging fashion to show off your images and videos with a slider. Sliders are cool and great for visual representation of the media. They are great for review bloggers as they showcase all products in the post in a single place.

Sliders are beneficial for affiliate bloggers as well, because they can include a link to the merchant to make a purchase.

Here is a shortlist of the best free slider plugins for WordPress.

Meta Slider Plugin For WordPress

meta slider plugin
When it comes to free slider plugins Meta slider should be the no 1 candidate. It has 700,000 plus installs. Lets trust fellow users’ choice. With the free version of the plugin you can create responsive image slideshows with Nivo Slider, Flex Slider, Coin Slider and Responsive Slides. You can adjust the height and width of the slider. There are three transition effects and one navigation option with the free version.
In the advanced option you can control how the text (caption of the media element) looks. Also every image slide has a link option where you ca put a link to a merchant or give a credit for a photography.
The most important feature of the free version from the SEO point of view is the ability to add image title and alt text. This feature makes the plugin a definite runner-up for the title best slider plugin.

 

[maxbutton id=”10″]

 

Huge It Slider Plugin For WordPress

huge-it-slider

 

Before making a review I want to test the plugin. I haven’t used it so far but it has 100,000 installs from WordPress Repository and almost 5/5 user reviews. I want to find out exactly what a user can do with the free version. The authors of the plugin were so kind to deposit a test slider with three quality images. I am going to use them to test the plugin.

There were no trouble installing and using the plugin at all. Everything started working from the very beginning. In the free version you can make as many sliders as you want but they can be only image type. You can create video and post sliders with the paid version only. With Huge It Slider Plugin you can adjust width and height of the slider, there are some eye- catching sliding effects included in the free version. You can also change pause time and change speed and change navigation signs.
Overall, this plugin is easy to use, allows creating of full blown image sliders with links to the products, objects. Last but not least runs smoothly on the current version of WordPress.
 
[maxbutton id=”11″]
 

Cyclone Slider 2 Plugin For WordPress

 
cyclone slider plugin for WordPress
 
This plugin has 80,000 plus downloads so far.
Cyclone Slider 2 slideshow plugin for WordPress has all the basic capabilities to create an efficient slider. Here comes the most interesting part. The plugin supports multiple slides parts. I mean you can create a slideshow where some of the slides are YouTube video, and some are images. The plugin supports image, YouTube, Vimeo, Custom HTML
and Testimonial slides. Awesome! In addition to the usual settings the plugin comes with four themes and advanced template page. There is an information on the site about how to customize the templates. The paid version includes dynamic height and more support for mobile devices. Yet the free one plugin creates responsive slides. Smart JS/CSS loading for best performance.
 

[maxbutton id=”12″]
 

Responsive WordPress Slider – Soliloquy Lite Plugin For WordPress

soliloqui
 
Soliloqui has some features that makes it stand in front of the others. It is using a custom post type to create sliders. This is not a new feature though.
The plugin is SEO optimized with the ability to specify alt and title tags for your images within the slider.
Last but not least there is smart JS/CSS loading so that assets only load on pages where a Soliloquy WordPress slider is present.
 
[maxbutton id=”13″]
 

Easing Slider Plugin For WordPress

Easing Slider Plugin WordPress
 
Easing Slider has 80,000 downloads from the repository. This plugin has very basic features. If you need a basic image slideshow with the images of your media library, perhaps this plugin is for you. If you want some more features, you will have to purchase a basic, unlimited or lifetime licence.

Download Easing Slider Plugin For WordPress

Master Slider Responsive Touch Slider Plugin For WordPress

master slider plugin for wordpress
This plugin sports 80,000 downloads from the repository. It is advertised as responsive and HTML5 WordPress slider plugin with touch swipe navigation that works smoothly on desktop and mobile devices. Having a website to perform equally well on mobile device and desktop is of crucial importance. Hence I am giving it a try.
The plugin offers touch swipe navigation for mobiles and loading assets on demand. Also you can choose from 6+ slide transitions and vertical and horizontal direction navigation.
The premium version adds the abilities to add videos and to slide WooCommerce products.
 
[maxbutton id=”14″]
 

Restart Start Stop Mysqld From The Terminal in Linux

You could need to restart MySQL server after installing, upgrading, or making some changes in my.cnf file in Linux. The quickest way to this is by typing on the command line terminal. No fancy graphic interface.

MySQL Server Restart General Syntax

The syntax is as follows. On the Linux or OS X type the following on the shell prompt:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
/etc/init.d/mysqld restart

MySQL Server Restart Using Systemd Manager

Alternatively you could restart MySQL by sending control commands to the systemd manager.
systemctl start mysqld
systemctl stop mysqld
systemctl restart mysqld

FreeBSD Unix server users could use the following syntax to start/stop/restart the server.
/usr/local/etc/rc.d/mysql-server start
/usr/local/etc/rc.d/mysql-server stop
/usr/local/etc/rc.d/mysql-server restart

On OS X to start/stop/restart MySQL from the command line, as this article states
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart

How to change ownership of files with chown in linux

File (directory) ownership is the foundations of every operating system. This post will teach you how to change file(s) ownership in Linux using the command chown.
There are different scenarios when you would need to change the ownership of a file using either chown or chgrp. Note: you can change group ownership with the command chown. I’ll show you how to do this later in this article.

There is another command to change permissions in Linux chmod. Note that only the current owner of the file and the root user can do this task.

Although neither of the commands are difficult to use, modifying the file ownership with chmod is beyond the scope of this post. It belongs to another article.

Change the file(s) or directory ownership to suit your needs by following roughly the instructions below.

Figure Out Who’s The Owner Of The File(s)

ls -l myfile
ls -l option uses a long listing format. With this option ls returns file ownership together with permissions. Here you would probably want to decide how to alter the file or directory ownership.

Using Chown To Change Ownership

The simplest usage of using the command and setting the ownership to the user myuser is:
chown myuser myfile
ls -l
-rw-r--r-- 1 myuser root 28 june 25 2014 myfile

where the file myfile is owned now by myuser. If you want to change the group from root to mygroup, do it by slightly modifying the code:

chown myuser:mygroup myfile

In real life, we usually have to change ownership of an entire directory tree. You would do this by adding -R option which stands for recursive operation. With this option the command goes thru all files and directories within the directory in changes the ownership.
chown myuser:mygroup /home/myuser -R
Takes everything in myuser home directory back.

How to disable root user from direct ssh login

Brute Force Login Attempts are as common as ever. Even if you have a strong root password, it is a matter of time for it to be cracked using a dictionary attack. Hence the need to prevent direct ssh logins for common accounts like root or admin.

Generally, it’s safe to use a hidden “su” user first, then login to root or other accounts once connected. Disable any well known accounts (root, admin, etc) that don’t need direct access by editing the /etc/ssh/sshd_config and removing or commenting  out the section with the code.

#AllowUsers root

Always test changes before logging out else you may lock yourself out from the box.

Here how you can do it on a generic Linux system is three simple steps:

  1. Add the user. I’ve chosen the user editor. You can pick some other name.
    [root@mycomputer ~]# adduser editor
    [root@mycomputer ~]# id editor
    [root@mycomputer ~]# uid=1007(editor) gid=1008(editor) groups=1008(editor)
    [root@mycomputer ~]# whoami
    [root@mycomputer ~]# editor
  2. Set the password for the new user. Enter and confirm the new password at the command prompt.[root@mycomputer ~]# passwd editor
    Changing password for user editor.
    New UNIX password:
    Retype new UNIX password:
    passwd: all authentication tokens updated successfully.
    [root@mycomputer ~]#
  3. In order to give sudo permissions of the new user editor you have to edit the file /etc/sudoers, remove the comment # in front of the statement
    %wheel ALL=(ALL) ALL
    where you will give su permissions to the group wheel. Add the user to the wheel group.
    usermod -aG wheel editor.
    At least this is the approach recommended from by RedHat
    Another way of doing this is by giving su permissions to the user editor. Once again this is done by adding a line in /etc/sudoers
    editor ALL=(ALL) ALL
  4. Now ssh to the server with the new user. Make sure everything is okay and the user has all the rights you need.
    [root@mycomputer ~]# ssh editor@myserver
    editor@myderver's password:
    [editor@editor ~]$
  5. Check if you can su (switch user) to root from the user admin
    [admin@admin ~]$ sudo su
    Password:
    [root@editor ~]# whoami
    [root@editor ~]# root
  6. After you are completely sure the new user editor works as expected, you can disable root access via ssh. Edit the file
    [root@editor ~]$ nano /etc/ssh/sshd_config
    and either set
    PermitRootLogin no
    or remove/ comment out the line
    AllowUsers root
  7. The last step is to restart the sshd service.
    for RedHat Centos Fedora
    [root@editor ~]# service sshd restart
    for Ubuntu Debian
    [root@editor ~]# service ssh restart