sudo mkdir /var/www/site.local/publick_html Create a folder for the site

sudo vi /var/www/site.local/publick_html/index.php Create a file

Through the console, these 2 commands begin to “Fail” - https://yadi.sk/i/L4-Cg-jizjbmJ

they themselves are assigned to the file name .swp, I especially do not know how to use such swap files, and I don’t need it. How to fix it?

The console also hangs after writing these commands.

On the server, clean ubuntu 16.04 + LAMP

================================================= ===========

Edit1 * Installed vim by manual, but this did not help, the fact is that when you enter any vim or nano command, the console behaves very strangely, nothing can be entered after that. I use the Bitvise ssh client, but this is not about it. From despair installed desktop gvim, but I understand, it does not have a built-in console?)

  • 1. Your question (recall: “Why are the .swp files created via the console?”) Has been answered. 2. If you have another question, please ask it using the corresponding button in the upper right corner of the page. 3. The text is better to bring in the form of text, not pictures. 4. If a picture is needed, it should be added directly to the question. - aleksandr barakin Nov.
  • In fact, I did not solve the problem, .swp files are also created to register your team correctly, which “solves” the problem, I need to run vim from the console, and already at this stage it is not clear what to do - Egor Tregubenko
  • An editor for such a primitive is not needed. $ echo "set noswapfile" >> ~/.vimrc - aleksandr barakin
  • and generally vim -a swap-files is a useful and necessary component of the program. the fact that their existence has confused you so much is of course yours. I just answered your question about this. // create, please, a new question in which you formulate your problem. taking into account the points set out in my first comment. - aleksandr barakin Nov.

2 answers 2

a file with an additional suffix .swp creates a program vim .

besides the fact that it serves as a kind of sign indicating that the edited file (which without this suffix) is already being edited, it also records changes in the file with the additional suffix that are not yet saved, which allows you to restore these changes after, for example, the collapse of the program.

so that such a file with the suffix .swp not created next to the file being edited, you can:

  • or disable the swap file creation altogether by adding a command to vimrc

     set noswapfile 
  • or tell vim to create it somewhere in the user's home directory by redefining the value of the directory variable (in the same vimrc ), where comma-separated priority locations of such files are listed.

    eg:

     set directory=~/.vim/backup,.,/tmp 

    here, first, vim will try to create a swap file in the ~/.vim/backup directory, if it failed (the directory does not exist or cannot be written), then in the same directory as the file being edited - . , and if it failed there, then in /tmp .


in your case, the vim program is run as the root , so vimrc , which is located in /root/.vimrc home directory (see clarification below), must be changed, and, if you specify, for example, the ~/.vim/backup directory in the configuration ~/.vim/backup to store swap files, this directory will need to be created:

 $ sudo mkdir -p /root/.vim/backup 

clarification

which directory will be considered home for programs executed with the sudo program depends on the sudo program settings. you can check, for example, like this:

 $ sudo sh -c 'echo $HOME' 

    Judging by your question and the screenshot to it, you did not use vi (or its advanced version of vim ). Try using a more familiar editor, such as the one that comes in ubuntu nano :

     sudo nano /var/www/site.local/publick_html/index.php ^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ запустить редактор с именем файла от root (или др. программу) 
    • The fact is that my nano or vim commands work very strangely, nothing can be entered after them, yadi.sk/i/0Kf3N-q-znMr6 - Egor Tregubenko
    • nano or vim commands open a console text editor. If you just want to create a file, touch . - aleks.andr