Different use of vi or vim editor for opening in read-only mode

hostgliders

New member
There are some situations like we need to view a file but we accidentally typed or misspelled something and saved.This is threat to file integrity an hence needs to avoided.

The solution is view files by vi or vim command by read-only mode.

>> view command

Simply open your file in view command and any attempt to alter or save changes will result in failure. If suppose you get into INSERT mode , you will get warning.

>> Using vi or vim command with -R option

The -R option is working same as the above one

--->> vi -R file name

>>using vi or vim command with -M option

-M = modifications are not allowed

All those three options are set for viewing a file in linux server/system in a secure way.
 
If you are only viewing, why not use CAT or TAIL?

For us, it's rare that we would ever need to view a file for the heck of it. Generally, we would be looking for something specific, at which point GREP and eGREP are our friends.

I can see how using VI or NANO in a read-mode could be useful for scrolling up or down, but normally we would use CAT on our systems.
 
There are many variants of using different commands to view the content of a file, but VIM is not one of them. It is pretty over the hand to use, that is why CAT or GREP are better, just like bigredseo suggested.

Other than that, I think that NANO is so much better than VIM when editing a file. Easier to use and more shortcuts.
 

Forum statistics

Threads
80,907
Messages
248,420
Members
20,678
Latest member
hostys
Top