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?

Giladiald
  • 239
  • 1
  • 4
  • 13

3 Answers3

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?

gertvdijk
  • 69,427
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!

hatef
  • 185
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"
haziz
  • 3,067