What's new

Tutorial Adding rc.local on your latest Debian/Ubuntu VPS

Fast VPN

Forum Veteran
Joined
Mar 25, 2020
Posts
3,486
Reaction
1,896
Points
869
Age
27
On the latest debian/ubuntu version the /etc/rc.local file is deprecated, but we can add it back using systemd for those scripts or applications that still depend on it.

1. Should be logged in as root or run this command in your console:
Code:
sudo su

2. Update and upgrade the VPS, run this command in your console:
Code:
apt-get update -y && apt-get upgrade -y && apt autoclean -y && apt autoremove

3.Now open your console and run this commands:
Code:
nano /etc/systemd/system/rc-local.service
Code:
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
 
[Install]
WantedBy=multi-user.target

Code:
nano /etc/rc.local

Code:
#!/bin/sh -e
#
# 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.
 
exit 0

4. Now open your console and run this commands; set the permissions:
Code:
chmod +x /etc/rc.local

5. Now open your console and run this commands:
Code:
systemctl enable rc-local

6. Now open your console and run this commands:
Code:
systemctl start rc-local

7. Test if your rc.local is working, run this command in your console:
Code:
systemctl status rc-local

You can now add what you want back into the rc.local file.
 
Ito po yung nag eexecute ng commands after mag restart/reboot ng VPS ninyo. For example si badvpn-udpgw dba pinapalagay ko po sa rc.local yung isang command para pag restart nyo ng vps automatic mag run sya para hindi nyo naraman i run yung command every time na mag restart kayo
 
Back
Top