[Seek Help] Deepin 20.3 内核5.15.1 smdb.service服务如何开机自启
Tofloor
poster avatar
卡苏Kasue
deepin
2021-12-05 17:25
Author

如题,共享文件夹已设置,共享密码已设置。

每次开机其他设备都无法打开Deepin的共享文件夹,

要么终端输入sudo service smbd start手动开启smdb.service

要么取消共享文件夹重新设置共享

有没有大神知道怎么让smdb.service开机自启?

Reply Favorite View the author
All Replies
wenzhizhong
deepin
2021-12-05 19:33
#1

查看一下有没有:

ls /etc/systemd/system/rc-local.service

没有的话

ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/

然后:

vi /etc/rc.loca

输入:

#!/bin/bash
service smbd restart

退出后:

chmod +x /etc/rc.local

systemctl enable rc-local.service
Reply View the author
川顺页
deepin
2021-12-05 19:33
#2

方法1

如果有systemd服务的话,可以直接用下面的命令开启

sudo systemctl enable smdb.service

方法2

弄一个开机自启的服务,然后把需要开机自启的命令粘贴到里面去。

  1. 编辑rc.local服务
sudo vim /lib/systemd/system/rc-local.service

最后面新增几行

[Install]
WantedBy=multi-user.target
Alias=rc-local.service

编辑后文件大概长这样

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

[Install]
WantedBy=multi-user.target
Alias=rc-local.service

  1. 编辑/etc/rc.local文件,这里粘贴需要自启后的命令
sudo vim /etc/rc.local

编辑后大概长这样

#!/bin/bash
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
service smbd start
# 这一句是你想要执行的自启动命令,可以省略sudo,默认就是root权限执行
exit 0
  1. 增加可执行权限
sudo chmod +x /etc/rc.local
  1. 建立软链接,方便systemctl 管理
sudo ln -s /lib/systemd/system/rc-local.service /etc/systemd/system/
  1. 测试一下
sudo systemctl restart rc-local
  1. 允许rc-local自启
sudo systemctl enable rc-local
Reply View the author
wenzhizhong
deepin
2021-12-05 19:34
#3
wenzhizhong

查看一下有没有:

ls /etc/systemd/system/rc-local.service

没有的话

ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/

然后:

vi /etc/rc.loca

输入:

#!/bin/bash
service smbd restart

退出后:

chmod +x /etc/rc.local

systemctl enable rc-local.service

Reply View the author