Why do Linux instructions almost never include sudo even when it is obviously necessary?

You see it a lot, for example, you will see something like:

"Edit /etc/hosts by doing $nano /etc/hosts and type in this huge block of text"

Then you find out you don't have permissions and all that work was for nothing (unless you can copy paste/xclip it all or something).

Then you do what should have been written and go "sudo nano /etc/hosts" and try again.

The example here is just that: an example. This happens a lot and can be really confusing sometimes. Specially when the system allows for a command to be run as user and as root/sudo and you really need the second.

closed as primarily opinion-based by muru, Sylvain Pineau, Eric Carvalho, Jacob Vlijm, Seth Mar 13 '15 at 16:59

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Ask the person who wrote the instructions. – muru Mar 13 '15 at 10:38
  • It's a general thing. Almost like a fashion thing that everyone does. I do believe it has a side intent to protect the end user, but can't see another reason for it. Also, understand the question before commenting. – fullmooninu Mar 13 '15 at 10:39
  • 1
    I don't see it often. – muru Mar 13 '15 at 10:40
  • Often, the prompt is shown. If the prompt ends in $, then use sudo. If it's #, don't. – Jos Mar 13 '15 at 11:03
  • 3
    When writing a long set of commands or detailed instructions it is frustrating to keep writing sudo foo sudo bar etc. Generally people will make note to run commands as root and generally if you are modifying files outside of $HOME you will need to do so as root. – Panther Mar 13 '15 at 12:03

Why do Linux instructions almost never include sudo even when it is obviously necessary?

  • Because not all Linux systems use sudo.
  • Because the guide you are following is not targeted towards "debian" style systems.

Then do what you should do: sudo nano /etc/hosts and try again.

Nope. You do sudo !! and press enter. The system will repeat the last command and put sudo in front of it.

  • What I'd do is save elsewhere and copy over. – muru Mar 13 '15 at 10:44
  • Yeh, that's the logic that I had envisioned. Still seems bad design to have instruction where you need to run as root without at least a sign saying so. – fullmooninu Mar 16 '15 at 12:19

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