gogoWebsite

Solution to the * service permission denied in Linux configuration

Updated to 23 hours ago

question

During the first time configuring *, an error will occur when writing directly in the terminal, prompt: permission denied


1. Enter the directory to check whether there are files

Due to the first configuration, there may be no files in the /etc/systemd/system/ directory, resulting in an error.

# Enter the following command in the terminal to view
 cd~
cd /etc/systemd/system/#If the file is not given, create it through vim
 vim *.service #Enter enter file editing mode

2. Configure files in file editing mode

First type i on the keyboard to enter input mode, and then enter the following:

[Unit]
Description=*
After=network.target

[Service]
Type=simple
PIDFile=/usr/src/*/*.pid
ExecStart=/usr/src/*/* -c /usr/src/*/config.json -l /usr/src/*/*.log
ExecReload=/bin/kill -HUP \$MAINPID
Restart=on-failure
RestartSec=1s

[Install]
WantedBy=multi-user.target

After the input is completed, press Esc to exit the editing mode, press :wq to save and exit, and the configuration will be successful:)