5

I am new to Ubuntu. I know I can open a file using vim in read-only mode by pass the -R option:

vim -R <filename> //Gives warning if I try to write

However, if I do the same thing with nano, I am able to write files freely:

nano -R <filename>  //I can still write

What am I doing wrong? How can I open files in read-only mode using nano?

Cody Gray
  • 103
Trojan
  • 71

1 Answers1

25

Nano does not use '-R' as a "read-only-" option and uses '-R' for something else.

-R, --restricted

Restricted mode: don't read or write to any file not specified on the command line. This means: don't read or write history files; don't allow suspending; don't allow spell checking; don't allow a file to be appended to, prepended to, or saved under a different name if it already has one; and don't make backup files. Restricted mode can also be activated by invoking nano with any name beginning with 'r' (e.g. "rnano").

it uses -v or --view:

-v, --view

Just view the file and disallow editing: read-only mode. This mode allows the user to open also other files for viewing, un‐ less --restricted is given too.

Rinzwind
  • 309,379