Twitter     Facebook
Hosting Discussion

Hosting Discussion > Web Hosting Forums > Essential Software & Control Panels > Different use of vi or vim editor for opening in read-only mode
forgot password?



  Post #1 (permalink)   02-15-2017, 10:51 PM
HD Newbie
Join Date: Feb 2017
Location: Oman
Posts: 41

Status: hostgliders is offline
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.

  Post #2 (permalink)   02-16-2017, 10:50 AM
HD Community Advisor
bigredseo's Avatar
Join Date: Aug 2015
Location: Omaha, Nebraska
Posts: 447

Status: bigredseo is offline
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.
Conor Treacy
Big Red SEO - SEO, Web Design, PPC Management & Training <- That's Me! ;)
The Following 2 Users Say Thank You to bigredseo For This Useful Post:
HostAG (02-16-2017), SenseiSteve (02-16-2017)

  Post #3 (permalink)   02-16-2017, 10:05 PM
HD Newbie
Join Date: Dec 2014
Posts: 36
Send a message via Skype™ to HostAG

Status: HostAG is offline
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.
The Following User Says Thank You to HostAG For This Useful Post:
bigredseo (02-17-2017)

Thread Tools

New Post New Post   Old Post Old Post
Posting Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On