ubuntu设置开机无需输入密码自启动todesk,内网穿透natapp

发布于:2025-02-10 ⋅ 阅读:(57) ⋅ 点赞:(0)

设置todesk自启动

1、完善rc-local.service服务

sudo vim /lib/systemd/system/rc-local.service 

 写入以下内容

#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  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]
After=network.target
StartLimitIntervalSec=0

[Service]
Restart=always
RestartSec=1
ExecStart=/etc/rc.local
TimeoutSec=0

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

2、添加/etc/rc.local文件

  1. 创建文件touch /etc/rc.local

  2. 在/etc/rc.local文件里面输入要运行的shell命令

systemctl restart todeskd
/usr/local/sunlogin/bin/sunloginclient
  1. 添加可执行权限 chmod +x /etc/rc.local

 

3、设置开启启动rc-local服务

执行systemctl enable rc-local.service即可

参考链接:Ubuntu22.04如何开机重新自动运行脚本_ubuntu 22.04 开机启动脚本-CSDN博客ubuntu 22.04 开机自启动脚本 - 南风丶轻语 - 博客园

设置natapp自启动

1. 创建 Systemd 服务文件

  1. 打开终端并创建一个新的服务文件。通常,服务文件存放在 /etc/systemd/system/ 目录下。您可以使用 sudo 权限来创建和编辑这个文件:

    
    sudo vim /etc/systemd/system/natapp.service

        2.在编辑器中,添加以下内容:

[Unit]
Description=Natapp Service
After=network.target

[Service]
ExecStart=/home/zeqi/softWare/natAPP/natapp -authtoken=9ab6b9040a624f40
WorkingDirectory=/home/zeqi/softWare/natAPP
Restart=always
User=zeqi

[Install]
WantedBy=multi-user.target
    • Description: 服务的描述。

    • After: 指定服务在网络服务启动之后启动。

    • ExecStart: 指定要执行的命令。

    • WorkingDirectory: 设置工作目录,确保命令在正确的目录下执行。

    • Restart: 设置服务在失败时自动重启。

    • User: 指定运行服务的用户。

    • WantedBy: 指定服务在 multi-user.target 下启用。

  1. 保存并退出编辑器

2. 启用并启动服务

  1. 重新加载 systemd 配置以应用新的服务文件:

  2. sudo systemctl daemon-reload
  3. 启用服务,使其在系统启动时自动运行:

    sudo systemctl enable natapp.service

3. 检查服务状态

您可以使用以下命令检查服务的状态,确保它已正确启动:

sudo systemctl status natapp.service

网站公告

今日签到

点亮在社区的每一天
去签到