Tag Archives: CentOS

How to set the hostname on CentOS 7

CentOS 7 has a nice command called hostnamectl. With it we can display the current hostname, and set any of the three types of hostname:

  • static hostname (something like example.com)
  • transient hostname (anything you like, assigned when using DHCP)
  • pretty hostname (something like Jay’s MacBook Pro)

By default, a CentOS installation comes back with localhost.localdomain – but that’s not meaningful if you see lots of localhosts on the same network.

If the IP of the box does not change, we can set the static hostname like this:

No feedback means good news. Likewise, we can set a hostname if were using DHCP to get an IP address, even though it may change every time we connect. To make sure we retain the same name no matter what IP we get, let’s set the transient hostname like so:

Note that we can’t use spaces or special characters with static or transient hostnames as far as I know.

Lucky for us there’s also the pretty hostname, which does support special characters. It doesn’t usually appear anywhere on the command line, but GUIs like to display the pretty name of a machine when available:

There’s no need to restart anything, the changes are in effect as soon as we hit return after either command.

To see the current hostnames, we can use the status switch:

Thanks to Vivek Gite for this wonderful explanation!

  • http://www.cyberciti.biz/faq/rhel-redhat-centos-7-change-hostname-command/

OS X Server vs. Parallels Desktop – Overhead Differences

Screen Shot 2015-11-04 at 10.28.17

Ever wondered if there’s a difference in overhead and memory usage when you’re using a VM instead of OS X directly? Here’s a comparison for website hosting.

The above graph shows the difference of hosting one of my websites for the last few days on OS X Server (in blue) that I got from Hostgator (using their HostGator Thanksgiving Deal 2016 coupon), and in a CentOS VM under Parallels Desktop 10 on the same hardware (in red).

The traffic logs show that the amount of requests and visitors has remained the same, so we can deduce that the load put on either OS X and the VM is the same. There is a little more overhead when using the VM, but not as much as I had feared: the requests have to be forwarded to another software layer after all, and that takes some CPU power.

Let’s have a look at memory next:

Continue reading OS X Server vs. Parallels Desktop – Overhead Differences

How to disable SSH access from everywhere except for certain IPs in CentOS 7

Here’s how to do it:

This declares an internal zone with two IPs (add as many or as few as you like) and subsequently removes the SSH service from the public zone altogether. As a result, any other IP gets a message such as “Connection refused” when trying to connect via SSH.

The “–permanent” switch saves the changes. Remove it for testing or if you don’t want this change to be permanent.

The last line reloads the current firewall rules (thanks, CertDepot).

  • http://serverfault.com/questions/680780/block-all-but-a-few-ips-with-firewalld

How to disable the user list at login on CentOS 7

Screen Shot 2015-08-13 at 10.51.47

By default, CentOS 7 will display a list of all users on the system. Click on it, type in the password, and you’re in. This works well when you have a handful of users on the system.

However, on systems with a lot of users, not everyone can be displayed in that list – and scrolling up or down is impossible (and even if it was, it’s impractical at best). The solution is to replace that list with a box to type in a user, much like what would happen when you choose the “Not Listed” option.

Here’s how to do it:

From the command line, login as root and create a file called /etc/dconf/db/gdm.d/00-login-screen. By default it does not exist.

Now add the following lines to it and save the file:

This will tell GNOME not to display the list anymore, and instead bring up a text box as shown below. For the change to take effect, we need to update GNOME with the following command:

And that’s it!

Screen Shot 2015-08-13 at 10.54.55

How to enable automatic user logins in CentOS 7 and GNOME

CentOS-LogoIf you’ve read my previous article about how to enable automatic logins on CentOS 6, and it sounded a little daunting, you may be pleased to hear that it’s a little easier to accomplish the same thing on CentOS 7.1.

If you’re using GNOME in a single user environment, and you’re confident that nobody else will use your system, you can enable auto-logins without the password questions like this:

  1. Login to GNOME as usual
  2. Find your name at the top right and click on it
  3. Now select Settings
  4. In the new window that opens, find Users
  5. Click on Unlock at the top right
  6. Select your own user and turn on Automatic Logins

