Difference between revisions of "Saving file as root using sudo"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb> =Saving files as root using sudo= Many times while working as normal user, one ends up editing a system file such as '<tt>/etc/ho...")
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Text editors]] > [[Vim]] > [[Saving file as root using sudo]]
=Saving files as root using sudo=


Many times while working as normal user, one ends up editing a system file such as '<tt>/etc/hosts</tt>' as normal user. On saving the changes error 'readonly' file gets generated due to insufficient permissions. In such cases to save file as root without loosing the changes one can use 'sudo' command, provided the current user has sudo access. (Sudo access configuration can be learned from [[Allowing user to run all commands as root without specifying password]]). To save file as root with sudo one can use:
Many times while working as normal user, one ends up editing a system file such as '<tt>/etc/hosts</tt>' as normal user. On saving the changes error 'readonly' file gets generated due to insufficient permissions. In such cases to save file as root without loosing the changes one can use 'sudo' command, provided the current user has sudo access. (Sudo access configuration can be learned from [[Allowing user to run all commands as root without specifying password]]). To save file as root with sudo one can use:
Line 9: Line 8:


Steps learned from http://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without-root-permission/
Steps learned from http://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without-root-permission/
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Text editors]] > [[Vim]] > [[Saving file as root using sudo]]

Latest revision as of 15:50, 24 August 2022

Home > CentOS > CentOS 6.x > Text editors > Vim > Saving file as root using sudo

Many times while working as normal user, one ends up editing a system file such as '/etc/hosts' as normal user. On saving the changes error 'readonly' file gets generated due to insufficient permissions. In such cases to save file as root without loosing the changes one can use 'sudo' command, provided the current user has sudo access. (Sudo access configuration can be learned from Allowing user to run all commands as root without specifying password). To save file as root with sudo one can use:

:w !sudo tee %


Steps learned from http://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without-root-permission/


Home > CentOS > CentOS 6.x > Text editors > Vim > Saving file as root using sudo