Vim saves the root permission file in Linux, and directly uses vim to edit the file in/etc/without sudo. After editing, when you use vim to save the file, you will be prompted that the file cannot be saved, at this time, no permission is found. There are currently several solutions to this problem. 1. Run the command w when saving vi/etc/httpd. conf! Sudo tee %: w-Write a file .! Sudo-Call shell sudo command. tee-The output of write (vim: w) command is redirected using tee. the % is nothing but current file name I. e. /etc/httpd. conf. in other words tee command is run as root and it takes standard input and write it to a file represented by %. however, this will prompt to reload file again (hit L to load changes in vim itself ). we strongly recommend this method. However, you must first ensure that the user running vim has the sudo permission. 2. Edit the user $ HOME/. vimrc file and rename the hard-to-remember command in the first solution. You can use it directly next time. Vim $ HOME/. vimrc Add the following sentence and save it. Command-nargs =? Sudow: w! Sudo tee % when you use vim to edit sudo files in the future, use the Sudow command defined here to save sudo files. 3. First save it to a temporary file, and then use root to copy it to overwrite the file to be edited. A file that may be opened with the user account, vim/etc/httpd. conf. After editing the number in vim, use w/tmp/httpd. conf to save it as a temporary file. 4. Use sudo vim directly when using vim. Haha, for example, sudo vim/etc/httpd. conf.