# Starting Emacs on boot

· by [Joakim Verona] · Read in about 1 min · (120 words) ·

I use Emacs all the time. My most important Emacs runs in my own server, which I access remotely either through a tty terminal, or a graphical session. The terminal can either be plain ssh, or mosh. The graphical session is x2go at the moment.

Since I always want an Emacs running, and I want to access the same emacs session in different ways, its convenient to start Emacs on boot.

The file /etc/systemd/system/emacs@.service:

[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
Restart=always
User=%i
WorkingDirectory=%h

[Install]
WantedBy=multi-user.target



Then in my case:

systemctl enable emacs@joakim
systemctl start emacs@joakim


I have been using this for a while and it works pretty well!

Latest Posts