In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you the "linux vi editors read-only documents can not be saved how to do", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "linux vi editors read-only documents can not be saved how to do" this article.
Use normal users to edit configuration files such as nginx.conf:
Saved time will prompt: no Root Permission
It can be solved in the following ways:
Add:
W! sudo tee%
I have a question here. There are no sudo permissions configured.
When using sudo, you will be prompted "xxx is not in the sudoers file. This incident will be reported." where XXX is your user name, that is, your user name does not have permission to use sudo. All we have to do is modify the / etc/sudoers file. Here is how to modify it:
1) enter superuser mode. That is, type "su -", the system will ask you to enter the super user password, enter the password to enter the superuser mode. (of course, you can also use root directly)
2) add write permission to the file. That is, enter the command "chmod Ubunw / etc/sudoers".
3) Edit / etc/sudoers file. That is, enter the command "vim / etc/sudoers", type "I" to enter edit mode, find this line: "root ALL= (ALL) ALL" add "xxx ALL= (ALL) ALL" (where xxx is your user name) below, and then save (that is, press the Esc key first, and then type ": wq") to exit.
4) revoke the write permission of the file. That is, enter the command "chmod Umurw / etc/sudoers".
Save again:
Check to see if it was successful:
$grep sudo nginx.conf
# test: W! sudo tee%
Explanation:
: w: Write a file. The file can be written, and the file is still in read-only mode, via: Q! Quit
! sudo: Call shell sudo command.
Tee: The output of the vi/vim write command is redirected using tee.
%: Triggers the use of the current filename.
Simply put, the 'tee' command is run as sudo and follows the vi/vim command on the current filename given.
Add:
I read a lot of answers on the Internet, mostly in one sentence:
W! sudo tee%
Or:
Do you have the authority to modify the file?
If it is root permission, you can
: wq!
In fact, what I want to say is one sentence: add sudo when opening the file.
That is, the sudo vi / etc/crontab command opens the file, and at this point you enter the file with root privileges.
Exit the file at this point using: wq! Just do it.
The above is all the contents of the article "what to do if the vi editor's read-only document cannot be saved under linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.