You need supervisor privileges to make this change. Next time you restart your system, you’re logged in automatically.

Screen Shot 2015-08-13 at 10.19.12

Thank you, CentOS!

How to install Parallels Tools via the Command Line in CentOS

I like setting up barebones CentOS and other flavoured VMs on my Mac via Parallels Desktop. Trouble is, for such things like time synchronisation to work properly, something called Parallels Tools needs to be installed on each VM.

This is to make sure Parallels Desktop can speak to the VM and communicate with it properly. It’s more important for GUIs so that the screen resolution and mouse handling is more accurate.

Thing is, when you have a VM with a GUI, installing Parallels Tolls is extremely easy and may even happen automatically as soon as you install the OS. But if you have a command line only interface, it just doesn’t happen, and it’s up to us to install those tools manually. Here’s how to do it in CentOS 6.

First, boot up your barebones VM and wait for it to start. Now head over to the VM’s menu and choose Actions – Install Parallels Tools. If they’re already installed, this message will change to “Reinstall Parallels Tools”.

Screen_Shot_2015-07-21_at_16_39_13

If your VM has a graphical user interface, this process will kick off the actual installation, but on barebones machines, it will merely attach the ISO image that contains the tools to your VM. In an ideal world, this tool would even mount the image for us, but sadly it doesn’t work with CentOS. Therefore we have a bit more work to do until we get to the installation part.

You’ll see the following message to confirm the attachment:

Screen-Shot-2015-07-21-at-16.29.35

Now let’s login to our VM as root using our favourite SSH client (or simply use Parallels Desktop). We’ll create a directory to which we can mount the image. As suggested in the Parallels documentation, we’ll use /media/cdrom:

With this directory in place, let’s mount the ISO image to it so we can address it:

The message is fairly self-explanatory: no writing to that ISO image. No problem! To start the installation, enter the directory and call the install script like so:

 

Help! That’ didn’t work!

Sometimes (in CentOS 7 for example) the ISO image isn’t properly mounted, and instead Parallels Desktop mounts a directory containing the ISO image. That’s no good of course. If you receive an error message along the lines of “command not found”, take a look at the CD Rom’s directory with the ls command.

If there is no file called “install”, and instead there’s something like “prl-tools-lin.iso”, you need to manually attach the ISO image to your VM. To do this, restart your VM and select Devices – CD/DVD 1 – Connect Image. Now navigate to Applications – Parallels Desktop.app – Contents – Resources – Tools and pick the appropriate ISO file.

Screen Shot 2015-08-07 at 12.49.50

 

For all Linux flavours this is prl-tools-lin.iso. Once attached, mount the device as discussed above and you should be able to run the installer.

 

Parallels Tools TUI in action

The script will greet us with a TUI and some steps we need to complete, one of which may be that some additional components (such as make and gcc) need to be installed. That’s not always the case on barebones systems. Lucky for us, the script will take care of this for us too:

Screen Shot 2015-07-21 at 16.33.51

And that’s it! The script will finish fairly quickly, and at that point, Parallels Tools is installed in your VM. Congratulations! There’s only one final step: reboot the VM. You can either do that from the VM’s menu under Actions – Restart, or by issuing the following command:

As soon as the VM is back up and running you’re all set 🙂

Screen Shot 2015-07-21 at 16.38.48

 

Further Reading:

How to enable resuming FTP uploads in Plesk

Plesk uses ProFTP as the default FTP server. It has a handy feature that allows file uploads to resume or append should a connection be broken during transmission. This means that partially transferred data doesn’t have to be uploaded again, it can simply be added to – potentially saving a lot of time.

Although easy to activate, this feature is not enabled by default on Plesk installations for security reasons. Here’s how to make it happen:

Edit /etc/proftpd.conf and add the following few lines:

You may find the AllowOverwrite directive in there already, in which case replace it with the above block. For the changes to take effect, restart the xinetd service (of which proFTP is part):

