ubuntu Writing shell Script Boot Auto Boot of Recommendation

  • 2021-07-10 21:20:13
  • OfStack

Scripts are written so that you don't have to open various services manually (and also to be lazy haha)

Step 1 Enter terminal input

Create a script file with the suffix. sh

touch test.sh

Edit script

vim test.sh

test. sh scripting content

2. Write test. sh scripts


# Provides:     test
# Required-Start:  $remote_fs $syslog
# Required-Stop:   $remote_fs $syslog
# Default-Start:   2 3 4 5
# Default-Stop:   0 1 6
# Short-Description: start test
# Description:    start test

# Write the script content here 
cd /home/Desktop/
exit 0

With #! /bin/bash beginning, middle script content, end of exit0

3. Move the test. sh file to the/etc/init. d directory

Move a file

sudo mv test.sh /etc/init.d/

Add permissions to files

chmod +750 test.sh

Set the boot to start automatically

sudo update-rc.d test.sh defaults

4. So that a boot automation script is completed


Related articles: