The @ symbol and systemctl and vsftpd

I have a two part question.

  1. What is the significance of the @ symbol in systemctl scripts?

  2. How to start vsftpd in fedora 16, (which in some tutorials seems to contain an @ in it's name)? I have done everything the tutorials say, and it still gives me an error. http://blog.tuxforge.com/fedora-16-vsftpd/

What I've done

systemctl enable [email protected]

What I see

Failed to issue method call: No such file or directory

(I have tried this with a absolute path as well, and after I checked there is no such file. The real file does not contain an @ sign, and is located under the /lib/systemd/system/ directory. I have also tried starting and enabling with and without the @ symbol, enabling works, but starting doesn't. I realize the article is now obsolete, but I still cannot seem to start the service. When I try to connect it doesn't let me)

EDIT: I got the service to start somehow, but I would still like to know what the @ symbol means in some service names. Also I am still getting a login error number #500 cannot change directory [...], what does this mean?

To start it I just typed

sudo systemctl enable vsftpd.service

sudo systemctl start vsftpd.service (the problem was I was using an absolute path for this I think)

Solution 1:

The @ symbol is for special services, sockets, and other units where multiple instances can be run.

For instance, [email protected] is the service that provides text login terminals. When you press Ctrl+Alt+F2, [email protected] is started, creating virtual terminal #2.

Another service that uses this functionality is OpenVPN. You can create a file /etc/openvpn/work.conf, configured to connect to the VPN at your workplace, and then systemctl start [email protected] to connect to it. Similarly, you could create /etc/openvpn/home.conf, then start [email protected] if you had a VPN at home. This prevents you from having to create a .service file for every VPN you connect to.

But don't take my word for it. Try it out! Let's create a simple service that outputs a message to syslog. Create a file /etc/systemd/system/[email protected] with the following contents:

[Unit]
Description=Echo '%I'

[Service]
Type=oneshot
ExecStart=/bin/echo %i
StandardOutput=syslog

Notice the %i? systemd will populate that with whatever follows the @ sign when the service is started. So, try starting [email protected]:

systemctl start [email protected]

Then, check the journal:

 journalctl -n10

At the bottom, you'll see that systemd ran /bin/echo foo:

Feb 24 12:41:01 localhost echo[8412]: foo

Now, try systemctl start [email protected]. This time, systemd will populate %i with bar, so you'll see:

Feb 24 12:42:51 localhost echo[8432]: bar

That's all there is to it! Anything could potentially follow the @ sign, as systemd just replaces %i in the service definition with it. OpenVPN uses it for configuration, other services might use for something else, like a port number.

For more information, see man systemd.unit.