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
?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Tomcat and SSL Client certificate
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
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)
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.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!