kali添加开机自启的方法

作者:Thr00k1e 时间:2023-06-06 04:15:06 

kali添加开机自启

采用systemd的方法,kali默认是没有rc.local的,需要自己创建。本方法也适用于ubuntu 18.04 64bit

改写rc-local.service 文件

先从lib中拿出模板文件进行更改

sudo cp /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service

再vim修改

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

主要是添加[install]复制最下面的[install]即可

#  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

创建/etc/rc.local文件

sudo vim /etc/rc.local
#!/bin/bash
#!/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.
/home/ki/桌面/frp_0.36.2_linux_amd64/frpc -c /home/ki/桌面/frp_0.36.2_linux_amd64/frpc.ini &
exit 0

注意,注释到执行代码这片区域中间不要有空行。不然该服务会将空行当命令执行,所以就会报错。命令后面我加上& 是表示在后台执行

设置执行权限

sudo chmod a+x /etc/rc.local

检查脚本是否正确

含义分别是重载服务,启动服务,查看服务状态

sudo systemctl enable rc-local
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

kali添加开机自启的方法

可能出现的问题

  • 出现active,但是下面日志出现报错

则你的systemd服务顺利执行了。但是你的/etc/rc.local脚本有问题。自己执行下这个命令看看能不能正确执行该脚本。不能那就检查脚本代码,注意不要出现空行。重新检查文件执行权限

./etc/rc.local
  • 没显示active

那么就是你的/etc/systemd/system/rc-local.service 写的不对。重新检查下,特别是[install]部分

来源:https://www.cnblogs.com/beidaxmf/p/14860651.html

标签:kali,开机,启动
0
投稿

猜你喜欢

  • Python3学习笔记之列表方法示例详解

    2023-02-04 06:47:35
  • Go语言基础设计模式之策略模式示例详解

    2024-05-25 15:11:01
  • phpstudy无法启动MySQL服务的完美解决办法

    2024-05-22 10:08:59
  • 页面只能打开一次Cooike如何实现

    2024-04-22 22:39:32
  • Python练习之操作MySQL数据库

    2024-01-20 12:29:22
  • pythotn条件分支与循环详解

    2021-12-02 12:20:08
  • 详解Open Folder as PyCharm Project怎么添加的方法

    2021-06-25 05:56:53
  • ASP开发网页牢记注意事项

    2013-06-28 16:20:30
  • pandas.read_csv参数详解(小结)

    2022-03-10 21:00:35
  • mysql慢查询优化之从理论和实践说明limit的优点

    2024-01-26 11:59:51
  • go mayfly开源项目代码结构设计

    2024-02-20 04:51:17
  • Python bisect模块原理及常见实例

    2023-01-12 07:22:15
  • Python利用pywin32实现自动操作电脑

    2024-01-03 03:35:59
  • python 使用值来排序一个字典的方法

    2022-02-05 00:25:05
  • Keras框架中的epoch、bacth、batch size、iteration使用介绍

    2023-10-13 13:15:13
  • Anaconda+vscode+pytorch环境搭建过程详解

    2022-04-06 01:37:19
  • JavaScript高级程序设计 扩展--关于动态原型

    2024-04-10 11:03:50
  • 完全卸载MYSQL

    2011-02-23 12:11:00
  • vue 动态创建组件的两种方法

    2024-05-09 10:51:27
  • Python接口自动化之cookie、session应用详解

    2023-02-02 11:10:35
  • asp之家 网络编程 m.aspxhome.com