Usually I use nano editor but with -t parameter. From man nano:

   -t (--tempfile)
          Always save changed buffer without prompting.  Same as Pico’s -t option.

It just doesn't ask me about saving yes/no and save to this file or another one.

So, it won't ask when I going to exit. But when this file is readonly I couldn't find a way to exit excepting save this file in different path.

Is there any way to exit without saving?


I could not find a solution for nano, but a workaround:

Use a shell function and test before opening, if the file is writable.

Open your .bashrc

nano ~/.bashrc

and add the code below

mynano() {
    if [ -w "$1" ]; then
            nano -t "$1"
            echo "$1 isn't writable"

save the file and reload the configuration.

source ~/.bashrc


$ ls -la foo
-rw-rw-r-- 1 root root 4 Sep 12 14:01 foo

$ whoami

$ mynano foo
foo isn't writable
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.