<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://qingliezhiquan.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Emacs_%E5%90%8E%E5%8F%B0%E8%87%AA%E5%8A%A8%E5%90%AF%E5%8A%A8-%E7%94%A8%E6%88%B7%E5%B1%82%E9%9D%A2</id>
	<title>Emacs 后台自动启动-用户层面 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://qingliezhiquan.com/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Emacs_%E5%90%8E%E5%8F%B0%E8%87%AA%E5%8A%A8%E5%90%AF%E5%8A%A8-%E7%94%A8%E6%88%B7%E5%B1%82%E9%9D%A2"/>
	<link rel="alternate" type="text/html" href="https://qingliezhiquan.com/mediawiki/index.php?title=Emacs_%E5%90%8E%E5%8F%B0%E8%87%AA%E5%8A%A8%E5%90%AF%E5%8A%A8-%E7%94%A8%E6%88%B7%E5%B1%82%E9%9D%A2&amp;action=history"/>
	<updated>2026-08-11T09:20:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://qingliezhiquan.com/mediawiki/index.php?title=Emacs_%E5%90%8E%E5%8F%B0%E8%87%AA%E5%8A%A8%E5%90%AF%E5%8A%A8-%E7%94%A8%E6%88%B7%E5%B1%82%E9%9D%A2&amp;diff=7945&amp;oldid=prev</id>
		<title>Mwroot: Created page with &quot;&lt;syntaxhighlight lang=&quot;bash&quot;&gt; mkdir -p ~/.config/systemd/user nano ~/.config/systemd/user/emacs-user.service &lt;/syntaxhighlight&gt;  &lt;pre&gt; [Unit] Description=Emacs text editor as a daemon Documentation=info:emacs man:emacs(1)  [Service] Type=forking ExecStart=/usr/bin/emacs --daemon ExecStop=/usr/bin/emacsclient --eval &quot;(kill-emacs)&quot; Restart=on-failure  [Install] WantedBy=default.target &lt;/pre&gt;  &lt;syntaxhighlight lang=&quot;bash&quot;&gt; systemctl --user daemon-reload systemctl --user ena...&quot;</title>
		<link rel="alternate" type="text/html" href="https://qingliezhiquan.com/mediawiki/index.php?title=Emacs_%E5%90%8E%E5%8F%B0%E8%87%AA%E5%8A%A8%E5%90%AF%E5%8A%A8-%E7%94%A8%E6%88%B7%E5%B1%82%E9%9D%A2&amp;diff=7945&amp;oldid=prev"/>
		<updated>2025-09-29T02:19:28Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt; mkdir -p ~/.config/systemd/user nano ~/.config/systemd/user/emacs-user.service &amp;lt;/syntaxhighlight&amp;gt;  &amp;lt;pre&amp;gt; [Unit] Description=Emacs text editor as a daemon Documentation=info:emacs man:emacs(1)  [Service] Type=forking ExecStart=/usr/bin/emacs --daemon ExecStop=/usr/bin/emacsclient --eval &amp;quot;(kill-emacs)&amp;quot; Restart=on-failure  [Install] WantedBy=default.target &amp;lt;/pre&amp;gt;  &amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt; systemctl --user daemon-reload systemctl --user ena...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
mkdir -p ~/.config/systemd/user&lt;br /&gt;
nano ~/.config/systemd/user/emacs-user.service&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Emacs text editor as a daemon&lt;br /&gt;
Documentation=info:emacs man:emacs(1)&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=forking&lt;br /&gt;
ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
ExecStop=/usr/bin/emacsclient --eval &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
Restart=on-failure&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=default.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl --user daemon-reload&lt;br /&gt;
systemctl --user enable emacs-user.service&lt;br /&gt;
systemctl --user start emacs-user.service&lt;br /&gt;
systemctl --user status emacs-user.service&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
systemctl --user stop emacs-user.service    # 停止服务&lt;br /&gt;
systemctl --user disable emacs-user.service # 禁用自动启动&lt;br /&gt;
rm ~/.config/systemd/user/emacs-user.service&lt;br /&gt;
systemctl --user daemon-reload&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
这是在用户层面自启，对 sudo 用户也自启，请看下一篇。&lt;br /&gt;
&lt;br /&gt;
感谢 ChatGPT，上边是他教的。从此以后，就可以随时启动 emacsclient 了。&lt;/div&gt;</summary>
		<author><name>Mwroot</name></author>
	</entry>
</feed>