Ubuntu – How to Change Hostname Without Rebooting

1. Update the current hostname

This command will instantly update the hostname which prevents having to reboot. It is not, however, persistent so your changes will be lost the next time you do reboot.

2. Update hostname File

Delete the current hostname and replace it with yours. This makes the new hostname persist when you reboot.

3. Update hosts File

If the new hostname isn’t added to the hosts file the sudo command won’t function properly.

Add the following on a new line after the localhost line:

Your hosts file should look similar to the following:

How to use IPTables to block all SSH traffic (port 22) except for your IP

Blocking traffic to port 22 (SSH) is one of the first steps you should take when hardening a server. Locking down port 22 not only keeps unwanted people from gaining access to your server, it also helps prevent a certain type of DDoS attacks called SYN floods. Using IPTables and a whitelist approach is the quickest and easiest ways to accomplish this.
Read More

Restrict Access to the WordPress Admin Dashboard Based on IP Address

The Admin Dashboard is one of the weakest links when it comes to securing WordPress. One way of securing the WordPress dashboard is using .htaccess to whitelist any IPs that you want to have access, and blocking everyone else. This method is quick and easy, and it works well because attackers can’t attack what they can’t see.

Here are two different ways to use .htaccess to block access to the WordPress Admin Dashboard based on IP address.
Read More

Force https and www with htaccess

Place the following stanzas in an .htaccess file in the root web directory:

Force www

Automatically redirect from domain.com to www.domain.com

Force https

Automatically redirect to a secure (https://) URL


  • Requires mod_rewrite
  • Requires AllowOveride to be set to On