editing tomcat-users.xml in CentOS 7 linux

2019-09-21 15:24发布

I am trying to edit tomcat-users.xml in tomcat 8, using the terminal of CentOS 7 linux. I typed su - to use the terminal as the root account. I then typed in vi $CATALINA_HOME/conf/tomcat-users.xml, but the result is that vi opens in the window with the contents of tomcat-users.xml in read-only mode, and there seems to be no way out of vi except to close the window, losing all the terminal history. I also navigated to the physical location of tomcat-users.xml and opened up the file using gedit, but gedit will not allow me to save the file. How can I edit tomcat-users.xml?

3条回答
唯我独甜
2楼-- · 2019-09-21 15:51

When you open vi, you are in command mode. Type i to place yourself in insert mode. make your edits then when you are finished use the escape key to toggle back to command mode. Then type :q! to exit without saving or ZZ to save and close. I believe barjomet is correct that as root, :wq! will allow you to write to a read only file.

you might want to investigate why the file permissions are read only. See who owns the file and what the permissions are by using the ls command with the -l option Example: ls -l /some/folder/somefile.xml

change the permissions (if you know what you're doing) by using chmod command and change owner by using the chown command (be careful, don't mess up the permissions and create a security flaw, I can't help with that as I don't know tomcat)

查看更多
Animai°情兽
3楼-- · 2019-09-21 16:07

You can edit read-only file as root with vi — just type :wq! when you finish.

If you not familiar with vi and have vim installed — I recommend you to run vimtutor and spent about an hour to learn basics, otherwise read this short tutorial.

查看更多
贪生不怕死
4楼-- · 2019-09-21 16:12

First thing to edit tomcat-user.xml file you need administrative privilege. If you the admin access. you can use vi or vim to edit the file when the file opens, to edit the hit key a or i, it will let you edit at the bottom you can see Insert text. After editing to save press esc key can type :wq!

查看更多
登录 后发表回答