Score:0

How to save script (sh) runing with vi command plus how to remove file?

jp flag

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
#######################################################
  1. I do not know if I need to copy ########## at the beginning and end or just everything between those characters.

  2. I can't save it or exit (it is not Ctrl+S to save or Ctrl+X to exit or F2 to exit)

  3. 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.

muru avatar
us flag
Does this answer your question? [How do I save files edited with vim?](https://askubuntu.com/questions/252760/how-do-i-save-files-edited-with-vim)
muru avatar
us flag
And https://askubuntu.com/questions/1301119/what-are-swp-files-and-why-are-they-created
karel avatar
sa flag
Does this answer your question? [Can't save .bashrc file in VIM ("The swap file ".bashrc.swp" already exists!")](https://askubuntu.com/questions/736182/cant-save-bashrc-file-in-vim-the-swap-file-bashrc-swp-already-exists)
Someone avatar
my flag
Cannot you use `sudo apt install nano` and the `nano /path/to/file` or you can use `gedit /path/to/file` , VI isn't necessary , it is just a text editor like gedit and nano, And also ### doesn't mean anything
Score:1
ug flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.