Difference between revisions of "Ubuntu: rc.local di ubuntu 18.04"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
Line 31: | Line 31: | ||
That's it. You can now use this file to execute commands at system boot. Just paste your commands above the line that says exit 0 | That's it. You can now use this file to execute commands at system boot. Just paste your commands above the line that says exit 0 | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Contoh Entry rc.local== | ||
+ | |||
+ | # By default this script does nothing. | ||
+ | |||
+ | /sbin/ifconfig enp2s0 down | ||
+ | /sbin/ifconfig enp3s0 down | ||
+ | /sbin/ifconfig enp2s0 192.168.0.252 | ||
+ | /sbin/ifconfig enp3s0 192.168.0.253 | ||
+ | /sbin/ifconfig enp2s0 up | ||
+ | /sbin/ifconfig enp3s0 up | ||
+ | sleep 10 | ||
+ | /sbin/dhclient enp3s0 | ||
+ | /sbin/dhclient enp2s0 | ||
+ | /etc/init.d/smbd restart | ||
+ | /etc/init.d/nfs-kernel-server restart | ||
+ | /usr/bin/utserver -settingspath /opt/utorrent-server-alpha-v3_3/ -daemon | ||
+ | |||
+ | exit 0 | ||
Revision as of 05:15, 21 November 2019
The /etc/rc.local files on Ubuntu and Debian systems are used to execute commands at system startup. But there's no such file in Ubuntu 18.04.
So what can we do? We can just create the file. Let's do it. Create the /etc/rc.local file with nano text editor,
nano /etc/rc.local
Paste the following lot,
#!/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
That's the content of Ubuntu 16.04's stock /etc/rc.local file. Now make it executable,
chmod +x /etc/rc.local
That's it. You can now use this file to execute commands at system boot. Just paste your commands above the line that says exit 0
Contoh Entry rc.local
# By default this script does nothing. /sbin/ifconfig enp2s0 down /sbin/ifconfig enp3s0 down /sbin/ifconfig enp2s0 192.168.0.252 /sbin/ifconfig enp3s0 192.168.0.253 /sbin/ifconfig enp2s0 up /sbin/ifconfig enp3s0 up sleep 10 /sbin/dhclient enp3s0 /sbin/dhclient enp2s0 /etc/init.d/smbd restart /etc/init.d/nfs-kernel-server restart /usr/bin/utserver -settingspath /opt/utorrent-server-alpha-v3_3/ -daemon exit 0