vim:saving_a_file_as_root
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
vim:saving_a_file_as_root [2020/01/09 01:51] – created peter | vim:saving_a_file_as_root [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 7: | Line 7: | ||
<code vi> | <code vi> | ||
:w !sudo tee % | :w !sudo tee % | ||
- | </vi> | + | </code> |
* **:w** - write a file. | * **:w** - write a file. | ||
Line 14: | Line 14: | ||
* **%** - The % is nothing but current filename. | * **%** - The % is nothing but current filename. | ||
- | tee command is run as root and it takes standard input (or the buffer) and writes it to a file represented by %. | + | **tee** command is run as root and it takes standard input (or the buffer) and writes it to a file represented by %. |
This will prompt to reload the file again - hit **L** to load changes within vi itself. | This will prompt to reload the file again - hit **L** to load changes within vi itself. | ||
Line 39: | Line 39: | ||
Edit the file, and write as a privileged file with custom command, just type: | Edit the file, and write as a privileged file with custom command, just type: | ||
- | <code vi> | + | <code vi> |
w: | w: | ||
- | </vi> | + | </code> |
sudo will require that you authenticate yourself, so enter your password when prompted. | sudo will require that you authenticate yourself, so enter your password when prompted. | ||
vim/saving_a_file_as_root.1578534703.txt.gz · Last modified: 2020/07/15 09:30 (external edit)