How to save script (sh) runing with vi command plus how to remove file?
I am installing DUC (Dynamic update client) for NO-IP DDNS on Ubuntu 20.04 desktop.
I used help from this site : https://www.blackmoreops.com/2020/11/18/how-to-install-the-noip2-on-ubuntu-and-run-via-systemd-systemctl-noip-dynamic-update-client/
I got stuck when I need to do this:
root@ubuntu:/usr/local/src/noip-2.1.9-1# vi /etc/init.d/noip2.sh
Paste the following in the file and save it:
#######################################################
#! /bin/sh
# . /etc/rc.d/init.d/functions # uncomment/modify for your killproc
case "$1" in
start)
echo "Starting noip2."
/usr/local/bin/noip2
;;
stop)
echo -n "Shutting down noip2."
killproc -TERM /usr/local/bin/noip2
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
#######################################################
-
I do not know if I need to copy
##########
at the beginning and end or just everything between those characters. -
I can't save it or exit (it is not Ctrl+S to save or Ctrl+X to exit or F2 to exit)
-
I think that I have a few files in folder
etc/int.d
that are not needed or they are duplicated:.noip2.sh.swl .noip2.sh.swm .noip2.sh.swn .noip2.sh.swo
I do not know how to remove them if necessary.
The #
means whatever follows it will be a comment, so whether you include those lines or not makes no difference.
vi
doesn't use ctrl+s to save. To write the buffer to disk and quit press escape followed by :wq
(short for write and quit).
Here are some other ways to exit vi(m).
As for the files, they are temporary files created by vi
and will go away when you close the editor.