在實際生產環境中將程序打包部署到linux上或者在linux上更新程序時,很多時候都要修改.zip包或者.tar.gz包中的配置文件的內容,如果在本機和linux上進行包程序拖動然後再進行改動那就顯得非常麻煩。linux中的vim命令可以非常方便的修改.tar.gz或者.zip包中的內容。
1.用vim命令修改 apache-tomcat-7.0.82.tar.gz中server.xml中的tomcat默認端口號。
1)將apahce-tomcat-7.0.82.tar.gz進行備份(mv移動到其它目錄)
2) vim編輯.tar.gz包
[root@192 tomcat7]# vim apache-tomcat-7.0.82.tar.gz
apache-tomcat-7.0.82/webapps/host-manager/images/docs.gif
apache-tomcat-7.0.82/webapps/host-manager/images/fix.gif
apache-tomcat-7.0.82/webapps/host-manager/images/tomcat.gif
apache-tomcat-7.0.82/webapps/host-manager/images/update.gif
apache-tomcat-7.0.82/webapps/host-manager/images/void.gif
apache-tomcat-7.0.82/webapps/host-manager/index.jsp
apache-tomcat-7.0.82/webapps/host-manager/manager.xml
apache-tomcat-7.0.82/webapps/manager/META-INF/context.xml
apache-tomcat-7.0.82/webapps/manager/WEB-INF/jsp/401.jsp
apache-tomcat-7.0.82/webapps/manager/WEB-INF/jsp/403.jsp
apache-tomcat-7.0.82/webapps/manager/WEB-INF/jsp/404.jsp
apache-tomcat-7.0.82/webapps/manager/WEB-INF/jsp/sessionDetail.jsp
apache-tomcat-7.0.82/webapps/manager/WEB-INF/jsp/sessionsList.jsp
apache-tomcat-7.0.82/webapps/manager/WEB-INF/web.xml
apache-tomcat-7.0.82/webapps/manager/images/add.gif
apache-tomcat-7.0.82/webapps/manager/images/asf-logo.svg
apache-tomcat-7.0.82/webapps/manager/images/code.gif
apache-tomcat-7.0.82/webapps/manager/images/design.gif
apache-tomcat-7.0.82/webapps/manager/images/docs.gif
apache-tomcat-7.0.82/webapps/manager/images/fix.gif
apache-tomcat-7.0.82/webapps/manager/images/tomcat.gif
apache-tomcat-7.0.82/webapps/manager/images/update.gif
apache-tomcat-7.0.82/webapps/manager/images/void.gif
apache-tomcat-7.0.82/webapps/manager/index.jsp
apache-tomcat-7.0.82/webapps/manager/status.xsd
apache-tomcat-7.0.82/webapps/manager/xform.xsl
3)用/conf/server.xml搜索出server.xml文件,修改端口:wq退出然後退到上一層目錄再:q退出。
2.vim命令一些快捷方式命令總結
退出並保存 | :wq |
退出並強制保存 | :wq! |
強制退出,不保存 | :q! |
將光標移動到文件的最後一行 | shinft+g |
將光標移動到文件的第一行 | gg |
將光標從所在位置移動到當前行的開頭 | 0 |
將光標從所在位置移動到當前行的結尾 | $ |
從光標位置開始,向下尋找名爲session的字符串 | /session |
從光標位置開始,向上尋找名爲session的字符串 | ?session |
從光標位置開始, 向下重複前一個搜索的動作 | n |
從光標位置開始,向上重複前一個搜索的動作 | N |
刪除光標所在的當前行 | dd |
進入編輯模式 | i |
切回到普通模式 | esc |