0

my problem is that i keep forgetting to write sudo before every time i use nano, and eventually what happens is i work on a file for a while and don't have permissions. i remember hearing somewhere that you can edit one of the files so that every time i type nano filename it will function as if i wrote sudo nano filename

i haven’t tried anything since I've no previous knowledge about this.

how would i go about doing this?

3 Answers 3

6

I suggest to create a Bash alias. I'm assuming you're using Bash as a shell here.

alias nano='sudo nano'

This will map nano to sudo nano. To make it permanent, see this Q&A: How do I create a permanent Bash alias?

6
  • well i was hoping for something other than an alias which i knew excited, but maybe i misunderstood what i heard.
    – Giladiald
    Dec 24, 2013 at 17:01
  • Why aren't you satisfied with an alias? And what do you mean by "i knew excited"?
    – gertvdijk
    Dec 24, 2013 at 17:02
  • sorry i don't know what happened there, i meant that i knew about alias... and m not satisfied because i STILL need to enter the sudo password, i want a better flow. is there a away that i can edit the alias so that the password entry is already in it and i wont need to enter it?
    – Giladiald
    Dec 24, 2013 at 17:14
  • @Giladiald That's another question you're asking there. In your current question you ask how to make you not to forget using sudo. That's something else than asking for a solution to prevent asking sudo for a password for any command starting with nano. I suggest you ask a new question and I'm happy to answer it. In addition to that, always mention the paths you've already tried and why they weren't satisfiable in your question. It's sad to see people spending time on answers you don't want to see.
    – gertvdijk
    Dec 24, 2013 at 17:16
  • @Giladiald Ah, your answer is here. Combine it with my answer and you have your solution: How do I run specific sudo commands without a password? (use /usr/bin/nano as the command there)
    – gertvdijk
    Dec 24, 2013 at 17:20
1

You can switch to super user mode using:

sudo su

this will make you the super user for all your actions in the current terminal.

Be careful though - you are a super user anymore and have the capability of causing an unforgivable harm to your system on every single action of yours!

0

There is a reason why the root directory and it's subdirectories are protected and you have to acquire superuser privileges to edit files there.

You can use nano freely without superuser privileges within your home directory.

What you are trying to do is to override the security measures built into every Unix and Linux system and that is not always advisable.

If you insist on overriding these measures then aliasing nano to "sudo nano" will do that. You can add this line to your .bashrc file (or the config file for your favorite shell.

alias nano="sudo nano"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .