日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

kali添加開機自啟的方法_相關技巧

作者:Thr00k1e ? 更新時間: 2022-11-16 編程語言

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

可能出現的問題

  • 出現active,但是下面日志出現報錯

則你的systemd服務順利執行了。但是你的/etc/rc.local腳本有問題。自己執行下這個命令看看能不能正確執行該腳本。不能那就檢查腳本代碼,注意不要出現空行。重新檢查文件執行權限

./etc/rc.local
  • 沒顯示active

那么就是你的/etc/systemd/system/rc-local.service 寫的不對。重新檢查下,特別是[install]部分

原文鏈接:https://www.cnblogs.com/beidaxmf/p/14860651.html

欄目分類
最近更新