Author: Sahil Suri

Configuring service unit files for use with systemd

Introduction In an earlier article, we discussed the systemd system startup manager in detail and also ventured into the reasons why it has replaced sysvinit as the default system startup and service manager for many popular Linux distributions including RedHat, Centos, and Ubuntu. Within Centos 7/RHEL 7 we are provided with targets or target units instead of run levels and in a similar manner service units now represent service scripts in systemd. In this article, we will demonstrate how we can create service unit files which are analogous to the init scripts in sysvinit which we already covered in a previous article.   An overview of systemctl One of the interesting features of systemd is that run level management and service management are under the control of a unified tool named systemctl. Therefore, systemd does not use the service and chkconfig commands or the init or telinit command to change run levels. To enable or start a service, for example, sshd on boot, we would use the following command. systemctl enable sshd To disable the sshd service on boot, we would use the following command. systemctl start sshd To view the status of the sshd service, we would use the following command. systemctl status sshd The systemctl status command is especially more useful and verbose as compared to it’s predecessor, the service status command because it not only provides...

Read More

How to write sysvinit scripts?

Introduction In one of our earlier articles we discussed the sysvinit system startup and service manager in detail. In a subsequent article, we compared sysvinit with other two major alternatives to sysvinit i.e. upstart and systemd. In this article, we will demonstrate how we can create our own init script and use it within the sysvinit service startup system.   Anatomy of an init script: The init scripts reside in the /etc/init.d directory which in fact is a soft link to the /etc/rc.d/init.d directory. An init script is a shell script that has some metadata information which is meant to be used by sysvinit followed by the code to manage a service/task/process. As you will see in the sample init script we’ve written and you may also take a look at other init scripts in the /etc/init.d directory, the general structure of the scripts is quite similar. The script will begin with some metadata information. This will be followed by a couple of functions which will contain code for actions to be performed. The functions and the code within them is essentially used to start or stop the service or to check it’s status. After the function definitions have been completed, there would be a case statement. The expression used with the case statement will be the argument specified to the service script. The case statement will contain cases...

Read More

Troubleshooting passwordless ssh logins

Introduction Configuring passwordless ssh authentication between users on the same or different systems is a common task for a system administrator. Following the available steps is simple enough but we may often find ourselves in annoying situations when we follow the steps exactly and the setup does not work. In this article, we will show you how to configure passwordless ssh authentication between two users with the same username on 2 different systems. Given below is an overview of our intended setup: username: sahil source server IP: 192.168.188.133 (centos 7) destination server IP: 192.168.188.129 (centos 6)   Step 1: Generate ssh authentication keys: Let’s log in to our source server and generate an ssh key pair which we will use for authentication. To do this we use the ssh-keygen command as shown below: [sahil@linuxnix1 ~]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/sahil/.ssh/id_rsa): Created directory '/home/sahil/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/sahil/.ssh/id_rsa. Your public key has been saved in /home/sahil/.ssh/id_rsa.pub. The key fingerprint is: 61:67:54:87:e2:1c:a2:d9:ac:34:e7:f3:17:9c:9e:e5 sahil@linuxnix1 The key's randomart image is: +--[ RSA 2048]----+ | ..... | | ..o .. | | =o+oo | | =.++o | | . =S . . | | . o + . | | o . = | | . + E |...

Read More

Over 16,000 readers, Get fresh content from “The Linux juggernaut”

Email Subscribe

ABOUT ME..!

My photo
My name is Surendra Kumar Anne. I hail from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present I work at Bank of America as Sr. Analyst Systems and Administration. You can contact me at surendra (@) linuxnix dot com.