Works on both CentOS 6 and CentOS 7.

Note that for this to work, it also needs to be enabled in your FTP client. In FileZilla it’s under Settings – Transfers – File Exists Action:

Screen-Shot-2015-04-09-at-12.40.26

  • http://soulhuntre.com/2005/01/27/plesk-proftpd-and-resume/
  • http://www.proftpd.org/docs/directives/linked/config_ref_AllowStoreRestart.html

How to update Plesk via the Command Line

Plesk-LogoYou can update Plesk via the Web Interface (under Tools and Settings – Updates and Upgrades). However sometimes the interface times out, or browsers get confused – therefore it’s good to know that you can apply updates via the command line interface as well. In this article I’ll show you how (in Linux – I don’t know much about running Plesk on Windows I’m afraid).

We need to download the standard installer script for this. It’s a powerful little tool which can also be used to add or remove components from the current Plesk installation, or to install Plesk on a barebones server.

As of 2017 the link can be found here:

  • https://page.plesk.com/plesk-onyx-free-download

Screen Shot 2015-05-03 at 09.39.40

If you click the option “Download Plesk installer for Linux”, you’ll see the actual script open in a new browser tab. Not what we want, although you could copy and paste this into a new file on your Linux system. Instead, right-click on the link and choose “Copy Link” instead.

Screen Shot 2015-05-03 at 09.41.27

With that link in your clipboard, connect to your server via SSH and download the file with something like wget:

This will result in a file called “plesk-installer” with some nasty parameters at the end, several hundred characters in total. Let’s rename it to something easier and tweak the execution permissions:

Now we can run the script like so:

Follow the instructions to upgrade Plesk. You can also call the script with several options, for a full list of those call it with “–help”. To see all available versions of Plesk during the installation, use “–all-versions”, which will eventually lead you to a screen similar to this:

If you call the script without any parameters, only micro updates and additional components are applied. Micro updates are usually applied automatically if this feature is enabled (it is by default).

How to open SMTP port 587 to send emails in Plesk

Plesk-LogoBy default Plesk on Linux uses Postfix for outgoing email, and by default listens on port 25 for outgoing SMTP mail. Some service providers do not allow to send emails on that port, and tragedy occurs: clients can’t send email with their Plesk servers. Not good.

Other SMTP ports will usually work, such as the other favourite 587 – but by default, Postfix is not listening on this port for email submissions – at least not in Plesk 12.0.8 on CentOS 7.

Here’s how to enable port 587 for such ventures:

Open the Postfix configuration file at /etc/postfix/master.cf and find the following line. It’s commented out. All we have to do is to remove the hash in front of it, and email can be sent via port 587:

Restart Postfix for the changes to take effect. In CentOS 5 and 6:

This will also work in CentOS 7, but to be more precise:

Happiness!

Note that port 587 needs to be open in your firewall. If the Plesk Firewall Extension is enabled, it’ll take care of it for you automagically.

 

  • http://blog.mailgun.com/25-465-587-what-port-should-i-use/
  • http://www.faqforge.com/linux/how-to-enable-port-587-submission-in-postfix/
  • http://know.mailsbestfriend.com/how_to_enable_port_587_submission_in_postfix-1932675618.shtml
  • a Plesk 11 alternative: http://kb.sp.parallels.com/en/114417

How to turn off all Plesk Health Monitor alert emails

Plesk-LogoI have previously described how to adjust the values that the Plesk Health Monitor uses to determine when an email should be sent out.

There is also a way to switch these emails off entirely. Here’s how:

To turn off the daemon that is responsible for sending these emails, issue this:

No more emails until you restart the server, when the daemon will be resumed. If you don’t want that, switch it off at boot time using

To remove the Health Monitor altogether, head over to Tools and Settings – Updates and Upgrades and uninstall the component.

  • http://forum.odin.com/threads/constant-alarm-level-changed-emails.261363/page-2
  • http://www.devblog.co/how-to-disable-health-monitoring-notifications-from-parallels-plesk/